Skip to content

Document webpack change: Add loader name to error message. Resolves #2878 #2231

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
webpack-bot opened this issue Jun 6, 2018 · 5 comments · Fixed by #2298
Closed

Document webpack change: Add loader name to error message. Resolves #2878 #2231

webpack-bot opened this issue Jun 6, 2018 · 5 comments · Fixed by #2298

Comments

@webpack-bot
Copy link

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:

image

After this PR:

image

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 .

@EugeneHlushko
Copy link
Member

Hi @sokra i am not sure what we can update from this one, can you point out please?

@EugeneHlushko
Copy link
Member

@ooflorent can you pls check this ?

@montogeek
Copy link
Member

@EugeneHlushko Maybe update examples that show those errors?

@ooflorent
Copy link
Member

ooflorent commented Jun 25, 2018

Yeah, @montogeek is right. This issue has been open because the error messages used in the documentation may require an update.

@mc-zone
Copy link
Member

mc-zone commented Jun 25, 2018

Sorry for my late. Just let me try to update this tomorrow ☺

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants