Automatically add the HMR plugin when hot or hotOnly is enabled #1612
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.
For Bugs and Features; did you add new tests?
Yep, tests added.
Motivation / Use-Case
When setting the
hot
orhotOnly
option, the entries are added automatically, but the HMR plugin needs to be added into config by the user.This PR extends the existing
addEntries
module to also amend the plugins config. This does make the name a bit of a misnomer, but for now i've just done the minimal changes.Breaking Changes
This is arguably a breaking change, as it's modifying config that it wasn't before. But if you were passing
hot
orhotOnly
and missing the plugin, you were doing something wrong - and I've put in some logic to prevent duplicates of the HMR plugin.I think it could be argued that this is safe to put into a point release.
Additional Info
This overlaps somewhat with functionality implemented in
webpack-cli/bin/convert-argv
, that adds the webpack HMR plugin if you specifiy--hot
, but not if you specify--hot-only
.