You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
763 B
30 lines
763 B
'use strict';
|
|
|
|
const TYPE = 'module-not-found';
|
|
|
|
function isModuleNotFoundError (e) {
|
|
const webpackError = e.webpackError || {};
|
|
return webpackError.dependencies
|
|
&& webpackError.dependencies.length > 0
|
|
&& e.name === 'ModuleNotFoundError'
|
|
&& e.message.indexOf('Module not found') === 0;
|
|
}
|
|
|
|
function transform(error) {
|
|
const webpackError = error.webpackError;
|
|
if (isModuleNotFoundError(error)) {
|
|
const dependency = webpackError.dependencies[0];
|
|
const module = dependency.request || dependency.options.request;
|
|
return Object.assign({}, error, {
|
|
message: `Module not found ${module}`,
|
|
type: TYPE,
|
|
severity: 900,
|
|
module,
|
|
name: 'Module not found'
|
|
});
|
|
}
|
|
|
|
return error;
|
|
}
|
|
|
|
module.exports = transform;
|
|
|