From c69d78d9010e224f1a31b1acfa24db346d535cb6 Mon Sep 17 00:00:00 2001 From: Cyril Sobierajewicz Date: Mon, 18 Mar 2019 12:02:35 +0100 Subject: Watch foreign modules on compilation error --- src/index.js | 13 +++++++++++++ src/utils.js | 4 ++++ 2 files changed, 17 insertions(+) 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) { const baseModulePath = path.join(this.rootContext, filename); this.addDependency(baseModulePath); + const foreignModulesErrorCodes = [ + 'ErrorParsingFFIModule', + 'MissingFFIImplementations', + 'UnusedFFIImplementations', + 'MissingFFIModule' + ]; + for (const code of foreignModulesErrorCodes) { + if (error.includes(code)) { + const resolved = utils.resolveForeignModule(baseModulePath); + this.addDependency(resolved); + } + } + const matchErrModuleName = /in module ((?:\w+\.)*\w+)/; const [, baseModuleName] = matchErrModuleName.exec(error) || []; 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 `${path.join(...parts)}.purs`) : baseModulePath; }; + +exports.resolveForeignModule = pursModulePath => + path.join(path.dirname(pursModulePath), + path.basename(pursModulePath, path.extname(pursModulePath)) + '.js'); -- cgit v1.2.3 From 5f7ec4c3db5bd3c6388ca346ab2ebde794c1b07d Mon Sep 17 00:00:00 2001 From: Cyril Sobierajewicz Date: Mon, 18 Mar 2019 12:03:36 +0100 Subject: Version 4.1.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e9b5035..1faef7b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "purs-loader", - "version": "4.0.0", + "version": "4.1.0", "description": "A webpack loader for PureScript.", "main": "lib/index.js", "files": [ -- cgit v1.2.3