Suppress / filter console warning messages
jgraniero opened this issue · comments
- 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
.
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.
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.