aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/to-javascript.js
diff options
context:
space:
mode:
authoreric thul <thul.eric@gmail.com>2017-04-23 14:00:35 -0400
committereric <thul.eric@gmail.com>2017-04-23 18:20:22 -0400
commit7f0547d4e02d927e766de340152a2f75b659d889 (patch)
treed9dd41f5902d81f73ad64772b34291887f4b4fdf /src/to-javascript.js
parent1c12889c0adf91cf3116a9d5ff44b7466b1dfcc9 (diff)
downloadpurs-loader-7f0547d4e02d927e766de340152a2f75b659d889.tar.gz
purs-loader-7f0547d4e02d927e766de340152a2f75b659d889.tar.zst
purs-loader-7f0547d4e02d927e766de340152a2f75b659d889.zip
Refactoring cache usage
Diffstat (limited to 'src/to-javascript.js')
-rw-r--r--src/to-javascript.js12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/to-javascript.js b/src/to-javascript.js
index b402ad4..d0934d5 100644
--- a/src/to-javascript.js
+++ b/src/to-javascript.js
@@ -10,7 +10,11 @@ const jsStringEscape = require('js-string-escape');
10 10
11const difference = require('lodash.difference'); 11const difference = require('lodash.difference');
12 12
13const debug = require('debug')('purs-loader'); 13const debug_ = require('debug');
14
15const debug = debug_('purs-loader');
16
17const debugVerbose = debug_('purs-loader:verbose');
14 18
15const PsModuleMap = require('./PsModuleMap'); 19const PsModuleMap = require('./PsModuleMap');
16 20
@@ -99,7 +103,7 @@ function makeJS(psModule, psModuleMap, js) {
99 const additionalImports = difference(imports, replacedImports); 103 const additionalImports = difference(imports, replacedImports);
100 104
101 if (additionalImports.length) { 105 if (additionalImports.length) {
102 debug('additional imports for %s: %o', name, additionalImports); 106 debugVerbose('additional imports for %s: %o', name, additionalImports);
103 } 107 }
104 108
105 const additionalImportsResult = additionalImports.map(import_ => { 109 const additionalImportsResult = additionalImports.map(import_ => {
@@ -129,13 +133,13 @@ module.exports = function toJavaScript(psModule) {
129 133
130 const bundlePath = path.resolve(options.bundleOutput); 134 const bundlePath = path.resolve(options.bundleOutput);
131 135
132 const jsPath = cache.bundle ? bundlePath : psModule.jsPath; 136 const jsPath = options.bundle ? bundlePath : psModule.jsPath;
133 137
134 const js = fs.readFileAsync(jsPath, 'utf8').catch(() => ''); 138 const js = fs.readFileAsync(jsPath, 'utf8').catch(() => '');
135 139
136 const psModuleMap = updatePsModuleMap(psModule); 140 const psModuleMap = updatePsModuleMap(psModule);
137 141
138 debug('loading JavaScript for %s', psModule.name); 142 debugVerbose('loading JavaScript for %s', psModule.name);
139 143
140 return Promise.props({js: js, psModuleMap: psModuleMap}).then(result => 144 return Promise.props({js: js, psModuleMap: psModuleMap}).then(result =>
141 options.bundle ? 145 options.bundle ?