Skip to content

Issue with webpack in monorepo - TypeError: The 'compilation' argument must be an instance of Compilation #9427

Description

@manvydas-tbol

Verify latest release

  • I verified that the issue exists in the latest pnpm release

pnpm version

10.8.0

Which area(s) of pnpm are affected? (leave empty if unsure)

Dependencies resolver

Link to the code that reproduces this issue or a replay of the bug

No response

Reproduction steps

Hello,

I'm running a monorepo, where webpack is used in multiple projects. Version of webapck is the same across all projects. After ugprading from pnpm 8 to 10 (same issue exists with pnpm 9) I started getting an error when building a project with webpack

[webpack-cli] TypeError: The 'compilation' argument must be an instance of Compilation
at ModuleFederationPlugin.getCompilationHooks (/job/node_modules/.pnpm/webpack@5.97.1_@swc+core@1.7.0_webpack-cli@5.1.4/node_modules/webpack/lib/container/ModuleFederationPlugin.js:58:10)
at /job/node_modules/.pnpm/webpack@5.97.1_@swc+core@1.7.0_webpack-cli@5.1.4/node_modules/webpack/lib/container/HoistContainerReferencesPlugin.js:36:33
at Hook.eval [as call] (eval at create (/job/node_modules/.pnpm/tapable@2.2.1/node_modules/tapable/lib/HookCodeFactory.js:19:10), <anonymous>:33:1)
  at Hook.CALL_DELEGATE [as _call] (/job/node_modules/.pnpm/tapable@2.2.1/node_modules/tapable/lib/Hook.js:14:14)
  at Compiler.newCompilation (/job/node_modules/.pnpm/webpack@5.97.1_@swc+core@1.7.0_@swc+helpers@0.5.12__webpack-cli@5.1.4/node_modules/webpack/lib/Compiler.js:1275:30)
  at /job/node_modules/.pnpm/webpack@5.97.1_@swc+core@1.7.0_@swc+helpers@0.5.12__webpack-cli@5.1.4/node_modules/webpack/lib/Compiler.js:1320:29
  at Hook.eval [as callAsync] (eval at create (/job/node_modules/.pnpm/tapable@2.2.1/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
    at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/job/node_modules/.pnpm/tapable@2.2.1/node_modules/tapable/lib/Hook.js:18:14)
    at Compiler.compile (/job/node_modules/.pnpm/webpack@5.97.1_@swc+core@1.7.0_@swc+helpers@0.5.12__webpack-cli@5.1.4/node_modules/webpack/lib/Compiler.js:1315:28)
    at /job/node_modules/.pnpm/webpack@5.97.1_@swc+core@1.7.0_@swc+helpers@0.5.12__webpack-cli@5.1.4/node_modules/webpack/lib/Compiler.js:597:12

As mentioned here, this error appears when there are multiple versions of webpack installed - jantimon/html-webpack-plugin#1451 (comment).

Seems like this is not the first time this issue appears, as this was mentioned here previously - #6154 (comment)

Any ideas what could be wrong here? No code changes, except updating pnpm from 8 to 10.

Expected Behavior

It should work just like it did in V8

Which Node.js version are you using?

TLS, 22.14.0

Which operating systems have you used?

  • macOS
  • Windows
  • Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Fields

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions