aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorCyril Sobierajewicz <cyril.sobierajewicz@fretlink.com>2018-12-03 11:50:55 +0100
committerCyril Sobierajewicz <cyril.sobierajewicz@fretlink.com>2018-12-03 11:57:30 +0100
commit7d28a10594c370194b8c23dfa95e533b2b6067b2 (patch)
tree1fbf2b0f4ea3761d06e5abe7b460e2150081deed
parentd8567b87b91abac0a428874cf5fdebb1b0d90ef0 (diff)
downloadpurs-loader-7d28a10594c370194b8c23dfa95e533b2b6067b2.tar.gz
purs-loader-7d28a10594c370194b8c23dfa95e533b2b6067b2.tar.zst
purs-loader-7d28a10594c370194b8c23dfa95e533b2b6067b2.zip
Annotate errors to prevent redundant parsing by other loaders
-rw-r--r--src/index.js11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/index.js b/src/index.js
index ec9af5f..0b4ecf8 100644
--- a/src/index.js
+++ b/src/index.js
@@ -190,6 +190,8 @@ module.exports = function purescriptLoader(source, map) {
190 }, 190 },
191 emitError: pscMessage => { 191 emitError: pscMessage => {
192 if (pscMessage.length) { 192 if (pscMessage.length) {
193 const modules = [];
194
193 const matchErrorsSeparator = /\n(?=Error)/; 195 const matchErrorsSeparator = /\n(?=Error)/;
194 const errors = pscMessage.split(matchErrorsSeparator); 196 const errors = pscMessage.split(matchErrorsSeparator);
195 for (const error of errors) { 197 for (const error of errors) {
@@ -218,6 +220,11 @@ module.exports = function purescriptLoader(source, map) {
218 } 220 }
219 } 221 }
220 222
223 const desc = {
224 name: baseModuleName,
225 filename: baseModulePath
226 };
227
221 if (typeof this.extractPursDependenciesFromError === 'function') { 228 if (typeof this.extractPursDependenciesFromError === 'function') {
222 const dependencies = this.extractPursDependenciesFromError(error) || []; 229 const dependencies = this.extractPursDependenciesFromError(error) || [];
223 230
@@ -225,9 +232,11 @@ module.exports = function purescriptLoader(source, map) {
225 this.addDependency(dep); 232 this.addDependency(dep);
226 } 233 }
227 } 234 }
235
236 modules.push(desc);
228 } 237 }
229 238
230 CACHE_VAR.errors.push(pscMessage); 239 CACHE_VAR.errors.push(Object.assign(new Error(pscMessage), { modules }));
231 } 240 }
232 } 241 }
233 } 242 }