aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/to-javascript.js
diff options
context:
space:
mode:
authoreric <thul.eric@gmail.com>2017-08-24 19:58:05 -0400
committerGitHub <noreply@github.com>2017-08-24 19:58:05 -0400
commita8410d6d39fc84499b5f804802b5b6e5ea07e92f (patch)
tree6982a97f0bf8f9e7f3d5c15e179f7114ea309ddd /src/to-javascript.js
parentb881e30ce321b9758f071289c4f22650d6457371 (diff)
downloadpurs-loader-a8410d6d39fc84499b5f804802b5b6e5ea07e92f.tar.gz
purs-loader-a8410d6d39fc84499b5f804802b5b6e5ea07e92f.tar.zst
purs-loader-a8410d6d39fc84499b5f804802b5b6e5ea07e92f.zip
Generate module map once (#105)
Resolves #97
Diffstat (limited to 'src/to-javascript.js')
-rw-r--r--src/to-javascript.js23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/to-javascript.js b/src/to-javascript.js
index b3e3051..3cc9698 100644
--- a/src/to-javascript.js
+++ b/src/to-javascript.js
@@ -26,21 +26,24 @@ function updatePsModuleMap(psModule) {
26 const filePurs = psModule.srcPath; 26 const filePurs = psModule.srcPath;
27 27
28 if (!cache.psModuleMap) { 28 if (!cache.psModuleMap) {
29 debug('module mapping does not exist'); 29 debugVerbose('module mapping does not exist - making a new module map');
30 30
31 return PsModuleMap.makeMap(options.src).then(map => { 31 cache.psModuleMap = PsModuleMap.makeMap(options.src);
32 cache.psModuleMap = map; 32
33 return cache.psModuleMap; 33 return cache.psModuleMap;
34 });
35 } 34 }
36 else { 35 else {
37 return PsModuleMap.makeMapEntry(filePurs).then(result => { 36 debugVerbose('module mapping exists - updating module map for %s', filePurs);
38 const map = Object.assign(cache.psModuleMap, result); 37
38 cache.psModuleMap = cache.psModuleMap.then(psModuleMap =>
39 PsModuleMap.makeMapEntry(filePurs).then(result => {
40 const map = Object.assign(psModuleMap, result);
39 41
40 cache.psModuleMap = map; 42 return map;
43 })
44 );
41 45
42 return cache.psModuleMap; 46 return cache.psModuleMap;
43 });
44 } 47 }
45} 48}
46 49