Skip to content
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

Suppress / filter console warning messages #319

Open
jgraniero opened this issue Jul 9, 2018 · 2 comments · May be fixed by #321
Open

Suppress / filter console warning messages #319

jgraniero opened this issue Jul 9, 2018 · 2 comments · May be fixed by #321

Comments

@jgraniero
Copy link

  • Operating System: macOS 10.13.1
  • Node Version: 10.5.0
  • NPM Version: 6.1.0
  • webpack Version: 4.15.1
  • ${package} Version: 2.22.2

Feature Proposal

Configure HMR client warning logs.

Feature Use Case

I use Typescript with ts-loader. The ts-loader docs indicate that the transpileOnly option should be set to true for HMR (also recommended to decrease build speed). If you have code that re-exports a type, e.g.

export { SomeType } from './some-module';

the transpileOnly flag will generate export code that webpack sees as invalid and webpack will report these issues as warnings. There was a discussion about this over in the ts-loader repo.

It seems the accepted solution to suppress these warnings is to add a warningsFilter to webpack's stats - which works fine, but the webpack-hot-middleware client still sees and reports these warnings to the browser console. This can make rebuilds really noisy.

Correct me if I'm wrong, but the only option to suppress these warnings right now would be to turn off all HMR client logging - which I don't really want to do because some of it is useful, like seeing what gets rebuilt and reloaded.

Ideally I'd like to be able to filter warning message the same way I'm doing with webpack's stats.warningsFilter, but I could see it being problematic adding something like that to the HMR client's query params. I'd be fine with just suppressing logging warning messages to the browser console, much like you can suppress info messages with noInfo.

@glenjamin
Copy link
Collaborator

Yep, this is an oversight - i can't see any reason not to add a noWarnings option or similar into the client code.

A PR would likely be accepted.

@jgraniero
Copy link
Author

If you want to solve this via a simple noWarnings flag, that seems easy and I can probably take care of it when I get a few minutes.

jgraniero pushed a commit to jgraniero/webpack-hot-middleware that referenced this issue Jul 10, 2018
jgraniero added a commit to jgraniero/webpack-hot-middleware that referenced this issue Jul 10, 2018
jgraniero added a commit to jgraniero/webpack-hot-middleware that referenced this issue Jul 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants