feat: watch mode config change
What kind of change does this PR introduce? Fixes https://github.com/webpack/webpack-cli/issues/15
Did you add tests for your changes? No If relevant, did you update the documentation? N/A Summary Need to check if CLIplugin is added to the config, otherwise there will be a memory leak
Does this PR introduce a breaking change?
No Other information N/A
@evenstensberg Thanks for your update.
I labeled the Pull Request so reviewers will review it again.
@alexander-akait Please review the new changes.
PTAL
@alexander-akait you have the source, maybe you can have a look at it?
Some points:
- We only have to worry about the compiler re-rednering after a config change is noticed
- We only have access to the configuration at this level
Due this, I think this is the right level of abstraction. Since the CLI is the one that reads a config, I think this is where we naturally add this feature. I don't understand why webpack itself should re-validate a config, core should only be worried about doing a compilation.
WDYT?
@evenstensberg Because only webpack knows about dependencies
We just want config changes, not dependency changes. Watchmode + watch a config file
In this case we don't look at import/require inside webpack.config.js/package.json and etc, so reload will not work for many cases
The watch API will sniff those changes if the text inside the config changes. this is what we want
We should watch dependencies too like package.json/import/require and etc
No need, if we refer to the original issue
It is require to right implementation
PTAL. Uses https://github.com/evenstensberg/watch-traverse
I wanted to close it, because it is invalid, we need to improve it on webpack side, we need:
- move
buildDependeciesfromoptions.cache.buildDependenciesto top options (it will be useful for any configuration, not only for webpack itself) - implement
watchRunhook and get files fromcompilation.modifiedFiles, if we have confiugration file there restart our CLI