Skip to content

Commit

Permalink
Merge pull request #13567 from webpack/bugfix/initial-chunk-ids-with-…
Browse files Browse the repository at this point in the history
…depend-on

getAllInitialChunks really returns all of them
  • Loading branch information
sokra committed Jun 14, 2021
2 parents ac97a27 + e282a6c commit ae4bd73
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/Chunk.js
Expand Up @@ -598,8 +598,12 @@ class Chunk {
*/
getAllInitialChunks() {
const chunks = new Set();
for (const group of this.groupsIterable) {
for (const c of group.chunks) chunks.add(c);
const queue = new Set(this.groupsIterable);
for (const group of queue) {
if (group.isInitial()) {
for (const c of group.chunks) chunks.add(c);
for (const g of group.childrenIterable) queue.add(g);
}
}
return chunks;
}
Expand Down
1 change: 1 addition & 0 deletions test/configCases/entry/depend-on-non-js/a.css
@@ -0,0 +1 @@
module.exports = [[module.id, "body { background-color: green; }"]];
1 change: 1 addition & 0 deletions test/configCases/entry/depend-on-non-js/a.js
@@ -0,0 +1 @@
if (Math.random() < 0) require("./a.css");
1 change: 1 addition & 0 deletions test/configCases/entry/depend-on-non-js/b.css
@@ -0,0 +1 @@
module.exports = [[module.id, "body { color: red; }"]];
3 changes: 3 additions & 0 deletions test/configCases/entry/depend-on-non-js/b.js
@@ -0,0 +1,3 @@
if (Math.random() < 0) require("./b.css");

it("should run the test", () => {});
5 changes: 5 additions & 0 deletions test/configCases/entry/depend-on-non-js/test.config.js
@@ -0,0 +1,5 @@
module.exports = {
findBundle: function () {
return ["./runtime.js", "./a.js", "./b.js"];
}
};
38 changes: 38 additions & 0 deletions test/configCases/entry/depend-on-non-js/webpack.config.js
@@ -0,0 +1,38 @@
const MiniCssPlugin = require("mini-css-extract-plugin");

/** @type {import("../../../../").Configuration} */
module.exports = {
entry: {
a: "./a.js",
b: { import: "./b.js", dependOn: "a" }
},
module: {
rules: [
{
test: /\.css$/,
loader: MiniCssPlugin.loader
}
]
},
output: {
filename: "[name].js"
},
optimization: {
runtimeChunk: "single",
splitChunks: {
chunks: "all",
cacheGroups: {
styles: {
type: "css/mini-extract",
enforce: true
}
}
}
},
target: "web",
plugins: [
new MiniCssPlugin({
experimentalUseImportModule: true
})
]
};

0 comments on commit ae4bd73

Please sign in to comment.