Skip to content

Exported WebpackPluginInstance type regression #20439

@faergeek

Description

@faergeek

Bug Description

#20402 changed types.d.ts to have type WebpackPluginInstance = (compiler: Compiler) => void and exporting it instead of a previous declare interface WebpackPluginInstance, while still leaving it there. That old WebpackPluginInstance looks more like a correct one and it's still being referred to internally, that's why type-checking doesn't fail in webpack itself I'd assume.

The new exported WebpackPluginInstance is now incompatible with VirtualUrlPlugin, for example. I assume there maybe more things that are incompatible like that as a result, but I guess because of two types it's probably not immediately visible in the webpack codebase.

Link to Minimal Reproduction and step to reproduce

Steps:

To just see the error:

  1. Take a look at https://github.com/faergeek/fs-routes/actions/runs/21891510698/job/63198138620?pr=176

OR to see it on a local machine:

  1. Clone https://github.com/faergeek/fs-routes
  2. Checkout renovate/webpack-5.x-lockfile branch.
  3. Run pnpm i (npm i should also work I guess as lockfile shouldn't change anything relevant to this issue).
  4. Run pnpm run build (or npm run build) to run tsc.
  5. Observe the error like "Type 'VirtualUrlPlugin' is not assignable to type 'WebpackPluginInstance'."

Expected Behavior

WebpackPluginInstance is compatible with VirtualUrlPlugin

Actual Behavior

WebpackPluginInstance is not compatible with VirtualUrlPlugin

Environment

System:
  OS: Linux 6.18 Arch Linux
  CPU: (16) x64 AMD Ryzen 7 7700X 8-Core Processor
  Memory: 22.29 GB / 30.43 GB
Binaries:
  Node: 24.13.0 - /home/faergeek/.asdf/installs/nodejs/24.13.0/bin/node
  npm: 11.6.2 - /home/faergeek/.asdf/plugins/nodejs/shims/npm
  pnpm: 10.29.2 - /home/faergeek/.local/share/pnpm/.tools/@pnpm+linux-x64/10.29.2/bin/pnpm
Packages:
  webpack: ^5.101.3 => 5.105.1
  webpack-cli: ^6.0.1 => 6.0.1

Is this a regression?

Yes (please specify version below)

Last Working Version

5.105.0

Additional Context

WebpackPluginInstance in theory could be represented as just a function, since functions have .apply method on them. But then it would look more like this (this: Compiler) => void than like this (compiler: Compiler) => void. This simple change didn't just work for me though. I guess everything else that should be compatible with that type would then need to be an interface and not a class, not 100% sure.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions