aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorCyril Sobierajewicz <cyril.sobierajewicz@fretlink.com>2019-03-18 14:08:02 +0100
committerCyril Sobierajewicz <cyril.sobierajewicz@fretlink.com>2019-03-18 14:08:02 +0100
commite28cbb4ec85b3292814d91e357a3b39115d12232 (patch)
tree50cd03b1f786a3e671e8f75ec8f3f54d54c153ef
parent1a321910d7afebddc65ea512f06b0b667b041ae0 (diff)
downloadpurs-loader-e28cbb4ec85b3292814d91e357a3b39115d12232.tar.gz
purs-loader-e28cbb4ec85b3292814d91e357a3b39115d12232.tar.zst
purs-loader-e28cbb4ec85b3292814d91e357a3b39115d12232.zip
Build v4.1.0
-rw-r--r--lib/index.js55
-rw-r--r--lib/utils.js4
2 files changed, 46 insertions, 13 deletions
diff --git a/lib/index.js b/lib/index.js
index 3f37e3c..c6e88f8 100644
--- a/lib/index.js
+++ b/lib/index.js
@@ -216,6 +216,35 @@ module.exports = function purescriptLoader(source, map) {
216 var baseModulePath = path.join(_this.rootContext, filename); 216 var baseModulePath = path.join(_this.rootContext, filename);
217 _this.addDependency(baseModulePath); 217 _this.addDependency(baseModulePath);
218 218
219 var foreignModulesErrorCodes = ['ErrorParsingFFIModule', 'MissingFFIImplementations', 'UnusedFFIImplementations', 'MissingFFIModule'];
220 var _iteratorNormalCompletion2 = true;
221 var _didIteratorError2 = false;
222 var _iteratorError2 = undefined;
223
224 try {
225 for (var _iterator2 = foreignModulesErrorCodes[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
226 var code = _step2.value;
227
228 if (error.includes(code)) {
229 var resolved = utils.resolveForeignModule(baseModulePath);
230 _this.addDependency(resolved);
231 }
232 }
233 } catch (err) {
234 _didIteratorError2 = true;
235 _iteratorError2 = err;
236 } finally {
237 try {
238 if (!_iteratorNormalCompletion2 && _iterator2.return) {
239 _iterator2.return();
240 }
241 } finally {
242 if (_didIteratorError2) {
243 throw _iteratorError2;
244 }
245 }
246 }
247
219 var matchErrModuleName = /in module ((?:\w+\.)*\w+)/; 248 var matchErrModuleName = /in module ((?:\w+\.)*\w+)/;
220 249
221 var _ref4 = matchErrModuleName.exec(error) || [], 250 var _ref4 = matchErrModuleName.exec(error) || [],
@@ -234,12 +263,12 @@ module.exports = function purescriptLoader(source, map) {
234 targetModuleName = _ref7[1]; 263 targetModuleName = _ref7[1];
235 264
236 if (targetModuleName) { 265 if (targetModuleName) {
237 var resolved = utils.resolvePursModule({ 266 var _resolved = utils.resolvePursModule({
238 baseModulePath: baseModulePath, 267 baseModulePath: baseModulePath,
239 baseModuleName: baseModuleName, 268 baseModuleName: baseModuleName,
240 targetModuleName: targetModuleName 269 targetModuleName: targetModuleName
241 }); 270 });
242 _this.addDependency(resolved); 271 _this.addDependency(_resolved);
243 } 272 }
244 } 273 }
245 274
@@ -254,28 +283,28 @@ module.exports = function purescriptLoader(source, map) {
254 dependencies = _describePscError$dep === undefined ? [] : _describePscError$dep, 283 dependencies = _describePscError$dep === undefined ? [] : _describePscError$dep,
255 details = _describePscError.details; 284 details = _describePscError.details;
256 285
257 var _iteratorNormalCompletion2 = true; 286 var _iteratorNormalCompletion3 = true;
258 var _didIteratorError2 = false; 287 var _didIteratorError3 = false;
259 var _iteratorError2 = undefined; 288 var _iteratorError3 = undefined;
260 289
261 try { 290 try {
262 291
263 for (var _iterator2 = dependencies[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) { 292 for (var _iterator3 = dependencies[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
264 var dep = _step2.value; 293 var dep = _step3.value;
265 294
266 _this.addDependency(dep); 295 _this.addDependency(dep);
267 } 296 }
268 } catch (err) { 297 } catch (err) {
269 _didIteratorError2 = true; 298 _didIteratorError3 = true;
270 _iteratorError2 = err; 299 _iteratorError3 = err;
271 } finally { 300 } finally {
272 try { 301 try {
273 if (!_iteratorNormalCompletion2 && _iterator2.return) { 302 if (!_iteratorNormalCompletion3 && _iterator3.return) {
274 _iterator2.return(); 303 _iterator3.return();
275 } 304 }
276 } finally { 305 } finally {
277 if (_didIteratorError2) { 306 if (_didIteratorError3) {
278 throw _iteratorError2; 307 throw _iteratorError3;
279 } 308 }
280 } 309 }
281 } 310 }
diff --git a/lib/utils.js b/lib/utils.js
index 3b9ba19..3c73fc6 100644
--- a/lib/utils.js
+++ b/lib/utils.js
@@ -61,4 +61,8 @@ exports.resolvePursModule = function (_ref) {
61 61
62 var parts = diffPursModuleNames(baseModuleName.split('.'), targetModuleName.split('.'), []); 62 var parts = diffPursModuleNames(baseModuleName.split('.'), targetModuleName.split('.'), []);
63 return parts.length ? path.resolve(baseModulePath, path.join.apply(path, _toConsumableArray(parts)) + '.purs') : baseModulePath; 63 return parts.length ? path.resolve(baseModulePath, path.join.apply(path, _toConsumableArray(parts)) + '.purs') : baseModulePath;
64};
65
66exports.resolveForeignModule = function (pursModulePath) {
67 return path.join(path.dirname(pursModulePath), path.basename(pursModulePath, path.extname(pursModulePath)) + '.js');
64}; \ No newline at end of file 68}; \ No newline at end of file