aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/to-javascript.js
diff options
context:
space:
mode:
authoreric thul <thul.eric@gmail.com>2017-02-25 10:09:45 -0500
committereric thul <thul.eric@gmail.com>2017-02-25 10:09:45 -0500
commit09e09fb310cf98cfd9581425b6a75b013f7be74e (patch)
tree352d6b1cda8404f1a4311f65586aecf052436a67 /src/to-javascript.js
parent4305f5b0053d6fd2887b364c5da0a1ca6c06fc54 (diff)
downloadpurs-loader-09e09fb310cf98cfd9581425b6a75b013f7be74e.tar.gz
purs-loader-09e09fb310cf98cfd9581425b6a75b013f7be74e.tar.zst
purs-loader-09e09fb310cf98cfd9581425b6a75b013f7be74e.zip
Adding an additional module check
Diffstat (limited to 'src/to-javascript.js')
-rw-r--r--src/to-javascript.js15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/to-javascript.js b/src/to-javascript.js
index 0acf180..b402ad4 100644
--- a/src/to-javascript.js
+++ b/src/to-javascript.js
@@ -103,10 +103,19 @@ function makeJS(psModule, psModuleMap, js) {
103 } 103 }
104 104
105 const additionalImportsResult = additionalImports.map(import_ => { 105 const additionalImportsResult = additionalImports.map(import_ => {
106 const escapedPath = jsStringEscape(psModuleMap[import_].src); 106 const moduleValue = psModuleMap[import_];
107 107
108 return `var ${import_.replace(/\./g, '_')} = require("${escapedPath}")`; 108 if (!moduleValue) {
109 }).join('\n'); 109 debug('module %s was not found in the map, skipping require', import_);
110
111 return null;
112 }
113 else {
114 const escapedPath = jsStringEscape(moduleValue.src);
115
116 return `var ${import_.replace(/\./g, '_')} = require("${escapedPath}")`;
117 }
118 }).filter(a => a !== null).join('\n');
110 119
111 const result_ = result + (additionalImports.length ? '\n' + additionalImportsResult : ''); 120 const result_ = result + (additionalImports.length ? '\n' + additionalImportsResult : '');
112 121