]> git.immae.eu Git - github/fretlink/purs-loader.git/commitdiff
Add a watch option
authoreric thul <thul.eric@gmail.com>
Sun, 19 Feb 2017 16:29:57 +0000 (11:29 -0500)
committereric thul <thul.eric@gmail.com>
Sun, 19 Feb 2017 17:10:43 +0000 (12:10 -0500)
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
src/Psc.js
src/index.js

index 3b313540f2c3bb05512dd7350d01dd2e469bae5a..931e4e6f7f8d27a4995c78ebd09f81121639fc06 100644 (file)
--- 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'),
index 4991d5fd8c90a7cd4d6390a767f83e7322c6a362..ffa32b714a69c43bcf8954c8b8f9bb2e35d71c78 100644 (file)
@@ -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) {
index 3f5e6a823d6a0b77bd9a19834019fdf7196d97ef..f4a6dff29ba15171fb08eae6219739518f98fda4 100644 (file)
@@ -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'),