Skip to content

Commit 374376d

Browse files
committed
fixes webpack#7382
1 parent 962cea5 commit 374376d

File tree

5 files changed

+47
-5
lines changed

5 files changed

+47
-5
lines changed

lib/optimize/RuntimeChunkPlugin.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,15 @@ module.exports = class RuntimeChunkPlugin {
1919
compilation.hooks.optimizeChunksAdvanced.tap("RuntimeChunkPlugin", () => {
2020
for (const entrypoint of compilation.entrypoints.values()) {
2121
const chunk = entrypoint.getRuntimeChunk();
22-
if (chunk.getNumberOfModules() > 0) {
23-
let name = this.options.name;
24-
if (typeof name === "function") {
25-
name = name(entrypoint);
26-
}
22+
let name = this.options.name;
23+
if (typeof name === "function") {
24+
name = name(entrypoint);
25+
}
26+
if (
27+
chunk.getNumberOfModules() > 0 ||
28+
!chunk.preventIntegration ||
29+
chunk.name !== name
30+
) {
2731
const newChunk = compilation.addChunk(name);
2832
newChunk.preventIntegration = true;
2933
entrypoint.unshiftChunk(newChunk);

test/__snapshots__/StatsTestCases.test.js.snap

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1973,6 +1973,11 @@ Child manifest is named entry:
19731973
[4] ./f.js 20 bytes {1} [built]"
19741974
`;
19751975

1976+
exports[`StatsTestCases should print correct stats for runtime-chunk-issue-7382 1`] = `
1977+
"Entrypoint e1 = runtime.js all.js e1.js
1978+
Entrypoint e2 = runtime.js all.js e2.js"
1979+
`;
1980+
19761981
exports[`StatsTestCases should print correct stats for runtime-chunk-single 1`] = `
19771982
"Entrypoint e1 = runtime.js e1.js
19781983
Entrypoint e2 = runtime.js e2.js"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = "entry1";
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = "entry2";
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
module.exports = {
2+
mode: "development",
3+
entry: {
4+
e1: "./e1",
5+
e2: "./e2"
6+
},
7+
output: {
8+
filename: "[name].js"
9+
},
10+
stats: {
11+
hash: false,
12+
timings: false,
13+
builtAt: false,
14+
assets: false,
15+
modules: false,
16+
reasons: true
17+
},
18+
optimization: {
19+
runtimeChunk: "single",
20+
splitChunks: {
21+
cacheGroups: {
22+
all: {
23+
test: /./,
24+
name: "all",
25+
minSize: 0,
26+
chunks: "initial"
27+
}
28+
}
29+
}
30+
}
31+
};

0 commit comments

Comments
 (0)