Skip to content

Commit a8d7922

Browse files
authored
Merge pull request #16088 from webpack/correct-error-with-wrong-chunkname
Correct error with wrong chunkname
2 parents d58d4c9 + c4762f8 commit a8d7922

7 files changed

Lines changed: 31 additions & 1 deletion

File tree

lib/buildChunkGraph.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -508,8 +508,9 @@ const visitModules = (
508508
new AsyncDependencyToInitialChunkError(chunkName, module, b.loc)
509509
);
510510
c = chunkGroup;
511+
} else {
512+
c.addOptions(b.groupOptions);
511513
}
512-
c.addOptions(b.groupOptions);
513514
c.addOrigin(module, b.loc, b.request);
514515
}
515516
blockConnections.set(b, []);

test/__snapshots__/StatsTestCases.basictest.js.snap

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1014,6 +1014,24 @@ Unexpected end of JSON input while parsing empty string
10141014
webpack x.x.x compiled with 1 error in X ms"
10151015
`;
10161016

1017+
exports[`StatsTestCases should print correct stats for dynamic-chunk-name-error 1`] = `
1018+
"assets by status 8.29 KiB [cached] 3 assets
1019+
runtime modules 3.54 KiB 8 modules
1020+
cacheable modules 128 bytes
1021+
./entry-1.js 63 bytes [built] [code generated]
1022+
./entry-2.js 1 bytes [built] [code generated]
1023+
./entry-3.js 63 bytes [built] [code generated]
1024+
./dynamic.js 1 bytes [built] [code generated]
1025+
1026+
ERROR in ./entry-1.js 1:7-58
1027+
It's not allowed to load an initial chunk on demand. The chunk name \\"entry2\\" is already used by an entrypoint.
1028+
1029+
ERROR in ./entry-3.js 1:7-58
1030+
It's not allowed to load an initial chunk on demand. The chunk name \\"entry3\\" is already used by an entrypoint.
1031+
1032+
webpack x.x.x compiled with 2 errors in X ms"
1033+
`;
1034+
10171035
exports[`StatsTestCases should print correct stats for entry-filename 1`] = `
10181036
"PublicPath: auto
10191037
asset a.js 1.4 KiB [emitted] (name: a)

test/statsCases/dynamic-chunk-name-error/dynamic.js

Whitespace-only changes.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
(() => import(/* webpackChunkName: "entry2" */"./dynamic"))();

test/statsCases/dynamic-chunk-name-error/entry-2.js

Whitespace-only changes.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
(() => import(/* webpackChunkName: "entry3" */"./dynamic"))();
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/** @type {import("../../../").Configuration} */
2+
module.exports = {
3+
mode: "production",
4+
entry: {
5+
entry1: "./entry-1.js",
6+
entry2: "./entry-2.js",
7+
entry3: "./entry-3.js"
8+
}
9+
};

0 commit comments

Comments
 (0)