Skip to content

Commit c22632f

Browse files
committed
fix(split-chunks): discover singleton intersections
1 parent cde4e88 commit c22632f

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

‎lib/optimize/SplitChunksPlugin.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ const ALL_CHUNK_FILTER = (_chunk) => true;
348348
/** Placeholder until a chunk set group is filled and its signatures are written. */
349349
const EMPTY_SIGNATURES = new Uint32Array(0);
350350

351-
const MIN_INTERSECTION_CHUNKS = 2;
351+
const MIN_INTERSECTION_CHUNKS = 1;
352352
const MAX_INTERSECTION_CANDIDATE_FACTOR = 2;
353353
const MAX_INTERSECTION_CANDIDATES = 4096;
354354
const MAX_INTERSECTION_PAIRS = 500000;

‎test/configCases/split-chunks/intersections-min-size/webpack.config.js‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ const config = ({
4141
target: "node",
4242
entry: {
4343
a: "./a",
44-
b: "./b",
44+
...(minChunks === 1 ? {} : { b: "./b" }),
4545
...(higherOrder
4646
? { c: "./pair01", d: "./pair02", e: "./pair12" }
4747
: { c: "./c0", d: "./c1", e: "./c2" })
@@ -80,7 +80,7 @@ const config = ({
8080
(compiler) => {
8181
compiler.hooks.done.tap("AssertIntersectionCandidates", (stats) => {
8282
const { chunkGraph, modules } = stats.compilation;
83-
const shouldSplit = !belowThreshold && minChunks === 2;
83+
const shouldSplit = !belowThreshold && minChunks <= 2;
8484
const shared = [...modules].filter((module) => {
8585
const name = module.nameForCondition();
8686
return name !== null && /[\\/]m[012]\.js$/.test(name);
@@ -114,5 +114,6 @@ module.exports = [
114114
{ usedExports: true, higherOrder: true },
115115
{ named: true },
116116
{ reductionOnly: true },
117+
{ minChunks: 1 },
117118
{ minChunks: 3 }
118119
].map(config);

0 commit comments

Comments
 (0)