Skip to content

Commit e516dcc

Browse files
test(html): cover the [name] placeholder in the chunkName template
1 parent 9e5b364 commit e516dcc

4 files changed

Lines changed: 19 additions & 18 deletions

File tree

‎test/configCases/html/chunk-name-option/__snapshots__/ConfigCacheTest.snap‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,19 @@ exports[`ConfigCacheTestCases html chunk-name-option exported tests should name
1919
exports[`ConfigCacheTestCases html chunk-name-option exported tests should name every extracted chunk from the template 1`] = `
2020
"<!DOCTYPE html>
2121
<title>Named by the option</title>
22-
<script src=\\"page_script-module_0.mjs\\" type=\\"module\\"></script>
22+
<script src=\\"page__script-module_0.mjs\\" type=\\"module\\"></script>
2323
24-
<script src=\\"page_script-module_2.mjs\\" async type=\\"module\\"></script>
25-
<script type=\\"module\\" src=\\"page_script-module_3.mjs\\"></script>
24+
<script src=\\"page__script-module_2.mjs\\" async type=\\"module\\"></script>
25+
<script type=\\"module\\" src=\\"page_external_script-module_3.mjs\\"></script>
2626
"
2727
`;
2828
2929
exports[`ConfigCacheTestCases html chunk-name-option exported tests should name every extracted chunk from the template 2`] = `
3030
"<!DOCTYPE html>
3131
<title>Named by the option</title>
32-
<script src=\\"page_script-module_0.mjs\\" type=\\"module\\"></script>
32+
<script src=\\"page__script-module_0.mjs\\" type=\\"module\\"></script>
3333
34-
<script src=\\"page_script-module_2.mjs\\" async type=\\"module\\"></script>
35-
<script type=\\"module\\" src=\\"page_script-module_3.mjs\\"></script>
34+
<script src=\\"page__script-module_2.mjs\\" async type=\\"module\\"></script>
35+
<script type=\\"module\\" src=\\"page_external_script-module_3.mjs\\"></script>
3636
"
3737
`;

‎test/configCases/html/chunk-name-option/__snapshots__/ConfigTest.snap‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,19 @@ exports[`ConfigTestCases html chunk-name-option exported tests should name a chu
1919
exports[`ConfigTestCases html chunk-name-option exported tests should name every extracted chunk from the template 1`] = `
2020
"<!DOCTYPE html>
2121
<title>Named by the option</title>
22-
<script src=\\"page_script-module_0.mjs\\" type=\\"module\\"></script>
22+
<script src=\\"page__script-module_0.mjs\\" type=\\"module\\"></script>
2323
24-
<script src=\\"page_script-module_2.mjs\\" async type=\\"module\\"></script>
25-
<script type=\\"module\\" src=\\"page_script-module_3.mjs\\"></script>
24+
<script src=\\"page__script-module_2.mjs\\" async type=\\"module\\"></script>
25+
<script type=\\"module\\" src=\\"page_external_script-module_3.mjs\\"></script>
2626
"
2727
`;
2828
2929
exports[`ConfigTestCases html chunk-name-option exported tests should name every extracted chunk from the template 2`] = `
3030
"<!DOCTYPE html>
3131
<title>Named by the option</title>
32-
<script src=\\"page_script-module_0.mjs\\" type=\\"module\\"></script>
32+
<script src=\\"page__script-module_0.mjs\\" type=\\"module\\"></script>
3333
34-
<script src=\\"page_script-module_2.mjs\\" async type=\\"module\\"></script>
35-
<script type=\\"module\\" src=\\"page_script-module_3.mjs\\"></script>
34+
<script src=\\"page__script-module_2.mjs\\" async type=\\"module\\"></script>
35+
<script type=\\"module\\" src=\\"page_external_script-module_3.mjs\\"></script>
3636
"
3737
`;

‎test/configCases/html/chunk-name-option/test.js‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,14 @@ it("should name every extracted chunk from the template", () => {
2020
const html = read("page.html");
2121
expect(html).toMatchSnapshot();
2222

23-
// `[page]_[type]_[index]`: the run's leader, the async tag and the `src`
24-
// tag, each at the position its tag holds in the document.
23+
// `[page]_[name]_[type]_[index]`: the run's leader, the async tag and the
24+
// `src` tag, each at the position its tag holds in the document. Only the
25+
// `src` tag has a url to lend `[name]` a basename.
2526
const urls = scriptUrls(html);
2627
expect(urls).toEqual([
27-
"page_script-module_0.mjs",
28-
"page_script-module_2.mjs",
29-
"page_script-module_3.mjs"
28+
"page__script-module_0.mjs",
29+
"page__script-module_2.mjs",
30+
"page_external_script-module_3.mjs"
3031
]);
3132
});
3233

‎test/configCases/html/chunk-name-option/webpack.config.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ module.exports = [
3737
parser: {
3838
// The placeholders name every chunk this page extracts, in place
3939
// of the default `<page>-<index>`.
40-
html: { chunkName: "[page]_[type]_[index]" }
40+
html: { chunkName: "[page]_[name]_[type]_[index]" }
4141
}
4242
},
4343
optimization: { chunkIds: "named" },

0 commit comments

Comments
 (0)