aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/to-javascript.js21
1 files changed, 15 insertions, 6 deletions
diff --git a/src/to-javascript.js b/src/to-javascript.js
index a7d64a2..3663c83 100644
--- a/src/to-javascript.js
+++ b/src/to-javascript.js
@@ -109,12 +109,21 @@ function makeJS(psModule, psModuleMap, js) {
109 return Promise.resolve(result); 109 return Promise.resolve(result);
110 } 110 }
111 else { 111 else {
112 debug('rebuilding module map due to additional imports for %s: %o', name, additionalImports); 112 const missingImports = additionalImports.filter(moduleName =>
113 113 !psModuleMap[moduleName] && moduleName.split('.')[0] !== 'Prim'
114 psModule.cache.psModuleMap = null; 114 );
115 115
116 return updatePsModuleMap(psModule).then(updatedPsModuleMap => { 116 let updatingPsModuleMap;
117 const additionalImportsResult = additionalImports.map(import_ => { 117 if (missingImports.length > 0) {
118 debug('rebuilding module map due to missing imports for %s: %o', name, missingImports);
119 psModule.cache.psModuleMap = null;
120 updatingPsModuleMap = updatePsModuleMap(psModule);
121 } else {
122 updatingPsModuleMap = Promise.resolve(psModuleMap);
123 }
124
125 return updatingPsModuleMap.then(updatedPsModuleMap => {
126 const missingImportsResult = missingImports.map(import_ => {
118 const moduleValue = updatedPsModuleMap[import_]; 127 const moduleValue = updatedPsModuleMap[import_];
119 128
120 if (!moduleValue) { 129 if (!moduleValue) {
@@ -129,7 +138,7 @@ function makeJS(psModule, psModuleMap, js) {
129 } 138 }
130 }).filter(a => a !== null).join('\n'); 139 }).filter(a => a !== null).join('\n');
131 140
132 return result + '\n' + additionalImportsResult; 141 return result + '\n' + missingImportsResult;
133 }); 142 });
134 } 143 }
135} 144}