@esmx/rspack 3.0.0-rc.44 → 3.0.0-rc.45
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +2 -4
- package/dist/index.mjs +4 -4
- package/dist/{app.d.ts → rspack/app.d.ts} +41 -0
- package/dist/{app.mjs → rspack/app.mjs} +2 -4
- package/dist/rspack/build-target.d.ts +8 -0
- package/dist/rspack/chain-config.d.ts +7 -0
- package/dist/rspack/chain-config.mjs +133 -0
- package/dist/rspack/index.d.ts +3 -0
- package/dist/rspack/index.mjs +4 -0
- package/dist/{html-app.d.ts → rspack-html/index.d.ts} +1 -114
- package/dist/rspack-html/index.mjs +158 -0
- package/package.json +7 -6
- package/src/index.ts +6 -5
- package/src/{app.ts → rspack/app.ts} +49 -6
- package/src/rspack/build-target.ts +8 -0
- package/src/rspack/chain-config.ts +193 -0
- package/src/rspack/index.ts +8 -0
- package/src/rspack-html/index.ts +510 -0
- package/dist/build-target.d.ts +0 -8
- package/dist/html-app.mjs +0 -214
- package/src/build-target.ts +0 -8
- package/src/html-app.ts +0 -559
- /package/dist/{build-target.mjs → rspack/build-target.mjs} +0 -0
- /package/dist/{config.d.ts → rspack/config.d.ts} +0 -0
- /package/dist/{config.mjs → rspack/config.mjs} +0 -0
- /package/dist/{hmr-config.d.ts → rspack/hmr-config.d.ts} +0 -0
- /package/dist/{hmr-config.mjs → rspack/hmr-config.mjs} +0 -0
- /package/dist/{hot-fix.d.ts → rspack/hot-fix.d.ts} +0 -0
- /package/dist/{hot-fix.mjs → rspack/hot-fix.mjs} +0 -0
- /package/dist/{loader.d.ts → rspack/loader.d.ts} +0 -0
- /package/dist/{loader.mjs → rspack/loader.mjs} +0 -0
- /package/dist/{pack.d.ts → rspack/pack.d.ts} +0 -0
- /package/dist/{pack.mjs → rspack/pack.mjs} +0 -0
- /package/dist/{utils → rspack/utils}/index.d.ts +0 -0
- /package/dist/{utils → rspack/utils}/index.mjs +0 -0
- /package/dist/{utils → rspack/utils}/rsbuild.d.ts +0 -0
- /package/dist/{utils → rspack/utils}/rsbuild.mjs +0 -0
- /package/src/{config.ts → rspack/config.ts} +0 -0
- /package/src/{hmr-config.ts → rspack/hmr-config.ts} +0 -0
- /package/src/{hot-fix.ts → rspack/hot-fix.ts} +0 -0
- /package/src/{loader.ts → rspack/loader.ts} +0 -0
- /package/src/{pack.ts → rspack/pack.ts} +0 -0
- /package/src/{utils → rspack/utils}/index.ts +0 -0
- /package/src/{utils → rspack/utils}/rsbuild.ts +0 -0
package/dist/html-app.mjs
DELETED
|
@@ -1,214 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
rspack
|
|
3
|
-
} from "@rspack/core";
|
|
4
|
-
import NodePolyfillPlugin from "node-polyfill-webpack-plugin";
|
|
5
|
-
import {
|
|
6
|
-
createRspackApp
|
|
7
|
-
} from "./app.mjs";
|
|
8
|
-
import { RSPACK_LOADER } from "./loader.mjs";
|
|
9
|
-
export async function createRspackHtmlApp(esmx, options) {
|
|
10
|
-
options = {
|
|
11
|
-
...options,
|
|
12
|
-
target: {
|
|
13
|
-
web: ["chrome>=64", "edge>=79", "firefox>=67", "safari>=11.1"],
|
|
14
|
-
node: ["node>=24"],
|
|
15
|
-
...options?.target
|
|
16
|
-
},
|
|
17
|
-
css: options?.css ? options.css : esmx.isProd ? "css" : "js"
|
|
18
|
-
};
|
|
19
|
-
return createRspackApp(esmx, {
|
|
20
|
-
...options,
|
|
21
|
-
config(context) {
|
|
22
|
-
const { config, buildTarget } = context;
|
|
23
|
-
config.stats = "errors-warnings";
|
|
24
|
-
config.module = {
|
|
25
|
-
...config.module,
|
|
26
|
-
rules: [
|
|
27
|
-
...config.module?.rules ?? [],
|
|
28
|
-
{
|
|
29
|
-
test: /\.(jpe?g|png|gif|bmp|webp|svg)$/i,
|
|
30
|
-
type: "asset/resource",
|
|
31
|
-
generator: {
|
|
32
|
-
filename: filename(esmx, "images")
|
|
33
|
-
}
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)$/i,
|
|
37
|
-
type: "asset/resource",
|
|
38
|
-
generator: {
|
|
39
|
-
filename: filename(esmx, "media")
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
test: /\.(woff|woff2|eot|ttf|otf)(\?.*)?$/i,
|
|
44
|
-
type: "asset/resource",
|
|
45
|
-
generator: {
|
|
46
|
-
filename: filename(esmx, "fonts")
|
|
47
|
-
}
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
test: /\.json$/i,
|
|
51
|
-
type: "json"
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
test: /\.worker\.(c|m)?(t|j)s$/i,
|
|
55
|
-
loader: options.loaders?.workerRspackLoader ?? RSPACK_LOADER.workerRspackLoader,
|
|
56
|
-
options: {
|
|
57
|
-
esModule: false,
|
|
58
|
-
filename: `${esmx.name}/workers/[name].[contenthash]${esmx.isProd ? ".final" : ""}.js`
|
|
59
|
-
}
|
|
60
|
-
},
|
|
61
|
-
{
|
|
62
|
-
test: /\.(ts|mts)$/i,
|
|
63
|
-
loader: options.loaders?.builtinSwcLoader ?? RSPACK_LOADER.builtinSwcLoader,
|
|
64
|
-
options: {
|
|
65
|
-
env: {
|
|
66
|
-
targets: buildTarget === "client" ? options?.target?.web : options?.target?.node,
|
|
67
|
-
...options?.swcLoader?.env
|
|
68
|
-
},
|
|
69
|
-
jsc: {
|
|
70
|
-
parser: {
|
|
71
|
-
syntax: "typescript",
|
|
72
|
-
...options?.swcLoader?.jsc?.parser
|
|
73
|
-
},
|
|
74
|
-
...options?.swcLoader?.jsc
|
|
75
|
-
},
|
|
76
|
-
...options?.swcLoader
|
|
77
|
-
},
|
|
78
|
-
type: "javascript/auto"
|
|
79
|
-
}
|
|
80
|
-
]
|
|
81
|
-
};
|
|
82
|
-
config.optimization = {
|
|
83
|
-
...config.optimization,
|
|
84
|
-
minimizer: [
|
|
85
|
-
new rspack.SwcJsMinimizerRspackPlugin({
|
|
86
|
-
minimizerOptions: {
|
|
87
|
-
format: {
|
|
88
|
-
comments: false
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}),
|
|
92
|
-
new rspack.LightningCssMinimizerRspackPlugin({
|
|
93
|
-
minimizerOptions: {
|
|
94
|
-
targets: options.target?.web,
|
|
95
|
-
errorRecovery: false
|
|
96
|
-
}
|
|
97
|
-
})
|
|
98
|
-
]
|
|
99
|
-
};
|
|
100
|
-
config.plugins = [
|
|
101
|
-
new NodePolyfillPlugin(),
|
|
102
|
-
...config.plugins ?? []
|
|
103
|
-
];
|
|
104
|
-
config.devtool = false;
|
|
105
|
-
config.cache = false;
|
|
106
|
-
if (options.definePlugin) {
|
|
107
|
-
const defineOptions = {};
|
|
108
|
-
Object.entries(options.definePlugin).forEach(
|
|
109
|
-
([name, value]) => {
|
|
110
|
-
const targetValue = typeof value === "string" ? value : value[buildTarget];
|
|
111
|
-
if (typeof targetValue === "string" && name !== targetValue) {
|
|
112
|
-
defineOptions[name] = targetValue;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
);
|
|
116
|
-
if (Object.keys(defineOptions).length) {
|
|
117
|
-
config.plugins.push(new rspack.DefinePlugin(defineOptions));
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
config.resolve = {
|
|
121
|
-
...config.resolve,
|
|
122
|
-
extensions: ["...", ".ts"]
|
|
123
|
-
};
|
|
124
|
-
addCssConfig(esmx, options, context);
|
|
125
|
-
options?.config?.(context);
|
|
126
|
-
}
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
function filename(esmx, name, ext = "[ext]") {
|
|
130
|
-
return esmx.isProd ? `${name}/[name].[contenthash:8].final${ext}` : `${name}/[path][name]${ext}`;
|
|
131
|
-
}
|
|
132
|
-
function addCssConfig(esmx, options, { config }) {
|
|
133
|
-
if (options.css === false) {
|
|
134
|
-
return;
|
|
135
|
-
}
|
|
136
|
-
if (options.css === "js") {
|
|
137
|
-
const cssRule = [
|
|
138
|
-
{
|
|
139
|
-
loader: options.loaders?.styleLoader ?? RSPACK_LOADER.styleLoader,
|
|
140
|
-
options: options.styleLoader
|
|
141
|
-
},
|
|
142
|
-
{
|
|
143
|
-
loader: options.loaders?.cssLoader ?? RSPACK_LOADER.cssLoader,
|
|
144
|
-
options: options.cssLoader
|
|
145
|
-
},
|
|
146
|
-
{
|
|
147
|
-
loader: options.loaders?.lightningcssLoader ?? RSPACK_LOADER.lightningcssLoader,
|
|
148
|
-
options: {
|
|
149
|
-
targets: options.target?.web ?? [],
|
|
150
|
-
minify: esmx.isProd
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
];
|
|
154
|
-
const lessRule = [
|
|
155
|
-
{
|
|
156
|
-
loader: options.loaders?.lessLoader ?? RSPACK_LOADER.lessLoader,
|
|
157
|
-
options: options.lessLoader
|
|
158
|
-
}
|
|
159
|
-
];
|
|
160
|
-
if (options.styleResourcesLoader) {
|
|
161
|
-
lessRule.push({
|
|
162
|
-
loader: options.loaders?.styleResourcesLoader ?? RSPACK_LOADER.styleResourcesLoader,
|
|
163
|
-
options: options.styleResourcesLoader
|
|
164
|
-
});
|
|
165
|
-
}
|
|
166
|
-
config.module = {
|
|
167
|
-
...config.module,
|
|
168
|
-
rules: [
|
|
169
|
-
...config.module?.rules ?? [],
|
|
170
|
-
{
|
|
171
|
-
test: /\.less$/,
|
|
172
|
-
use: [...cssRule, ...lessRule],
|
|
173
|
-
type: "javascript/auto"
|
|
174
|
-
},
|
|
175
|
-
{
|
|
176
|
-
test: /\.css$/,
|
|
177
|
-
use: cssRule,
|
|
178
|
-
type: "javascript/auto"
|
|
179
|
-
}
|
|
180
|
-
]
|
|
181
|
-
};
|
|
182
|
-
return;
|
|
183
|
-
}
|
|
184
|
-
config.experiments = {
|
|
185
|
-
...config.experiments,
|
|
186
|
-
css: true
|
|
187
|
-
};
|
|
188
|
-
if (!config.experiments.css) {
|
|
189
|
-
return;
|
|
190
|
-
}
|
|
191
|
-
const lessLoaders = [
|
|
192
|
-
{
|
|
193
|
-
loader: options.loaders?.lessLoader ?? RSPACK_LOADER.lessLoader,
|
|
194
|
-
options: options.lessLoader
|
|
195
|
-
}
|
|
196
|
-
];
|
|
197
|
-
if (options.styleResourcesLoader) {
|
|
198
|
-
lessLoaders.push({
|
|
199
|
-
loader: options.loaders?.styleResourcesLoader ?? RSPACK_LOADER.styleResourcesLoader,
|
|
200
|
-
options: options.styleResourcesLoader
|
|
201
|
-
});
|
|
202
|
-
}
|
|
203
|
-
config.module = {
|
|
204
|
-
...config.module,
|
|
205
|
-
rules: [
|
|
206
|
-
...config.module?.rules ?? [],
|
|
207
|
-
{
|
|
208
|
-
test: /\.less$/,
|
|
209
|
-
use: [...lessLoaders],
|
|
210
|
-
type: "css"
|
|
211
|
-
}
|
|
212
|
-
]
|
|
213
|
-
};
|
|
214
|
-
}
|