aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorCyril Sobierajewicz <cyril.sobierajewicz@fretlink.com>2019-03-18 12:02:35 +0100
committerCyril Sobierajewicz <cyril.sobierajewicz@fretlink.com>2019-03-18 13:46:27 +0100
commitc69d78d9010e224f1a31b1acfa24db346d535cb6 (patch)
treefc60163dfb0be013ccfcda40a0cac51a60c2f7aa
parent8a5fcc4d12c8526871d82cb5ea5760a32d1ae813 (diff)
downloadpurs-loader-c69d78d9010e224f1a31b1acfa24db346d535cb6.tar.gz
purs-loader-c69d78d9010e224f1a31b1acfa24db346d535cb6.tar.zst
purs-loader-c69d78d9010e224f1a31b1acfa24db346d535cb6.zip
Watch foreign modules on compilation error
-rw-r--r--src/index.js13
-rw-r--r--src/utils.js4
2 files changed, 17 insertions, 0 deletions
diff --git a/src/index.js b/src/index.js
index 28246e3..be809c6 100644
--- a/src/index.js
+++ b/src/index.js
@@ -202,6 +202,19 @@ module.exports = function purescriptLoader(source, map) {
202 const baseModulePath = path.join(this.rootContext, filename); 202 const baseModulePath = path.join(this.rootContext, filename);
203 this.addDependency(baseModulePath); 203 this.addDependency(baseModulePath);
204 204
205 const foreignModulesErrorCodes = [
206 'ErrorParsingFFIModule',
207 'MissingFFIImplementations',
208 'UnusedFFIImplementations',
209 'MissingFFIModule'
210 ];
211 for (const code of foreignModulesErrorCodes) {
212 if (error.includes(code)) {
213 const resolved = utils.resolveForeignModule(baseModulePath);
214 this.addDependency(resolved);
215 }
216 }
217
205 const matchErrModuleName = /in module ((?:\w+\.)*\w+)/; 218 const matchErrModuleName = /in module ((?:\w+\.)*\w+)/;
206 const [, baseModuleName] = matchErrModuleName.exec(error) || []; 219 const [, baseModuleName] = matchErrModuleName.exec(error) || [];
207 if (!baseModuleName) continue; 220 if (!baseModuleName) continue;
diff --git a/src/utils.js b/src/utils.js
index b6ccf81..829ba72 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -33,3 +33,7 @@ exports.resolvePursModule = ({ baseModulePath, baseModuleName, targetModuleName
33 `${path.join(...parts)}.purs`) 33 `${path.join(...parts)}.purs`)
34 : baseModulePath; 34 : baseModulePath;
35}; 35};
36
37exports.resolveForeignModule = pursModulePath =>
38 path.join(path.dirname(pursModulePath),
39 path.basename(pursModulePath, path.extname(pursModulePath)) + '.js');