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

SplitChunksPlugin shouldn't change entrypoint chunk name #10910

Closed
Closed
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
4 changes: 3 additions & 1 deletion lib/optimize/SplitChunksPlugin.js
Expand Up @@ -1297,7 +1297,9 @@ module.exports = class SplitChunksPlugin {
}
} else {
// change the chunk to be a part
chunk.name = name;
if (chunkGraph.getNumberOfEntryModules(chunk) === 0) {
chunk.name = name;
}
}
}
}
Expand Down
136 changes: 68 additions & 68 deletions test/__snapshots__/StatsTestCases.test.js.snap

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions test/configCases/split-chunks/chunk-filename-entrypoint/a.js
@@ -0,0 +1,3 @@
const c = require("./commons");

module.exports = "a" + c;
3 changes: 3 additions & 0 deletions test/configCases/split-chunks/chunk-filename-entrypoint/b.js
@@ -0,0 +1,3 @@
const c = require("./commons");

module.exports = "b" + c;
3 changes: 3 additions & 0 deletions test/configCases/split-chunks/chunk-filename-entrypoint/c.js
@@ -0,0 +1,3 @@
const c = require("./commons");

module.exports = "c" + c;
@@ -0,0 +1,2 @@
/* Large module to trigger chunk generation */
module.exports = "commons";
14 changes: 14 additions & 0 deletions test/configCases/split-chunks/chunk-filename-entrypoint/index.js
@@ -0,0 +1,14 @@
it("should run", function() {
Promise.all(
[
import(/* webpackChunkName: "a" */ "./a"),
import(/* webpackChunkName: "b" */ "./b"),
import(/* webpackChunkName: "c" */ "./c")
]
);

const files = require("fs").readdirSync(__dirname);
expect(files).toContain('main.js');
expect(files).toContain('a-a_js-2a91f0ff.bundle.js');
expect(files).toContain('b-b_js-c441f481.bundle.js');
});
@@ -0,0 +1,5 @@
module.exports = {
findBundle: function(i, options) {
return ["main.js"];
}
};
@@ -0,0 +1,23 @@
/** @type {import("../../../../").Configuration} */
module.exports = {
mode: "development",
entry: {
main: "./index.js"
},
node: {
__dirname: false,
__filename: false
},
output: {
filename: "[name].js",
chunkFilename: "[name].bundle.js"
},
optimization: {
splitChunks: {
chunks: "all",
name: "common",
maxSize: 2,
minSize: 1
}
}
};