Skip to content

Commit

Permalink
fix: extract from message if module is undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
fengzilong authored Nov 28, 2019
1 parent 441aa60 commit fe53d5d
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/transformers/moduleNotFound.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,22 @@ function transform(error) {
message: `Module not found ${module}`,
type: TYPE,
severity: 900,
module,
module: module || extractModuleName(webpackError.message || ''),
name: 'Module not found'
});
}

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;

0 comments on commit fe53d5d

Please # to comment.