Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
webpack-bot opened this issue Oct 6, 2022 · 3 comments

Comments

@webpack-bot
Copy link

Bug 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


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

@alexander-akait
Copy link
Collaborator

@jantimon you can move html-webpack-plugin to official webpack-contrib org and we start to fixing most of problems instead keeping them, thank you

@alexander-akait
Copy link
Collaborator

@jantimon Friendly ping

@alexander-akait
Copy link
Collaborator

Ref: #1722 (comment) - need add a test case for this use case

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants