-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Description
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:
- 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:
- Clone https://github.com/faergeek/fs-routes
- Checkout
renovate/webpack-5.x-lockfilebranch. - Run
pnpm i(npm ishould also work I guess as lockfile shouldn't change anything relevant to this issue). - Run
pnpm run build(ornpm run build) to runtsc. - 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.1Is 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.