question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Single runtime chunk incompatible with library output in Webpack 5

See original GitHub issue

Bug 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:closed
  • Created 3 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
alexander-akaitcommented, Mar 2, 2021

It is the same problem, duplicate, yes steps are different but the problem is the same

0reactions
keeganstreetcommented, Mar 2, 2021

OK thanks

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found