webpack stopped concatenating modules in Violentmonkey's sw.js since 5.110.2
Have you used AI?
No
Which part of webpack is affected?
optimization (tree-shaking, splitChunks, concatenation)
Bug Description
webpack stopped concatenating modules since 5.110.2 for the same source and build options.
Link to Minimal Reproduction and steps to reproduce
https://github.com/violentmonkey/violentmonkey/tree/test-webpack - please use test-webpack branch
- pnpm ci && pnpm dev:mv3
~280 files in src, 5...30 seconds to install node_modules, ~10 seconds to build on an old i7 CPU. I'm not good at debugging such issues so hopefully it wouldn't inconvenience you to test the actual repository. The repro is using a fast non-minified dev build so that the difference is easily seen in the output.
Expected Behavior
dist-mv3/sw.js is concatenated: no __webpack_exports__ inside.
Actual Behavior
dist-mv3/sw.js is not concatenated: lots of __webpack_exports__ inside.
Environment
⬡ System:
OS: Windows 10 10.0.19045
CPU: (8) x64 Intel(R) Core(TM) i7-3770K CPU @ 3.50GHz
Memory: 16.01 GB / 31.95 GB
⬡ Binaries:
Node: 26.2.0
npm: 11.15.0
pnpm: 12.4.2
⬡ Packages:
webpack: 5.111.0
Is this a regression?
Yes (please specify version below)
Last Working Version
5.110.1
Additional Context
Using specNamespaceObject: true fixes sw.js but breaks concatenation in the output injected-web.js, so such discrepancy feels like a bug in Webpack.
Adding optimizationBailout doesn't help me as it's unclear why specifically the listed file prevents concatenation.
Source: webpack/webpack