Extracted client logging to its own module. #925
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request opens the path to fixing the HMR logging issue described below.
What kind of change does this PR introduce?
This is basically refactoring.
Did you add or update the
examples/
?Not needed.
Summary
There is a long standing issue with the HMR logging in the browser console, which cannot be turned off. This is because the modules in
webpack/hot
(dev-server.js
,only-dev-server.js
,log-apply-result.js
) useconsole.log()
andconsole.warn()
directly, without any possibility to turn them off. This is especially annoying while trying to debug usingconsole.log()
, and getting your debug messages mixed with unrelated HMR messages. There are a few open issues about this, listed below, with some hackish workarounds.To solve this once and for all, we should have an option to turn off HMR logging based on the desired log level. For this we can use the
clientLogLevel
option added in #579. But because the HMR modules don't have acces towebpack-dev-server/client/index.js
's scope, where theclientLogLevel
is defined, we have two options:clientLogLevel
(or the logging functionlog()
) fromwebpack-dev-server/client/index.js
, and use it inside thewebpack/hot
modules, orwebpack-dev-server/client/log.js
, and require it inside thewebpack/hot
modules, which I've used here.As for the
webpack/hot
modules, instead of just havingconsole.log("[HMR] some message here")
, we will have something like(also see the proof of concept PR here: webpack/webpack#4960)
Related issues list:
Option to console.log only important stuff #109
An option to mute console logging for hot module replacement
webpack/webpack#415
cannot mute webpack/hot/dev-server console.logs webpack/webpack#4115
How to quiet the console.log outputs? gaearon/react-hot-loader#79
Does this PR introduce a breaking change?
There's no breaking change, as far as I can see.