From fe53d5d11ca45078b3776cebf00905c9de05450a Mon Sep 17 00:00:00 2001 From: MO Date: Thu, 28 Nov 2019 17:51:07 +0800 Subject: [PATCH] fix: extract from message if module is undefined closes #101 --- src/transformers/moduleNotFound.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/transformers/moduleNotFound.js b/src/transformers/moduleNotFound.js index 2e5e0c4..be0e6eb 100644 --- a/src/transformers/moduleNotFound.js +++ b/src/transformers/moduleNotFound.js @@ -19,7 +19,7 @@ function transform(error) { message: `Module not found ${module}`, type: TYPE, severity: 900, - module, + module: module || extractModuleName(webpackError.message || ''), name: 'Module not found' }); } @@ -27,4 +27,14 @@ function transform(error) { return error; } +const re = /Can't resolve '([^']*)'/ + +function extractModuleName(message) { + const matches = message.match(re) + + if (matches && matches[1]) { + return matches[1] + } +} + module.exports = transform;