Skip to content

Commit df8798f

Browse files
committed
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
1 parent 8e21ab0 commit df8798f

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ const loaderConfig = {
6161
bundleNamespace: 'PS',
6262
bundle: false,
6363
warnings: true,
64+
watch: false, // indicates if webapck is in watch mode
6465
output: 'output',
6566
src: [
6667
path.join('src', '**', '*.purs'),

src/Psc.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,12 @@ function compile(psModule) {
4545
if (errorMessage.length) {
4646
psModule.emitError(errorMessage);
4747
}
48-
reject(new Error('compilation failed'))
48+
if (options.watch) {
49+
resolve(psModule);
50+
}
51+
else {
52+
reject(new Error('compilation failed'))
53+
}
4954
} else {
5055
const warningMessage = stderr.join('');
5156
if (options.warnings && warningMessage.length) {

src/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ module.exports = function purescriptLoader(source, map) {
4646
bundleNamespace: 'PS',
4747
bundle: false,
4848
warnings: true,
49+
watch: false,
4950
output: 'output',
5051
src: [
5152
path.join('src', '**', '*.purs'),

0 commit comments

Comments
 (0)