Our project relies heavily on custom 'heavy' loaders, and fast compilation is crucial. In watch mode, every loader that utilizes addContextDependency reruns one more time after any project change, leading to longer build times. Trying to find a solution to minimize the re-running of these loaders and improve watch mode performance.
Bug report
After initial compilation in watch mode every loader that uses addContextDependency will rerun one more time after any change in the project.
What is the current behavior?
Custom loaders that use addContextDependency will rerun only if supplied context dependencies are changed.
If the current behavior is a bug, please provide the steps to reproduce.
Reproducible example here:
https://github.com/modjke/webpack-5-add-context-dependency-issue
txt-loader.js will run twice: at startup and for the first time index.js is changed
What is the expected behavior?
Loaders with addContextDependency should run only once on initial compilation in watch mode.
What have we tried?
- debugging
watchpack, as it turns out watchpack reports changes correctly
- using async/sync loaders (same bug appears)
- increasing
aggregateTimeout
- disabling hot module reload
Other relevant information:
webpack version: 5.76.3
Node.js version: 18.15.0
Operating System: Mac OS (M1), Windows 11 H22, Windows 10
Additional tools: ~
Our project relies heavily on custom 'heavy' loaders, and fast compilation is crucial. In watch mode, every loader that utilizes
addContextDependencyreruns one more time after any project change, leading to longer build times. Trying to find a solution to minimize the re-running of these loaders and improve watch mode performance.Bug report
After initial compilation in watch mode every loader that uses
addContextDependencywill rerun one more time after any change in the project.What is the current behavior?
Custom loaders that use
addContextDependencywill rerun only if supplied context dependencies are changed.If the current behavior is a bug, please provide the steps to reproduce.
Reproducible example here:
https://github.com/modjke/webpack-5-add-context-dependency-issue
txt-loader.jswill run twice: at startup and for the first timeindex.jsis changedWhat is the expected behavior?
Loaders with
addContextDependencyshould run only once on initial compilation in watch mode.What have we tried?
watchpack, as it turns outwatchpackreports changes correctlyaggregateTimeoutOther relevant information:
webpack version: 5.76.3
Node.js version: 18.15.0
Operating System: Mac OS (M1), Windows 11 H22, Windows 10
Additional tools: ~