Skip to content

Single runtime chunk incompatible with library output in Webpack 5 #12801

@keeganstreet

Description

@keeganstreet

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

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