-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Description
A pull request by @mc-zone was merged and maintainers requested a documentation change.
See pull request: webpack/webpack#6542
What kind of change does this PR introduce?
Feature.
Did you add tests for your changes?
Yes.
If relevant, link to documentation update:
N/A
Summary
Add loader name to Error message so that people can actually realize which loaders were emiting these errors clearly.
Demo:
webpack.config.js:
module.exports = {
entry:"./index.js",
output:{
path:path.resolve(__dirname, "./dist"),
filename:"[name].bundle.js",
},
mode:"development",
module: {
rules: [
{
test: /\.test$/,
use: [
"babel-loader",
{
loader:path.resolve(__dirname, './test-loader.js'),
}
]
},
]
},
};
test-loader.js:
module.exports = function(source){
this.emitWarning(new Error("This is a emit Warning"));
this.emitError(new Error("This is a emit Error"));
return source;
};
lib.test:
);a
console.log("I'm test");
Current output:
After this PR:
Resolves #2878.
Does this PR introduce a breaking change?
Nope (I think).
Other information
Note: This feature also need some changes in webpack/loader-runner
to handle errors from throw
and callback(error)
(need add loader name to error.from
). I will add it subsequently.
Updated: Now using loaderContext.loaderIndex
in NormalModule.js
for all to determine which loader the error is belong to .