Single runtime chunk incompatible with library output in Webpack 5
See original GitHub issueBug report
What is the current behavior?
Using the following config works in Webpack 4 but not Webpack 5:
module.exports = {
output: {
library: "A",
},
optimization: {
runtimeChunk: "single"
},
};
I would expect the module to be assigned to a variable A
, but in Webpack 5 A
is undefined.
Webpack 4 output:
var A =
(window["webpackJsonpA"] = window["webpackJsonpA"] || []).push([["main"],{
...
},[["./src/index.js","runtime"]]]);
Webpack 5 output:
var A;
(self["webpackChunkA"] = self["webpackChunkA"] || []).push([["main"],{
...
},
0,[["./src/index.js","runtime"]]]);
If the current behavior is a bug, please provide the steps to reproduce.
Smallest reproducible bug demo: https://github.com/keeganstreet/webpack-5-library
What is the expected behavior?
The module should be assigned to A
.
Other relevant information: webpack version: 5.24.2 Node.js version: v14.4.0 Operating System: Mac OS Additional tools: N/A
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Output - webpack
The format of chunks (formats included by default are 'array-push' (web/WebWorker), 'commonjs' (node.js), 'module' (ESM), but others might be added by plugins).
Read more >[Webpack 5] (minimal repro included!) __webpack_modules ...
__webpack_require__ goes bang attempting to import a library local to our project (i.e. a sibling package in the same lerna monorepo). We did ......
Read more >After build via Webpack 5 app stoped working on Internet ...
From the webpack guide To v5 from v4, it says: By default, webpack's runtime code uses ES2015 syntax to build smaller bundles.
Read more >How I solved and debugged my Webpack issue through trial ...
js ) and one of the source files contains an error, the stack trace will simply point to bundle.js . This isn't always...
Read more >API - ESBuild
When bundling is enabled the default output format is set to cjs , which stands for CommonJS (the module format used by node)....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It is the same problem, duplicate, yes steps are different but the problem is the same
OK thanks