webpack-cli icon indicating copy to clipboard operation
webpack-cli copied to clipboard

feat: watch mode config change

Open evenstensberg opened this issue 4 years ago • 12 comments

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 avatar Jun 24 '21 19:06 evenstensberg

@evenstensberg Thanks for your update.

I labeled the Pull Request so reviewers will review it again.

@alexander-akait Please review the new changes.

webpack-bot avatar Jun 25 '21 15:06 webpack-bot

PTAL

evenstensberg avatar Jun 25 '21 15:06 evenstensberg

@alexander-akait you have the source, maybe you can have a look at it?

evenstensberg avatar Jun 26 '21 15:06 evenstensberg

Some points:

  1. We only have to worry about the compiler re-rednering after a config change is noticed
  2. 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 avatar Jun 29 '21 20:06 evenstensberg

@evenstensberg Because only webpack knows about dependencies

alexander-akait avatar Jun 30 '21 12:06 alexander-akait

We just want config changes, not dependency changes. Watchmode + watch a config file

evenstensberg avatar Jun 30 '21 14:06 evenstensberg

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

alexander-akait avatar Jun 30 '21 14:06 alexander-akait

The watch API will sniff those changes if the text inside the config changes. this is what we want

evenstensberg avatar Jul 01 '21 17:07 evenstensberg

We should watch dependencies too like package.json/import/require and etc

alexander-akait avatar Jul 01 '21 17:07 alexander-akait

No need, if we refer to the original issue

evenstensberg avatar Jul 02 '21 19:07 evenstensberg

It is require to right implementation

alexander-akait avatar Jul 02 '21 19:07 alexander-akait

PTAL. Uses https://github.com/evenstensberg/watch-traverse

evenstensberg avatar Jul 10 '21 19:07 evenstensberg

I wanted to close it, because it is invalid, we need to improve it on webpack side, we need:

  • move buildDependecies from options.cache.buildDependencies to top options (it will be useful for any configuration, not only for webpack itself)
  • implement watchRun hook and get files from compilation.modifiedFiles, if we have confiugration file there restart our CLI

alexander-akait avatar May 03 '23 19:05 alexander-akait