Skip to content

Commit 916810e

Browse files
test: lock chunk filenames stay verbatim for scoped names (#21006)
Regression test ensuring webpack does not URL-encode '@' (or other special characters) in entry names or webpackChunkName values. Mirrors the concern raised in jantimon/html-webpack-plugin#1771 against the plugin and pins the expected webpack-side behavior.
1 parent 72ef0fb commit 916810e

4 files changed

Lines changed: 34 additions & 0 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export default 42;
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
it("should not URL-encode '@' in chunk filenames", () =>
2+
import(/* webpackChunkName: "@scope/chunk" */ "./chunk").then(r =>
3+
expect(r).toEqual(expect.objectContaining({ default: 42 }))
4+
));
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
"use strict";
2+
3+
const fs = require("fs");
4+
const path = require("path");
5+
6+
module.exports = {
7+
findBundle(i, options) {
8+
const bundle = "./@scope/app.js";
9+
const chunk = path.join(options.output.path, "chunks/@scope/chunk.js");
10+
if (!fs.existsSync(chunk)) {
11+
throw new Error(
12+
`Expected chunk to be emitted verbatim at ${chunk} (no URL-encoding of '@'); see https://github.com/jantimon/html-webpack-plugin/issues/1771`
13+
);
14+
}
15+
return [bundle];
16+
}
17+
};
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
"use strict";
2+
3+
/** @type {import("../../../../").Configuration} */
4+
module.exports = {
5+
entry: {
6+
"@scope/app": "./index.js"
7+
},
8+
output: {
9+
filename: "[name].js",
10+
chunkFilename: "chunks/[name].js"
11+
}
12+
};

0 commit comments

Comments
 (0)