From: eric thul Date: Sun, 19 Feb 2017 16:29:57 +0000 (-0500) Subject: Add a watch option X-Git-Tag: 2.4.0-beta.0~2 X-Git-Url: https://git.immae.eu/?a=commitdiff_plain;ds=sidebyside;h=df8798fa0eeeb3dfcce14dc10100b03f708b57f6;p=github%2Ffretlink%2Fpurs-loader.git 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 --- 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'),