Skip to content

Commit 5b0e366

Browse files
authored
fix: skip concatenation when optimization.providedExports is disabled (#22410)
1 parent cb6d1d0 commit 5b0e366

9 files changed

Lines changed: 47 additions & 0 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"webpack": patch
3+
---
4+
5+
Skip concatenating modules when `optimization.providedExports` is disabled.

‎lib/optimize/ModuleConcatenationPlugin.js‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,14 @@ class ModuleConcatenationPlugin {
257257

258258
// Exports must be known (and not dynamic)
259259
const exportsInfo = moduleGraph.getExportsInfo(module);
260+
if (exportsInfo.otherExportsInfo.provided === undefined) {
261+
setBailoutReason(
262+
module,
263+
"Module has no provided exports info (optimization.providedExports is disabled)"
264+
);
265+
continue;
266+
}
267+
260268
const relevantExports = exportsInfo.getRelevantExports(undefined);
261269
const unknownReexports = relevantExports.filter(
262270
(exportInfo) =>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const a = "a";
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const b = "b";
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const c = "c";
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export default "d";
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import value, { a, b, c, ns, local } from "./reexports";
2+
3+
it("should not concatenate modules without provided exports info", () => {
4+
expect(a).toBe("a");
5+
expect(b).toBe("b");
6+
expect(c).toBe("c");
7+
expect(ns.a).toBe("a");
8+
expect(value).toBe("d");
9+
expect(local).toBe("local");
10+
});
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { b } from "./b";
2+
3+
export { a } from "./a";
4+
export { b };
5+
export * from "./c";
6+
export * as ns from "./a";
7+
export { default } from "./d";
8+
export const local = "local";
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
"use strict";
2+
3+
/** @type {import("../../../../").Configuration} */
4+
module.exports = {
5+
mode: "production",
6+
optimization: {
7+
minimize: false,
8+
concatenateModules: true,
9+
usedExports: true,
10+
providedExports: false
11+
}
12+
};

0 commit comments

Comments
 (0)