Skip to content

Commit a915dab

Browse files
authored
test: remove legacy builtin configuration of builtin test cases (#11857)
1 parent 481b729 commit a915dab

File tree

101 files changed

+559
-494
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+559
-494
lines changed

packages/rspack-test-tools/src/case/builtin.ts

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import path from "node:path";
2-
import { rspack } from "@rspack/core";
32
import fs from "fs-extra";
43
import { merge } from "webpack-merge";
54
import { isJavaScript } from "../helper";
@@ -170,30 +169,6 @@ export function defaultOptions<T extends ECompilerType.Rspack>(
170169
defaultOptions = merge(defaultOptions, caseOptions);
171170
}
172171

173-
// TODO: remove builtin compatible code
174-
const defineOptions = (defaultOptions as any).builtins?.define;
175-
if (defineOptions) {
176-
defaultOptions.plugins!.push(new rspack.DefinePlugin(defineOptions));
177-
}
178-
179-
const provideOptions = (defaultOptions as any).builtins?.provide;
180-
if (provideOptions) {
181-
defaultOptions.plugins!.push(new rspack.ProvidePlugin(provideOptions));
182-
}
183-
184-
const htmlOptions = (defaultOptions as any).builtins?.html;
185-
if (htmlOptions) {
186-
if (Array.isArray(htmlOptions)) {
187-
for (const item of htmlOptions) {
188-
defaultOptions.plugins!.push(new rspack.HtmlRspackPlugin(item));
189-
}
190-
} else {
191-
defaultOptions.plugins!.push(new rspack.HtmlRspackPlugin(htmlOptions));
192-
}
193-
}
194-
195-
delete (defaultOptions as any).builtins;
196-
197172
if (!global.printLogger) {
198173
defaultOptions.infrastructureLogging = {
199174
level: "error"
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
const { HtmlRspackPlugin } = require("@rspack/core");
12
/** @type {import("@rspack/core").Configuration} */
23
module.exports = {
3-
builtins: {
4-
html: [{}]
5-
}
4+
plugins: [
5+
new HtmlRspackPlugin({})
6+
],
67
};
Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
const { HtmlRspackPlugin } = require("@rspack/core");
12
/** @type {import("@rspack/core").Configuration} */
23
module.exports = {
34
entry: {
@@ -11,13 +12,11 @@ module.exports = {
1112
import: ["./chunk3.js"]
1213
}
1314
},
14-
builtins: {
15-
html: [
16-
{
17-
template: "index.html",
18-
chunks: ["chunk1", "chunk2"],
19-
excludeChunks: ["chunk2"]
20-
}
21-
]
22-
}
15+
plugins: [
16+
new HtmlRspackPlugin({
17+
template: "index.html",
18+
chunks: ["chunk1", "chunk2"],
19+
excludeChunks: ["chunk2"]
20+
})
21+
],
2322
};
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1+
const { HtmlRspackPlugin } = require("@rspack/core");
12
/** @type {import("@rspack/core").Configuration} */
23
module.exports = {
34
entry: {
45
index: {
56
import: ["./index.js"]
67
}
78
},
8-
builtins: {
9-
html: [
10-
{
11-
favicon: "favicon.ico"
12-
}
13-
]
14-
}
9+
plugins: [
10+
new HtmlRspackPlugin({
11+
favicon: "favicon.ico"
12+
})
13+
],
14+
1515
};
Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1+
const { HtmlRspackPlugin } = require("@rspack/core");
2+
13
/** @type {import("@rspack/core").Configuration} */
24
module.exports = {
3-
builtins: {
4-
html: [
5-
{
6-
filename: "[name].[contenthash].html"
7-
},
8-
{
9-
template: "./index.html",
10-
filename: "[name].[contenthash].html"
11-
}
12-
]
13-
}
5+
plugins: [
6+
new HtmlRspackPlugin({
7+
filename: "[name].[contenthash].html"
8+
}),
9+
new HtmlRspackPlugin({
10+
template: "./index.html",
11+
filename: "[name].[contenthash].html"
12+
})
13+
],
1414
};
Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
1+
const { HtmlRspackPlugin } = require("@rspack/core");
12
/** @type {import("@rspack/core").Configuration} */
23
module.exports = {
3-
builtins: {
4-
html: [
5-
{
6-
filename: "inject_head.html",
7-
inject: "head"
8-
},
9-
{
10-
filename: "inject_body.html",
11-
inject: "body"
12-
},
13-
{
14-
filename: "inject_false.html",
15-
inject: false
16-
}
17-
]
18-
}
4+
plugins: [
5+
new HtmlRspackPlugin({
6+
filename: "inject_head.html",
7+
inject: "head"
8+
}),
9+
new HtmlRspackPlugin({
10+
filename: "inject_body.html",
11+
inject: "body"
12+
}),
13+
new HtmlRspackPlugin({
14+
filename: "inject_false.html",
15+
inject: false
16+
})
17+
],
1918
};
Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
1+
const { HtmlRspackPlugin } = require("@rspack/core");
2+
13
/** @type {import("@rspack/core").Configuration} */
24
module.exports = {
35
entry: {
46
index: {
57
import: ["./index.js"]
68
}
79
},
8-
builtins: {
9-
html: [
10-
{
11-
meta: {
12-
viewport: {
13-
name: "viewport",
14-
content: "width=device-width, initial-scale=1, shrink-to-fit=no"
15-
}
10+
plugins: [
11+
new HtmlRspackPlugin({
12+
meta: {
13+
viewport: {
14+
name: "viewport",
15+
content: "width=device-width, initial-scale=1, shrink-to-fit=no"
1616
}
1717
}
18-
]
19-
}
18+
})
19+
],
20+
2021
};
Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1+
const { HtmlRspackPlugin } = require("@rspack/core");
12
/** @type {import("@rspack/core").Configuration} */
23
module.exports = {
34
entry: {
45
index: {
56
import: ["./index.js"]
67
}
78
},
8-
builtins: {
9-
html: [
10-
{
11-
minify: true
12-
}
13-
]
14-
}
9+
plugins: [
10+
new HtmlRspackPlugin({
11+
minify: true
12+
})
13+
],
1514
};
Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
const { HtmlRspackPlugin } = require("@rspack/core");
12
/** @type {import("@rspack/core").Configuration} */
23
module.exports = {
34
entry: {
@@ -11,23 +12,22 @@ module.exports = {
1112
import: ["./chunk3.js"]
1213
}
1314
},
14-
builtins: {
15-
html: [
16-
{
17-
template: "index.html",
18-
filename: "chunk1.html",
19-
chunks: ["chunk1"]
20-
},
21-
{
22-
template: "index.html",
23-
filename: "chunk2.html",
24-
chunks: ["chunk2"]
25-
},
26-
{
27-
template: "index.html",
28-
filename: "chunk3.html",
29-
chunks: ["chunk3"]
30-
}
31-
]
32-
}
15+
plugins: [
16+
new HtmlRspackPlugin({
17+
template: "index.html",
18+
filename: "chunk1.html",
19+
chunks: ["chunk1"]
20+
}),
21+
new HtmlRspackPlugin({
22+
template: "index.html",
23+
filename: "chunk2.html",
24+
chunks: ["chunk2"]
25+
}),
26+
new HtmlRspackPlugin({
27+
template: "index.html",
28+
filename: "chunk3.html",
29+
chunks: ["chunk3"]
30+
})
31+
],
32+
3333
};
Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
const { HtmlRspackPlugin } = require("@rspack/core");
12
/** @type {import("@rspack/core").Configuration} */
23
module.exports = {
34
entry: {
@@ -8,11 +9,9 @@ module.exports = {
89
output: {
910
publicPath: "/base"
1011
},
11-
builtins: {
12-
html: [
13-
{
14-
favicon: "favicon.ico"
15-
}
16-
]
17-
}
12+
plugins: [
13+
new HtmlRspackPlugin({
14+
favicon: "favicon.ico"
15+
})
16+
],
1817
};

0 commit comments

Comments
 (0)