Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix too large runtime chunks when using dependOn #13334

Merged
merged 1 commit into from May 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 8 additions & 2 deletions lib/Chunk.js
Expand Up @@ -568,9 +568,15 @@ class Chunk {
Array.from(this.groupsIterable, g => new Set(g.chunks))
);

for (const chunkGroup of this.groupsIterable) {
const initialQueue = new Set(this.groupsIterable);

for (const chunkGroup of initialQueue) {
for (const child of chunkGroup.childrenIterable) {
queue.add(child);
if (child instanceof Entrypoint) {
initialQueue.add(child);
} else {
queue.add(child);
}
}
}

Expand Down
1 change: 1 addition & 0 deletions test/configCases/runtime/entries-in-runtime/async.js
@@ -0,0 +1 @@
console.log("split");
11 changes: 11 additions & 0 deletions test/configCases/runtime/entries-in-runtime/index.js
@@ -0,0 +1,11 @@
import path from "path";
import fs from "fs";

it("should not have references to chunks of unrelated entrypoints in runtime", () => {
const content = fs.readFileSync(
path.resolve(__dirname, "runtime.js"),
"utf-8"
);
expect(content).not.toContain("other-entry");
expect(content).not.toContain("split");
});
Empty file.
2 changes: 2 additions & 0 deletions test/configCases/runtime/entries-in-runtime/other-entry.js
@@ -0,0 +1,2 @@
import "./split";
import("./async");
1 change: 1 addition & 0 deletions test/configCases/runtime/entries-in-runtime/split.js
@@ -0,0 +1 @@
console.log("split");
5 changes: 5 additions & 0 deletions test/configCases/runtime/entries-in-runtime/test.config.js
@@ -0,0 +1,5 @@
module.exports = {
findBundle: function () {
return ["./runtime.js", "./main.js", "./first-entry.js"];
}
};
39 changes: 39 additions & 0 deletions test/configCases/runtime/entries-in-runtime/webpack.config.js
@@ -0,0 +1,39 @@
/** @type {import("../../../../").Configuration} */
module.exports = {
mode: "production",
entry: {
main: "./main",
"first-entry": {
dependOn: "main",
import: "./index"
},
"other-entry": {
dependOn: "main",
import: "./other-entry"
}
},
target: "web",
node: {
__dirname: false,
__filename: false
},
externalsPresets: {
node: true
},
output: {
filename: "[name].js"
},
optimization: {
runtimeChunk: "single",
splitChunks: {
cacheGroups: {
split: {
chunks: "all",
name: "split",
test: /split\.js$/,
enforce: true
}
}
}
}
};