]> git.immae.eu Git - github/fretlink/purs-loader.git/blobdiff - src/Psc.js
Use emitError and emitWarning
[github/fretlink/purs-loader.git] / src / Psc.js
index 437eb9176e444406a436f9cfffc1c9c5ffe84a5a..8fe843751442b42b2dae5de7ca4374d996b03661 100644 (file)
@@ -40,10 +40,16 @@ function compile(psModule) {
       debug('finished compiling PureScript.')
       cache.compilationFinished = true
       if (code !== 0) {
-        cache.errors = stderr.join('')
+        const errorMessage = stderr.join('');
+        if (errorMessage.length) {
+          psModule.emitError(errorMessage);
+        }
         reject(new Error('compilation failed'))
       } else {
-        cache.warnings = stderr.join('')
+        const warningMessage = stderr.join('');
+        if (options.warnings && warningMessage.length) {
+          psModule.emitWarning(warningMessage);
+        }
         resolve(psModule)
       }
     })
@@ -83,7 +89,10 @@ function bundle(options, cache) {
     compilation.on('close', code => {
       debug('finished bundling PureScript.')
       if (code !== 0) {
-        cache.errors = (cache.errors || '') + stderr.join('')
+        const errorMessage = stderr.join('');
+        if (errorMessage.length) {
+          psModule.emitError(errorMessage);
+        }
         return reject(new Error('bundling failed'))
       }
       cache.bundle = stderr