Config dependency manager doesn't take into account all the hooks until "initialize".
See original GitHub issueBug report
What is the current behavior?
I use configuration dependencies to make sure that the plugins from the second config 'server' will always be executed after the first config 'client' output is emitted:
module.exports = [
{
name: 'client',
plugins: [
{
apply: compiler => compiler.hooks.afterEmit.tap('Plugin1', _ => {
console.log('Config 1: afterEmit')
})
}
]
},
{
name: 'server',
dependencies: ['client'],
plugins: [
{
apply: compiler => compiler.hooks.afterResolvers.tap('Plugin2', _ => {
// I picked the "afterResolvers" hook, because i will apply here the HtmlWebpackPlugin,
// that is required to be applied before the "initialize" step.
console.log('Config 2: afterResolvers')
})
}
]
}
]
Doesn’t work in the right order for the hooks like afterResolvers (or initialize), as seen in the console output:
Config 2: afterResolvers
Config 1: afterEmit
However, this works as expected starting from the beforeRun hook:
Config 1: afterEmit
Config 2: beforeRun
What is the expected behavior?
Config 1: afterEmit
Config 2: afterResolvers
Other relevant information: webpack version: 5.74.0 Node.js version: 16.17.0 Operating System: Windows 10
Issue Analytics
- State:
- Created a year ago
- Comments:6 (5 by maintainers)
Top Results From Across the Web
Packer.nvim - GitHub
A use-package inspired plugin manager for Neovim. Uses native packages, supports Luarocks dependencies, written in Lua, allows for expressive config ...
Read more >How to fix missing dependency warning when using useEffect ...
I have this current setup, React hook useEffect runs continuously forever/infinite loop and the only comment is about useCallback() which I'm not familiar...
Read more >DbContext Lifetime, Configuration, and Initialization - EF Core
The DbContext lifetime; DbContext in dependency injection for ASP. ... Make sure to await all async calls before continuing to use the ...
Read more >Configuration Blocks and Attributes - Terragrunt
The working directory for hooks associated with init-from-module will run in the terragrunt config directory, while the working directory for hooks associated ...
Read more >React useReducer Hook ultimate guide - LogRocket Blog
In the code below, we initialize state with the useReducer Hook: ... React doesn't use the (state = initialState, action) => newState Redux ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@reves I want to close the issue, because we can’t fix it here,
HtmlWebpackPluginshould be rewritten withoutinitializehook and get entrypoint from compilation (not from configuration, so you code will work without workarounds)HtmlWebpackPluginshould not usecompiler.hooks.initializeto get options, that is wrong and invalid, options can be changed in future too, so it should be rewritten to get options in the valid hooks, but here workaround:/cc @jantimon can we rewrite it, to get entries you can use this hook - https://github.com/webpack/webpack/blob/00c57ede11ee10dbb0a42e944b2cd7a038089944/lib/ProgressPlugin.js#L393, other things are just default options and small logic, you don’t need it to do inside hook and it is wrong