Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fixes #7382
  • Loading branch information
sokra committed May 24, 2018
1 parent 962cea5 commit 374376d
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 5 deletions.
14 changes: 9 additions & 5 deletions lib/optimize/RuntimeChunkPlugin.js
Expand Up @@ -19,11 +19,15 @@ module.exports = class RuntimeChunkPlugin {
compilation.hooks.optimizeChunksAdvanced.tap("RuntimeChunkPlugin", () => {
for (const entrypoint of compilation.entrypoints.values()) {
const chunk = entrypoint.getRuntimeChunk();
if (chunk.getNumberOfModules() > 0) {
let name = this.options.name;
if (typeof name === "function") {
name = name(entrypoint);
}
let name = this.options.name;
if (typeof name === "function") {
name = name(entrypoint);
}
if (
chunk.getNumberOfModules() > 0 ||
!chunk.preventIntegration ||
chunk.name !== name
) {
const newChunk = compilation.addChunk(name);
newChunk.preventIntegration = true;
entrypoint.unshiftChunk(newChunk);
Expand Down
5 changes: 5 additions & 0 deletions test/__snapshots__/StatsTestCases.test.js.snap
Expand Up @@ -1973,6 +1973,11 @@ Child manifest is named entry:
[4] ./f.js 20 bytes {1} [built]"
`;

exports[`StatsTestCases should print correct stats for runtime-chunk-issue-7382 1`] = `
"Entrypoint e1 = runtime.js all.js e1.js
Entrypoint e2 = runtime.js all.js e2.js"
`;

exports[`StatsTestCases should print correct stats for runtime-chunk-single 1`] = `
"Entrypoint e1 = runtime.js e1.js
Entrypoint e2 = runtime.js e2.js"
Expand Down
1 change: 1 addition & 0 deletions test/statsCases/runtime-chunk-issue-7382/e1.js
@@ -0,0 +1 @@
module.exports = "entry1";
1 change: 1 addition & 0 deletions test/statsCases/runtime-chunk-issue-7382/e2.js
@@ -0,0 +1 @@
module.exports = "entry2";
31 changes: 31 additions & 0 deletions test/statsCases/runtime-chunk-issue-7382/webpack.config.js
@@ -0,0 +1,31 @@
module.exports = {
mode: "development",
entry: {
e1: "./e1",
e2: "./e2"
},
output: {
filename: "[name].js"
},
stats: {
hash: false,
timings: false,
builtAt: false,
assets: false,
modules: false,
reasons: true
},
optimization: {
runtimeChunk: "single",
splitChunks: {
cacheGroups: {
all: {
test: /./,
name: "all",
minSize: 0,
chunks: "initial"
}
}
}
}
};

0 comments on commit 374376d

Please sign in to comment.