From df8798fa0eeeb3dfcce14dc10100b03f708b57f6 Mon Sep 17 00:00:00 2001 From: eric thul Date: Sun, 19 Feb 2017 11:29:57 -0500 Subject: Add a watch option Similar to the way psc-ide support works, the purs-loader now tolerates compiler errors when the `watch` option is true. When webpack is being run in watch mode the user can set `watch` to true in order to avoid failing the webpack bundle creation when the PureScript compiler fails. Resolves issue #66 Resolves issue #73 Resolves issue #74 --- README.md | 1 + src/Psc.js | 7 ++++++- src/index.js | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3b31354..931e4e6 100644 --- a/README.md +++ b/README.md @@ -61,6 +61,7 @@ const loaderConfig = { bundleNamespace: 'PS', bundle: false, warnings: true, + watch: false, // indicates if webapck is in watch mode output: 'output', src: [ path.join('src', '**', '*.purs'), diff --git a/src/Psc.js b/src/Psc.js index 4991d5f..ffa32b7 100644 --- a/src/Psc.js +++ b/src/Psc.js @@ -45,7 +45,12 @@ function compile(psModule) { if (errorMessage.length) { psModule.emitError(errorMessage); } - reject(new Error('compilation failed')) + if (options.watch) { + resolve(psModule); + } + else { + reject(new Error('compilation failed')) + } } else { const warningMessage = stderr.join(''); if (options.warnings && warningMessage.length) { diff --git a/src/index.js b/src/index.js index 3f5e6a8..f4a6dff 100644 --- a/src/index.js +++ b/src/index.js @@ -46,6 +46,7 @@ module.exports = function purescriptLoader(source, map) { bundleNamespace: 'PS', bundle: false, warnings: true, + watch: false, output: 'output', src: [ path.join('src', '**', '*.purs'), -- cgit v1.2.3