jantimon / jantimon/html-webpack-plugin

Config dependency manager doesn't take into account all the hooks until "initialize".

Open
#1,768 4 comments 0 reactions 0 assignees View on GitHub
wontfix
Dominant language
JavaScript
Stars
10.7k
Forks
1.3k
Avg merge
1m
Merged PRs (30d)
1

Description

# Bug report

**What is the current behavior?**
I use [configuration dependencies](https://webpack.js.org/configuration/configuration-types/#dependencies) to make sure that the plugins from the second config `'server'` will always be executed after the first config `'client'` output is emitted:

```javascript
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](https://webpack.js.org/api/compiler-hooks/#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

---

This issue was moved from webpack/webpack#16312 by @alexander-akait. Original issue was by @reves.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the configuration dependency example with the afterResolvers, initialize, beforeRun, and afterEmit hooks described in the issue. Trace the dependency manager's ordering around those hooks; done means the dependent server configuration runs after the client configuration for early and later hooks, matching the expected output.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, webpack
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.