aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/index.js
diff options
context:
space:
mode:
authoreric <thul.eric@gmail.com>2017-08-12 10:47:55 -0400
committerGitHub <noreply@github.com>2017-08-12 10:47:55 -0400
commit466c00689bf6e411becec2c1b6d5d3246f4aa834 (patch)
treecdf352238fb96cf09602edc58d8e5da4eadef18f /src/index.js
parent712dabc76c3f4495098e8f6bae47610c2857c59f (diff)
downloadpurs-loader-466c00689bf6e411becec2c1b6d5d3246f4aa834.tar.gz
purs-loader-466c00689bf6e411becec2c1b6d5d3246f4aa834.tar.zst
purs-loader-466c00689bf6e411becec2c1b6d5d3246f4aa834.zip
Adding source map support (#102)
* Adding source map support Resolves #101 * Remove unused fs
Diffstat (limited to 'src/index.js')
-rw-r--r--src/index.js10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/index.js b/src/index.js
index 4c5abd2..f90a218 100644
--- a/src/index.js
+++ b/src/index.js
@@ -22,6 +22,8 @@ const ide = require('./ide');
22 22
23const toJavaScript = require('./to-javascript'); 23const toJavaScript = require('./to-javascript');
24 24
25const sourceMaps = require('./source-maps');
26
25const dargs = require('./dargs'); 27const dargs = require('./dargs');
26 28
27const spawn = require('cross-spawn').sync 29const spawn = require('cross-spawn').sync
@@ -168,9 +170,11 @@ module.exports = function purescriptLoader(source, map) {
168 170
169 const psModule = { 171 const psModule = {
170 name: psModuleName, 172 name: psModuleName,
171 load: js => callback(null, js), 173 source: source,
174 load: ({js, map}) => callback(null, js, map),
172 reject: error => callback(error), 175 reject: error => callback(error),
173 srcPath: this.resourcePath, 176 srcPath: this.resourcePath,
177 remainingRequest: loaderUtils.getRemainingRequest(this),
174 srcDir: path.dirname(this.resourcePath), 178 srcDir: path.dirname(this.resourcePath),
175 jsPath: path.resolve(path.join(options.output, psModuleName, 'index.js')), 179 jsPath: path.resolve(path.join(options.output, psModuleName, 'index.js')),
176 options: options, 180 options: options,
@@ -226,6 +230,7 @@ module.exports = function purescriptLoader(source, map) {
226 ide.rebuild(psModule) 230 ide.rebuild(psModule)
227 .then(() => 231 .then(() =>
228 toJavaScript(psModule) 232 toJavaScript(psModule)
233 .then(js => sourceMaps(psModule, js))
229 .then(psModule.load) 234 .then(psModule.load)
230 .catch(psModule.reject) 235 .catch(psModule.reject)
231 ) 236 )
@@ -255,6 +260,7 @@ module.exports = function purescriptLoader(source, map) {
255 Promise.map(cache.deferred, psModule => 260 Promise.map(cache.deferred, psModule =>
256 ide.load(psModule) 261 ide.load(psModule)
257 .then(() => toJavaScript(psModule)) 262 .then(() => toJavaScript(psModule))
263 .then(js => sourceMaps(psModule, js))
258 .then(psModule.load) 264 .then(psModule.load)
259 ) 265 )
260 ) 266 )
@@ -287,6 +293,7 @@ module.exports = function purescriptLoader(source, map) {
287 debugVerbose('compilation is already finished, loading module %s', psModule.name); 293 debugVerbose('compilation is already finished, loading module %s', psModule.name);
288 294
289 toJavaScript(psModule) 295 toJavaScript(psModule)
296 .then(js => sourceMaps(psModule, js))
290 .then(psModule.load) 297 .then(psModule.load)
291 .catch(psModule.reject); 298 .catch(psModule.reject);
292 } 299 }
@@ -320,6 +327,7 @@ module.exports = function purescriptLoader(source, map) {
320 .then(() => 327 .then(() =>
321 Promise.map(cache.deferred, psModule => 328 Promise.map(cache.deferred, psModule =>
322 toJavaScript(psModule) 329 toJavaScript(psModule)
330 .then(js => sourceMaps(psModule, js))
323 .then(psModule.load) 331 .then(psModule.load)
324 ) 332 )
325 ) 333 )