diff options
author | eric thul <thul.eric@gmail.com> | 2017-04-23 14:00:35 -0400 |
---|---|---|
committer | eric <thul.eric@gmail.com> | 2017-04-23 18:20:22 -0400 |
commit | 7f0547d4e02d927e766de340152a2f75b659d889 (patch) | |
tree | d9dd41f5902d81f73ad64772b34291887f4b4fdf /src/to-javascript.js | |
parent | 1c12889c0adf91cf3116a9d5ff44b7466b1dfcc9 (diff) | |
download | purs-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.js | 12 |
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 | ||
11 | const difference = require('lodash.difference'); | 11 | const difference = require('lodash.difference'); |
12 | 12 | ||
13 | const debug = require('debug')('purs-loader'); | 13 | const debug_ = require('debug'); |
14 | |||
15 | const debug = debug_('purs-loader'); | ||
16 | |||
17 | const debugVerbose = debug_('purs-loader:verbose'); | ||
14 | 18 | ||
15 | const PsModuleMap = require('./PsModuleMap'); | 19 | const 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 ? |