@rsbuild/core 0.7.7 → 0.7.8
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/compiled/css-loader/index.js +3 -3
- package/compiled/jiti/index.d.ts +1 -0
- package/compiled/jiti/index.js +391 -0
- package/compiled/jiti/license +21 -0
- package/compiled/jiti/package.json +1 -0
- package/compiled/postcss-load-config/index.js +1 -1
- package/compiled/postcss-loader/index.js +6 -6
- package/compiled/semver/index.d.ts +1 -0
- package/compiled/semver/index.js +2585 -0
- package/compiled/semver/license +15 -0
- package/compiled/semver/package.json +1 -0
- package/compiled/webpack-dev-middleware/index.js +280 -10
- package/compiled/ws/index.js +80 -57
- package/compiled/ws/package.json +1 -1
- package/dist/index.cjs +579 -530
- package/dist/index.js +340 -304
- package/dist-types/helpers.d.ts +2 -0
- package/dist-types/index.d.ts +1 -0
- package/dist-types/internal.d.ts +1 -1
- package/dist-types/server/helper.d.ts +1 -0
- package/dist-types/types.d.ts +1 -2
- package/package.json +5 -3
- package/dist-types/server/index.d.ts +0 -2
package/dist/index.cjs
CHANGED
|
@@ -237,7 +237,7 @@ function isEmptyDir(path13) {
|
|
|
237
237
|
async function isFileExists(file) {
|
|
238
238
|
return import_shared2.fse.promises.access(file, import_shared2.fse.constants.F_OK).then(() => true).catch(() => false);
|
|
239
239
|
}
|
|
240
|
-
var import_node_path2, import_shared, import_shared2, rspackMinVersion, compareSemver, isSatisfyRspackVersion, getCompiledPath, hintNodePolyfill, getAllStatsErrors, getAllStatsWarnings, formatPublicPath, getPublicPathFromChain, ensureAbsolutePath, isFileSync, findExists;
|
|
240
|
+
var import_node_path2, import_shared, import_shared2, rspackMinVersion, compareSemver, isSatisfyRspackVersion, getCompiledPath, hintNodePolyfill, getAllStatsErrors, getAllStatsWarnings, formatPublicPath, getPublicPathFromChain, ensureAbsolutePath, isFileSync, findExists, urlJoin, canParse, ensureAssetPrefix;
|
|
241
241
|
var init_helpers = __esm({
|
|
242
242
|
"src/helpers.ts"() {
|
|
243
243
|
"use strict";
|
|
@@ -381,6 +381,34 @@ ${import_shared.color.yellow(tips.join("\n"))}`;
|
|
|
381
381
|
}
|
|
382
382
|
return false;
|
|
383
383
|
};
|
|
384
|
+
urlJoin = (base, path13) => {
|
|
385
|
+
const fullUrl = new URL(base);
|
|
386
|
+
fullUrl.pathname = import_node_path2.posix.join(fullUrl.pathname, path13);
|
|
387
|
+
return fullUrl.toString();
|
|
388
|
+
};
|
|
389
|
+
canParse = (url2) => {
|
|
390
|
+
try {
|
|
391
|
+
new URL(url2);
|
|
392
|
+
return true;
|
|
393
|
+
} catch {
|
|
394
|
+
return false;
|
|
395
|
+
}
|
|
396
|
+
};
|
|
397
|
+
ensureAssetPrefix = (url2, assetPrefix) => {
|
|
398
|
+
if (url2.startsWith("//")) {
|
|
399
|
+
return url2;
|
|
400
|
+
}
|
|
401
|
+
if (canParse(url2)) {
|
|
402
|
+
return url2;
|
|
403
|
+
}
|
|
404
|
+
if (assetPrefix.startsWith("http")) {
|
|
405
|
+
return urlJoin(assetPrefix, url2);
|
|
406
|
+
}
|
|
407
|
+
if (assetPrefix.startsWith("//")) {
|
|
408
|
+
return urlJoin(`https:${assetPrefix}`, url2).replace("https:", "");
|
|
409
|
+
}
|
|
410
|
+
return import_node_path2.posix.join(assetPrefix, url2);
|
|
411
|
+
};
|
|
384
412
|
}
|
|
385
413
|
});
|
|
386
414
|
|
|
@@ -544,7 +572,7 @@ async function loadConfig({
|
|
|
544
572
|
return config;
|
|
545
573
|
};
|
|
546
574
|
try {
|
|
547
|
-
const { default: jiti } = await import("
|
|
575
|
+
const { default: jiti } = await import("../compiled/jiti/index.js");
|
|
548
576
|
const loadConfig2 = jiti(__filename, {
|
|
549
577
|
esmResolve: true,
|
|
550
578
|
// disable require cache to support restart CLI and read the new config
|
|
@@ -1032,7 +1060,7 @@ async function createContextByConfig(options, bundlerType, config = {}) {
|
|
|
1032
1060
|
return {
|
|
1033
1061
|
entry: getEntryObject(config, "web"),
|
|
1034
1062
|
targets: config.output?.targets || [],
|
|
1035
|
-
version: "0.7.
|
|
1063
|
+
version: "0.7.8",
|
|
1036
1064
|
rootPath,
|
|
1037
1065
|
distPath,
|
|
1038
1066
|
cachePath,
|
|
@@ -2213,7 +2241,7 @@ function getURLMessages(urls, routes) {
|
|
|
2213
2241
|
if (routes.length === 1) {
|
|
2214
2242
|
return urls.map(
|
|
2215
2243
|
({ label, url: url2 }) => ` ${`> ${label.padEnd(10)}`}${import_shared20.color.cyan(
|
|
2216
|
-
|
|
2244
|
+
normalizeUrl(`${url2}${routes[0].pathname}`)
|
|
2217
2245
|
)}
|
|
2218
2246
|
`
|
|
2219
2247
|
).join("");
|
|
@@ -2229,7 +2257,7 @@ function getURLMessages(urls, routes) {
|
|
|
2229
2257
|
for (const r of routes) {
|
|
2230
2258
|
message += ` ${import_shared20.color.dim("-")} ${import_shared20.color.dim(
|
|
2231
2259
|
r.entryName.padEnd(maxNameLength + 4)
|
|
2232
|
-
)}${import_shared20.color.cyan(
|
|
2260
|
+
)}${import_shared20.color.cyan(normalizeUrl(`${url2}${r.pathname}`))}
|
|
2233
2261
|
`;
|
|
2234
2262
|
}
|
|
2235
2263
|
});
|
|
@@ -2273,7 +2301,7 @@ function printServerURLs({
|
|
|
2273
2301
|
import_shared20.logger.log(message);
|
|
2274
2302
|
return message;
|
|
2275
2303
|
}
|
|
2276
|
-
var import_node_net, import_node_os, import_shared20, formatPrefix, formatRoutes, HMR_SOCK_PATH, getPort, getServerConfig, getDevConfig, getIpv4Interfaces, isLoopbackHost, getHostInUrl, concatUrl, LOCAL_LABEL, NETWORK_LABEL, getUrlLabel, getAddressUrls;
|
|
2304
|
+
var import_node_net, import_node_os, import_shared20, normalizeUrl, formatPrefix, formatRoutes, HMR_SOCK_PATH, getPort, getServerConfig, getDevConfig, getIpv4Interfaces, isLoopbackHost, getHostInUrl, concatUrl, LOCAL_LABEL, NETWORK_LABEL, getUrlLabel, getAddressUrls;
|
|
2277
2305
|
var init_helper = __esm({
|
|
2278
2306
|
"src/server/helper.ts"() {
|
|
2279
2307
|
"use strict";
|
|
@@ -2281,6 +2309,7 @@ var init_helper = __esm({
|
|
|
2281
2309
|
import_node_os = __toESM(require("os"));
|
|
2282
2310
|
import_shared20 = require("@rsbuild/shared");
|
|
2283
2311
|
init_constants();
|
|
2312
|
+
normalizeUrl = (url2) => url2.replace(/([^:]\/)\/+/g, "$1");
|
|
2284
2313
|
formatPrefix = (prefix) => {
|
|
2285
2314
|
if (!prefix) {
|
|
2286
2315
|
return "/";
|
|
@@ -2984,194 +3013,22 @@ var init_devServer = __esm({
|
|
|
2984
3013
|
}
|
|
2985
3014
|
});
|
|
2986
3015
|
|
|
2987
|
-
// src/server/prodServer.ts
|
|
2988
|
-
var prodServer_exports = {};
|
|
2989
|
-
__export(prodServer_exports, {
|
|
2990
|
-
RsbuildProdServer: () => RsbuildProdServer,
|
|
2991
|
-
startProdServer: () => startProdServer
|
|
2992
|
-
});
|
|
2993
|
-
async function startProdServer(context, config, { getPortSilently } = {}) {
|
|
2994
|
-
if (!(0, import_shared23.getNodeEnv)()) {
|
|
2995
|
-
(0, import_shared23.setNodeEnv)("production");
|
|
2996
|
-
}
|
|
2997
|
-
const { port, host, https } = await getServerConfig({
|
|
2998
|
-
config,
|
|
2999
|
-
getPortSilently
|
|
3000
|
-
});
|
|
3001
|
-
const { default: connect } = await import("../compiled/connect/index.js");
|
|
3002
|
-
const middlewares = connect();
|
|
3003
|
-
const serverConfig = config.server;
|
|
3004
|
-
const server = new RsbuildProdServer(
|
|
3005
|
-
{
|
|
3006
|
-
pwd: context.rootPath,
|
|
3007
|
-
output: {
|
|
3008
|
-
path: config.output.distPath.root || ROOT_DIST_DIR,
|
|
3009
|
-
assetPrefix: config.output.assetPrefix
|
|
3010
|
-
},
|
|
3011
|
-
serverConfig
|
|
3012
|
-
},
|
|
3013
|
-
middlewares
|
|
3014
|
-
);
|
|
3015
|
-
await context.hooks.onBeforeStartProdServer.call();
|
|
3016
|
-
const httpServer = await createHttpServer({
|
|
3017
|
-
serverConfig,
|
|
3018
|
-
middlewares: server.middlewares
|
|
3019
|
-
});
|
|
3020
|
-
await server.onInit(httpServer);
|
|
3021
|
-
return new Promise((resolve) => {
|
|
3022
|
-
httpServer.listen(
|
|
3023
|
-
{
|
|
3024
|
-
host,
|
|
3025
|
-
port
|
|
3026
|
-
},
|
|
3027
|
-
async () => {
|
|
3028
|
-
const routes = formatRoutes(
|
|
3029
|
-
context.entry,
|
|
3030
|
-
config.output.distPath.html,
|
|
3031
|
-
config.html.outputStructure
|
|
3032
|
-
);
|
|
3033
|
-
await context.hooks.onAfterStartProdServer.call({
|
|
3034
|
-
port,
|
|
3035
|
-
routes
|
|
3036
|
-
});
|
|
3037
|
-
const protocol = https ? "https" : "http";
|
|
3038
|
-
const urls = getAddressUrls({ protocol, port, host });
|
|
3039
|
-
printServerURLs({
|
|
3040
|
-
urls,
|
|
3041
|
-
port,
|
|
3042
|
-
routes,
|
|
3043
|
-
protocol,
|
|
3044
|
-
printUrls: serverConfig.printUrls
|
|
3045
|
-
});
|
|
3046
|
-
const onClose = () => {
|
|
3047
|
-
server.close();
|
|
3048
|
-
httpServer.close();
|
|
3049
|
-
};
|
|
3050
|
-
resolve({
|
|
3051
|
-
port,
|
|
3052
|
-
urls: urls.map((item) => item.url),
|
|
3053
|
-
server: {
|
|
3054
|
-
close: async () => {
|
|
3055
|
-
onClose();
|
|
3056
|
-
}
|
|
3057
|
-
}
|
|
3058
|
-
});
|
|
3059
|
-
}
|
|
3060
|
-
);
|
|
3061
|
-
});
|
|
3062
|
-
}
|
|
3063
|
-
var import_node_path11, import_shared23, RsbuildProdServer;
|
|
3064
|
-
var init_prodServer = __esm({
|
|
3065
|
-
"src/server/prodServer.ts"() {
|
|
3066
|
-
"use strict";
|
|
3067
|
-
import_node_path11 = require("path");
|
|
3068
|
-
import_shared23 = require("@rsbuild/shared");
|
|
3069
|
-
init_constants();
|
|
3070
|
-
init_helper();
|
|
3071
|
-
init_httpServer();
|
|
3072
|
-
init_middlewares();
|
|
3073
|
-
RsbuildProdServer = class {
|
|
3074
|
-
constructor(options, middlewares) {
|
|
3075
|
-
__publicField(this, "app");
|
|
3076
|
-
__publicField(this, "options");
|
|
3077
|
-
__publicField(this, "middlewares");
|
|
3078
|
-
this.options = options;
|
|
3079
|
-
this.middlewares = middlewares;
|
|
3080
|
-
}
|
|
3081
|
-
// Complete the preparation of services
|
|
3082
|
-
async onInit(app) {
|
|
3083
|
-
this.app = app;
|
|
3084
|
-
await this.applyDefaultMiddlewares();
|
|
3085
|
-
}
|
|
3086
|
-
async applyDefaultMiddlewares() {
|
|
3087
|
-
const { headers, proxy, historyApiFallback, compress } = this.options.serverConfig;
|
|
3088
|
-
if ((0, import_shared23.isDebug)()) {
|
|
3089
|
-
this.middlewares.use(await getRequestLoggerMiddleware());
|
|
3090
|
-
}
|
|
3091
|
-
if (compress) {
|
|
3092
|
-
const { default: compression } = await import("../compiled/http-compression/index.js");
|
|
3093
|
-
this.middlewares.use((req, res, next) => {
|
|
3094
|
-
compression({
|
|
3095
|
-
gzip: true,
|
|
3096
|
-
brotli: false
|
|
3097
|
-
})(req, res, next);
|
|
3098
|
-
});
|
|
3099
|
-
}
|
|
3100
|
-
if (headers) {
|
|
3101
|
-
this.middlewares.use((_req, res, next) => {
|
|
3102
|
-
for (const [key, value] of Object.entries(headers)) {
|
|
3103
|
-
res.setHeader(key, value);
|
|
3104
|
-
}
|
|
3105
|
-
next();
|
|
3106
|
-
});
|
|
3107
|
-
}
|
|
3108
|
-
if (proxy) {
|
|
3109
|
-
const { createProxyMiddleware: createProxyMiddleware2 } = await Promise.resolve().then(() => (init_proxy(), proxy_exports));
|
|
3110
|
-
const { middlewares, upgrade } = createProxyMiddleware2(proxy);
|
|
3111
|
-
for (const middleware of middlewares) {
|
|
3112
|
-
this.middlewares.use(middleware);
|
|
3113
|
-
}
|
|
3114
|
-
this.app.on("upgrade", upgrade);
|
|
3115
|
-
}
|
|
3116
|
-
this.applyStaticAssetMiddleware();
|
|
3117
|
-
if (historyApiFallback) {
|
|
3118
|
-
const { default: connectHistoryApiFallback } = await import("../compiled/connect-history-api-fallback/index.js");
|
|
3119
|
-
const historyApiFallbackMiddleware = connectHistoryApiFallback(
|
|
3120
|
-
historyApiFallback === true ? {} : historyApiFallback
|
|
3121
|
-
);
|
|
3122
|
-
this.middlewares.use(historyApiFallbackMiddleware);
|
|
3123
|
-
await this.applyStaticAssetMiddleware();
|
|
3124
|
-
}
|
|
3125
|
-
this.middlewares.use(faviconFallbackMiddleware);
|
|
3126
|
-
}
|
|
3127
|
-
async applyStaticAssetMiddleware() {
|
|
3128
|
-
const {
|
|
3129
|
-
output: { path: path13, assetPrefix },
|
|
3130
|
-
serverConfig: { htmlFallback },
|
|
3131
|
-
pwd
|
|
3132
|
-
} = this.options;
|
|
3133
|
-
const { default: sirv } = await import("../compiled/sirv/index.js");
|
|
3134
|
-
const assetMiddleware = sirv((0, import_node_path11.join)(pwd, path13), {
|
|
3135
|
-
etag: true,
|
|
3136
|
-
dev: true,
|
|
3137
|
-
ignores: ["favicon.ico"],
|
|
3138
|
-
single: htmlFallback === "index"
|
|
3139
|
-
});
|
|
3140
|
-
this.middlewares.use((req, res, next) => {
|
|
3141
|
-
const url2 = req.url;
|
|
3142
|
-
if (assetPrefix && url2?.startsWith(assetPrefix)) {
|
|
3143
|
-
req.url = url2.slice(assetPrefix.length);
|
|
3144
|
-
assetMiddleware(req, res, (...args) => {
|
|
3145
|
-
req.url = url2;
|
|
3146
|
-
next(...args);
|
|
3147
|
-
});
|
|
3148
|
-
} else {
|
|
3149
|
-
assetMiddleware(req, res, next);
|
|
3150
|
-
}
|
|
3151
|
-
});
|
|
3152
|
-
}
|
|
3153
|
-
close() {
|
|
3154
|
-
}
|
|
3155
|
-
};
|
|
3156
|
-
}
|
|
3157
|
-
});
|
|
3158
|
-
|
|
3159
3016
|
// src/provider/build.ts
|
|
3160
3017
|
var build_exports = {};
|
|
3161
3018
|
__export(build_exports, {
|
|
3162
3019
|
build: () => build
|
|
3163
3020
|
});
|
|
3164
|
-
var
|
|
3021
|
+
var import_shared23, import_core4, build;
|
|
3165
3022
|
var init_build = __esm({
|
|
3166
3023
|
"src/provider/build.ts"() {
|
|
3167
3024
|
"use strict";
|
|
3168
|
-
|
|
3025
|
+
import_shared23 = require("@rsbuild/shared");
|
|
3169
3026
|
import_core4 = require("@rspack/core");
|
|
3170
3027
|
init_createCompiler();
|
|
3171
3028
|
init_initConfigs();
|
|
3172
3029
|
build = async (initOptions, { mode = "production", watch, compiler: customCompiler } = {}) => {
|
|
3173
|
-
if (!(0,
|
|
3174
|
-
(0,
|
|
3030
|
+
if (!(0, import_shared23.getNodeEnv)()) {
|
|
3031
|
+
(0, import_shared23.setNodeEnv)(mode);
|
|
3175
3032
|
}
|
|
3176
3033
|
const { context } = initOptions;
|
|
3177
3034
|
let compiler;
|
|
@@ -3195,7 +3052,7 @@ var init_build = __esm({
|
|
|
3195
3052
|
isFirstCompile = false;
|
|
3196
3053
|
await p;
|
|
3197
3054
|
};
|
|
3198
|
-
(0,
|
|
3055
|
+
(0, import_shared23.onCompileDone)(
|
|
3199
3056
|
compiler,
|
|
3200
3057
|
onDone,
|
|
3201
3058
|
// @ts-expect-error type mismatch
|
|
@@ -3204,7 +3061,7 @@ var init_build = __esm({
|
|
|
3204
3061
|
if (watch) {
|
|
3205
3062
|
compiler.watch({}, (err) => {
|
|
3206
3063
|
if (err) {
|
|
3207
|
-
|
|
3064
|
+
import_shared23.logger.error(err);
|
|
3208
3065
|
}
|
|
3209
3066
|
});
|
|
3210
3067
|
return;
|
|
@@ -3217,7 +3074,7 @@ var init_build = __esm({
|
|
|
3217
3074
|
} else {
|
|
3218
3075
|
compiler.close((closeErr) => {
|
|
3219
3076
|
if (closeErr) {
|
|
3220
|
-
|
|
3077
|
+
import_shared23.logger.error(closeErr);
|
|
3221
3078
|
}
|
|
3222
3079
|
resolve({ stats });
|
|
3223
3080
|
});
|
|
@@ -3281,11 +3138,6 @@ var init_provider = __esm({
|
|
|
3281
3138
|
);
|
|
3282
3139
|
return server.listen();
|
|
3283
3140
|
},
|
|
3284
|
-
async preview(options) {
|
|
3285
|
-
const { startProdServer: startProdServer2 } = await Promise.resolve().then(() => (init_prodServer(), prodServer_exports));
|
|
3286
|
-
const config = await initRsbuildConfig({ context, pluginManager });
|
|
3287
|
-
return startProdServer2(context, config, options);
|
|
3288
|
-
},
|
|
3289
3141
|
async build(options) {
|
|
3290
3142
|
const { build: build2 } = await Promise.resolve().then(() => (init_build(), build_exports));
|
|
3291
3143
|
return build2({ context, pluginManager, rsbuildOptions }, options);
|
|
@@ -3317,20 +3169,20 @@ var basic_exports = {};
|
|
|
3317
3169
|
__export(basic_exports, {
|
|
3318
3170
|
pluginBasic: () => pluginBasic
|
|
3319
3171
|
});
|
|
3320
|
-
var
|
|
3172
|
+
var import_node_path11, import_shared24, pluginBasic;
|
|
3321
3173
|
var init_basic = __esm({
|
|
3322
3174
|
"src/plugins/basic.ts"() {
|
|
3323
3175
|
"use strict";
|
|
3324
|
-
|
|
3325
|
-
|
|
3176
|
+
import_node_path11 = __toESM(require("path"));
|
|
3177
|
+
import_shared24 = require("@rsbuild/shared");
|
|
3326
3178
|
pluginBasic = () => ({
|
|
3327
3179
|
name: "rsbuild:basic",
|
|
3328
3180
|
setup(api) {
|
|
3329
3181
|
api.modifyBundlerChain(
|
|
3330
3182
|
(chain, { env, isProd: isProd6, target, bundler, CHAIN_ID: CHAIN_ID3 }) => {
|
|
3331
3183
|
const config = api.getNormalizedConfig();
|
|
3332
|
-
chain.name(
|
|
3333
|
-
chain.devtool((0,
|
|
3184
|
+
chain.name(import_shared24.TARGET_ID_MAP[target]);
|
|
3185
|
+
chain.devtool((0, import_shared24.getJsSourceMap)(config));
|
|
3334
3186
|
chain.context(api.context.rootPath);
|
|
3335
3187
|
chain.mode(isProd6 ? "production" : "development");
|
|
3336
3188
|
chain.merge({
|
|
@@ -3347,13 +3199,13 @@ var init_basic = __esm({
|
|
|
3347
3199
|
});
|
|
3348
3200
|
const isMinimize = isProd6 && config.output.minify !== false;
|
|
3349
3201
|
chain.optimization.minimize(isMinimize);
|
|
3350
|
-
const usingHMR = (0,
|
|
3202
|
+
const usingHMR = (0, import_shared24.isUsingHMR)(config, { target, isProd: isProd6 });
|
|
3351
3203
|
if (usingHMR) {
|
|
3352
3204
|
chain.plugin(CHAIN_ID3.PLUGIN.HMR).use(bundler.HotModuleReplacementPlugin);
|
|
3353
3205
|
}
|
|
3354
3206
|
if (env === "development") {
|
|
3355
3207
|
chain.output.devtoolModuleFilenameTemplate(
|
|
3356
|
-
(info) =>
|
|
3208
|
+
(info) => import_node_path11.default.resolve(info.absoluteResourcePath).replace(/\\/g, "/")
|
|
3357
3209
|
);
|
|
3358
3210
|
}
|
|
3359
3211
|
process.env.RSPACK_CONFIG_VALIDATE = "loose-silent";
|
|
@@ -3371,15 +3223,15 @@ __export(cache_exports, {
|
|
|
3371
3223
|
pluginCache: () => pluginCache
|
|
3372
3224
|
});
|
|
3373
3225
|
async function validateCache(cacheDirectory, buildDependencies) {
|
|
3374
|
-
const configFile = (0,
|
|
3226
|
+
const configFile = (0, import_node_path12.join)(cacheDirectory, "buildDependencies.json");
|
|
3375
3227
|
if (await isFileExists(configFile)) {
|
|
3376
|
-
const prevBuildDependencies = await
|
|
3228
|
+
const prevBuildDependencies = await import_shared25.fse.readJSON(configFile);
|
|
3377
3229
|
if (JSON.stringify(prevBuildDependencies) === JSON.stringify(buildDependencies)) {
|
|
3378
3230
|
return;
|
|
3379
3231
|
}
|
|
3380
|
-
await
|
|
3232
|
+
await import_shared25.fse.remove(cacheDirectory);
|
|
3381
3233
|
}
|
|
3382
|
-
await
|
|
3234
|
+
await import_shared25.fse.outputJSON(configFile, buildDependencies);
|
|
3383
3235
|
}
|
|
3384
3236
|
function getDigestHash(digest) {
|
|
3385
3237
|
const fsHash = import_node_crypto.default.createHash("md5");
|
|
@@ -3388,13 +3240,13 @@ function getDigestHash(digest) {
|
|
|
3388
3240
|
}
|
|
3389
3241
|
function getCacheDirectory({ cacheDirectory }, context) {
|
|
3390
3242
|
if (cacheDirectory) {
|
|
3391
|
-
return (0,
|
|
3243
|
+
return (0, import_node_path12.isAbsolute)(cacheDirectory) ? cacheDirectory : (0, import_node_path12.join)(context.rootPath, cacheDirectory);
|
|
3392
3244
|
}
|
|
3393
|
-
return (0,
|
|
3245
|
+
return (0, import_node_path12.join)(context.cachePath, context.bundlerType);
|
|
3394
3246
|
}
|
|
3395
3247
|
async function getBuildDependencies(context, config) {
|
|
3396
|
-
const rootPackageJson = (0,
|
|
3397
|
-
const browserslistConfig = (0,
|
|
3248
|
+
const rootPackageJson = (0, import_node_path12.join)(context.rootPath, "package.json");
|
|
3249
|
+
const browserslistConfig = (0, import_node_path12.join)(context.rootPath, ".browserslistrc");
|
|
3398
3250
|
const buildDependencies = {};
|
|
3399
3251
|
if (await isFileExists(rootPackageJson)) {
|
|
3400
3252
|
buildDependencies.packageJson = [rootPackageJson];
|
|
@@ -3410,7 +3262,7 @@ async function getBuildDependencies(context, config) {
|
|
|
3410
3262
|
}
|
|
3411
3263
|
const tailwindExts = ["ts", "js", "cjs", "mjs"];
|
|
3412
3264
|
const configs = tailwindExts.map(
|
|
3413
|
-
(ext) => (0,
|
|
3265
|
+
(ext) => (0, import_node_path12.join)(context.rootPath, `tailwind.config.${ext}`)
|
|
3414
3266
|
);
|
|
3415
3267
|
const tailwindConfig = findExists(configs);
|
|
3416
3268
|
if (tailwindConfig) {
|
|
@@ -3418,13 +3270,13 @@ async function getBuildDependencies(context, config) {
|
|
|
3418
3270
|
}
|
|
3419
3271
|
return buildDependencies;
|
|
3420
3272
|
}
|
|
3421
|
-
var import_node_crypto,
|
|
3273
|
+
var import_node_crypto, import_node_path12, import_shared25, pluginCache;
|
|
3422
3274
|
var init_cache = __esm({
|
|
3423
3275
|
"src/plugins/cache.ts"() {
|
|
3424
3276
|
"use strict";
|
|
3425
3277
|
import_node_crypto = __toESM(require("crypto"));
|
|
3426
|
-
|
|
3427
|
-
|
|
3278
|
+
import_node_path12 = require("path");
|
|
3279
|
+
import_shared25 = require("@rsbuild/shared");
|
|
3428
3280
|
init_helpers();
|
|
3429
3281
|
pluginCache = () => ({
|
|
3430
3282
|
name: "rsbuild:cache",
|
|
@@ -3464,11 +3316,11 @@ var target_exports = {};
|
|
|
3464
3316
|
__export(target_exports, {
|
|
3465
3317
|
pluginTarget: () => pluginTarget
|
|
3466
3318
|
});
|
|
3467
|
-
var
|
|
3319
|
+
var import_shared26, pluginTarget;
|
|
3468
3320
|
var init_target = __esm({
|
|
3469
3321
|
"src/plugins/target.ts"() {
|
|
3470
3322
|
"use strict";
|
|
3471
|
-
|
|
3323
|
+
import_shared26 = require("@rsbuild/shared");
|
|
3472
3324
|
pluginTarget = () => ({
|
|
3473
3325
|
name: "rsbuild:target",
|
|
3474
3326
|
setup(api) {
|
|
@@ -3480,12 +3332,12 @@ var init_target = __esm({
|
|
|
3480
3332
|
return;
|
|
3481
3333
|
}
|
|
3482
3334
|
const config = api.getNormalizedConfig();
|
|
3483
|
-
const browserslist = await (0,
|
|
3335
|
+
const browserslist = await (0, import_shared26.getBrowserslistWithDefault)(
|
|
3484
3336
|
api.context.rootPath,
|
|
3485
3337
|
config,
|
|
3486
3338
|
target
|
|
3487
3339
|
);
|
|
3488
|
-
const esVersion = (0,
|
|
3340
|
+
const esVersion = (0, import_shared26.browserslistToESVersion)(browserslist);
|
|
3489
3341
|
if (target === "web-worker" || target === "service-worker") {
|
|
3490
3342
|
chain.target(["webworker", `es${esVersion}`]);
|
|
3491
3343
|
return;
|
|
@@ -3532,7 +3384,7 @@ async function applyCSSRule({
|
|
|
3532
3384
|
utils: { target, isProd: isProd6, CHAIN_ID: CHAIN_ID3 },
|
|
3533
3385
|
importLoaders = 1
|
|
3534
3386
|
}) {
|
|
3535
|
-
const browserslist = await (0,
|
|
3387
|
+
const browserslist = await (0, import_shared27.getBrowserslistWithDefault)(
|
|
3536
3388
|
context.rootPath,
|
|
3537
3389
|
config,
|
|
3538
3390
|
target
|
|
@@ -3549,14 +3401,14 @@ async function applyCSSRule({
|
|
|
3549
3401
|
if (enableExtractCSS) {
|
|
3550
3402
|
rule.use(CHAIN_ID3.USE.MINI_CSS_EXTRACT).loader(getCssExtractPlugin().loader).options(config.tools.cssExtract.loaderOptions).end();
|
|
3551
3403
|
} else {
|
|
3552
|
-
const styleLoaderOptions = (0,
|
|
3404
|
+
const styleLoaderOptions = (0, import_shared27.reduceConfigs)({
|
|
3553
3405
|
initial: {},
|
|
3554
3406
|
config: config.tools.styleLoader
|
|
3555
3407
|
});
|
|
3556
3408
|
rule.use(CHAIN_ID3.USE.STYLE).loader(getCompiledPath("style-loader")).options(styleLoaderOptions).end();
|
|
3557
3409
|
}
|
|
3558
3410
|
} else {
|
|
3559
|
-
rule.use(CHAIN_ID3.USE.IGNORE_CSS).loader(
|
|
3411
|
+
rule.use(CHAIN_ID3.USE.IGNORE_CSS).loader(import_node_path13.default.join(LOADER_PATH, "ignoreCssLoader.cjs")).end();
|
|
3560
3412
|
}
|
|
3561
3413
|
rule.use(CHAIN_ID3.USE.CSS).loader(getCompiledPath("css-loader")).options(cssLoaderOptions).end();
|
|
3562
3414
|
if (target === "web") {
|
|
@@ -3570,12 +3422,12 @@ async function applyCSSRule({
|
|
|
3570
3422
|
rule.merge({ sideEffects: true });
|
|
3571
3423
|
rule.resolve.preferRelative(true);
|
|
3572
3424
|
}
|
|
3573
|
-
var
|
|
3425
|
+
var import_node_path13, import_shared27, enableNativeCss, isUseCssExtract, getCSSModulesLocalIdentName, normalizeCssLoaderOptions, userPostcssrcCache, applyAutoprefixer, getPostcssLoaderOptions, getCSSLoaderOptions, pluginCss;
|
|
3574
3426
|
var init_css = __esm({
|
|
3575
3427
|
"src/plugins/css.ts"() {
|
|
3576
3428
|
"use strict";
|
|
3577
|
-
|
|
3578
|
-
|
|
3429
|
+
import_node_path13 = __toESM(require("path"));
|
|
3430
|
+
import_shared27 = require("@rsbuild/shared");
|
|
3579
3431
|
init_constants();
|
|
3580
3432
|
init_helpers();
|
|
3581
3433
|
init_pluginHelper();
|
|
@@ -3609,17 +3461,17 @@ var init_css = __esm({
|
|
|
3609
3461
|
userPostcssrcCache = /* @__PURE__ */ new Map();
|
|
3610
3462
|
applyAutoprefixer = async (plugins, browserslist, config) => {
|
|
3611
3463
|
const pluginObjects = plugins.map(
|
|
3612
|
-
(plugin) => (0,
|
|
3464
|
+
(plugin) => (0, import_shared27.isFunction)(plugin) ? plugin({}) : plugin
|
|
3613
3465
|
);
|
|
3614
3466
|
const hasAutoprefixer = pluginObjects.some((pluginObject) => {
|
|
3615
|
-
if ((0,
|
|
3467
|
+
if ((0, import_shared27.isPlainObject)(pluginObject) && "postcssPlugin" in pluginObject) {
|
|
3616
3468
|
return pluginObject.postcssPlugin === "autoprefixer";
|
|
3617
3469
|
}
|
|
3618
3470
|
return false;
|
|
3619
3471
|
});
|
|
3620
3472
|
if (!hasAutoprefixer) {
|
|
3621
3473
|
const { default: autoprefixer } = await import("@rsbuild/shared/autoprefixer");
|
|
3622
|
-
const autoprefixerOptions = (0,
|
|
3474
|
+
const autoprefixerOptions = (0, import_shared27.reduceConfigs)({
|
|
3623
3475
|
initial: {
|
|
3624
3476
|
flexbox: "no-2009",
|
|
3625
3477
|
overrideBrowserslist: browserslist
|
|
@@ -3659,7 +3511,7 @@ var init_css = __esm({
|
|
|
3659
3511
|
},
|
|
3660
3512
|
sourceMap: config.output.sourceMap.css
|
|
3661
3513
|
};
|
|
3662
|
-
const mergedConfig = (0,
|
|
3514
|
+
const mergedConfig = (0, import_shared27.reduceConfigsWithContext)({
|
|
3663
3515
|
initial: defaultPostcssConfig,
|
|
3664
3516
|
config: config.tools.postcss,
|
|
3665
3517
|
ctx: utils
|
|
@@ -3686,10 +3538,10 @@ var init_css = __esm({
|
|
|
3686
3538
|
},
|
|
3687
3539
|
sourceMap: config.output.sourceMap.css
|
|
3688
3540
|
};
|
|
3689
|
-
const mergedCssLoaderOptions = (0,
|
|
3541
|
+
const mergedCssLoaderOptions = (0, import_shared27.reduceConfigs)({
|
|
3690
3542
|
initial: defaultOptions2,
|
|
3691
3543
|
config: config.tools.cssLoader,
|
|
3692
|
-
mergeFn:
|
|
3544
|
+
mergeFn: import_shared27.deepmerge
|
|
3693
3545
|
});
|
|
3694
3546
|
const cssLoaderOptions = normalizeCssLoaderOptions(
|
|
3695
3547
|
mergedCssLoaderOptions,
|
|
@@ -3734,7 +3586,7 @@ function getPublicPath({
|
|
|
3734
3586
|
context
|
|
3735
3587
|
}) {
|
|
3736
3588
|
const { dev, output } = config;
|
|
3737
|
-
let publicPath =
|
|
3589
|
+
let publicPath = import_shared28.DEFAULT_ASSET_PREFIX;
|
|
3738
3590
|
if (isProd6) {
|
|
3739
3591
|
if (typeof output.assetPrefix === "string") {
|
|
3740
3592
|
publicPath = output.assetPrefix;
|
|
@@ -3754,12 +3606,12 @@ function getPublicPath({
|
|
|
3754
3606
|
}
|
|
3755
3607
|
return formatPublicPath(publicPath);
|
|
3756
3608
|
}
|
|
3757
|
-
var
|
|
3609
|
+
var import_node_path14, import_shared28, import_core5, pluginOutput;
|
|
3758
3610
|
var init_output = __esm({
|
|
3759
3611
|
"src/plugins/output.ts"() {
|
|
3760
3612
|
"use strict";
|
|
3761
|
-
|
|
3762
|
-
|
|
3613
|
+
import_node_path14 = require("path");
|
|
3614
|
+
import_shared28 = require("@rsbuild/shared");
|
|
3763
3615
|
import_core5 = require("@rspack/core");
|
|
3764
3616
|
init_constants();
|
|
3765
3617
|
init_helpers();
|
|
@@ -3776,31 +3628,31 @@ var init_output = __esm({
|
|
|
3776
3628
|
isProd: isProd6,
|
|
3777
3629
|
context: api.context
|
|
3778
3630
|
});
|
|
3779
|
-
const jsPath = (0,
|
|
3780
|
-
const jsAsyncPath = (0,
|
|
3781
|
-
const jsFilename = (0,
|
|
3631
|
+
const jsPath = (0, import_shared28.getDistPath)(config, "js");
|
|
3632
|
+
const jsAsyncPath = (0, import_shared28.getDistPath)(config, "jsAsync");
|
|
3633
|
+
const jsFilename = (0, import_shared28.getFilename)(config, "js", isProd6);
|
|
3782
3634
|
const isJsFilenameFn = typeof jsFilename === "function";
|
|
3783
3635
|
chain.output.path(api.context.distPath).filename(
|
|
3784
3636
|
isJsFilenameFn ? (...args) => {
|
|
3785
3637
|
const name = jsFilename(...args);
|
|
3786
|
-
return
|
|
3787
|
-
} :
|
|
3638
|
+
return import_node_path14.posix.join(jsPath, name);
|
|
3639
|
+
} : import_node_path14.posix.join(jsPath, jsFilename)
|
|
3788
3640
|
).chunkFilename(
|
|
3789
3641
|
isJsFilenameFn ? (...args) => {
|
|
3790
3642
|
const name = jsFilename(...args);
|
|
3791
|
-
return
|
|
3792
|
-
} :
|
|
3643
|
+
return import_node_path14.posix.join(jsAsyncPath, name);
|
|
3644
|
+
} : import_node_path14.posix.join(jsAsyncPath, jsFilename)
|
|
3793
3645
|
).publicPath(publicPath).pathinfo(false).hashFunction("xxhash64");
|
|
3794
3646
|
if (isServer) {
|
|
3795
|
-
const serverPath = (0,
|
|
3796
|
-
chain.output.path(
|
|
3647
|
+
const serverPath = (0, import_shared28.getDistPath)(config, "server");
|
|
3648
|
+
chain.output.path(import_node_path14.posix.join(api.context.distPath, serverPath)).filename("[name].js").chunkFilename("[name].js").library({
|
|
3797
3649
|
...chain.output.get("library") || {},
|
|
3798
3650
|
type: "commonjs2"
|
|
3799
3651
|
});
|
|
3800
3652
|
}
|
|
3801
3653
|
if (isServiceWorker) {
|
|
3802
|
-
const workerPath = (0,
|
|
3803
|
-
const filename =
|
|
3654
|
+
const workerPath = (0, import_shared28.getDistPath)(config, "worker");
|
|
3655
|
+
const filename = import_node_path14.posix.join(workerPath, "[name].js");
|
|
3804
3656
|
chain.output.filename(filename).chunkFilename(filename);
|
|
3805
3657
|
}
|
|
3806
3658
|
if (config.output.copy && api.context.bundlerType === "rspack") {
|
|
@@ -3810,13 +3662,13 @@ var init_output = __esm({
|
|
|
3810
3662
|
}
|
|
3811
3663
|
if (isUseCssExtract(config, target)) {
|
|
3812
3664
|
const extractPluginOptions = config.tools.cssExtract.pluginOptions;
|
|
3813
|
-
const cssPath = (0,
|
|
3814
|
-
const cssFilename = (0,
|
|
3815
|
-
const cssAsyncPath = (0,
|
|
3665
|
+
const cssPath = (0, import_shared28.getDistPath)(config, "css");
|
|
3666
|
+
const cssFilename = (0, import_shared28.getFilename)(config, "css", isProd6);
|
|
3667
|
+
const cssAsyncPath = (0, import_shared28.getDistPath)(config, "cssAsync");
|
|
3816
3668
|
chain.plugin(CHAIN_ID3.PLUGIN.MINI_CSS_EXTRACT).use(getCssExtractPlugin(), [
|
|
3817
3669
|
{
|
|
3818
|
-
filename:
|
|
3819
|
-
chunkFilename:
|
|
3670
|
+
filename: import_node_path14.posix.join(cssPath, cssFilename),
|
|
3671
|
+
chunkFilename: import_node_path14.posix.join(cssAsyncPath, cssFilename),
|
|
3820
3672
|
...extractPluginOptions
|
|
3821
3673
|
}
|
|
3822
3674
|
]);
|
|
@@ -3861,13 +3713,13 @@ function applyAlias({
|
|
|
3861
3713
|
if (!alias) {
|
|
3862
3714
|
return;
|
|
3863
3715
|
}
|
|
3864
|
-
const mergedAlias = (0,
|
|
3716
|
+
const mergedAlias = (0, import_shared29.reduceConfigsWithContext)({
|
|
3865
3717
|
initial: {},
|
|
3866
3718
|
config: alias,
|
|
3867
3719
|
ctx: { target }
|
|
3868
3720
|
});
|
|
3869
3721
|
for (const name of Object.keys(mergedAlias)) {
|
|
3870
|
-
const values = (0,
|
|
3722
|
+
const values = (0, import_shared29.castArray)(mergedAlias[name]);
|
|
3871
3723
|
const formattedValues = values.map((value) => {
|
|
3872
3724
|
if (typeof value === "string" && value.startsWith(".")) {
|
|
3873
3725
|
return ensureAbsolutePath(rootPath, value);
|
|
@@ -3880,11 +3732,11 @@ function applyAlias({
|
|
|
3880
3732
|
);
|
|
3881
3733
|
}
|
|
3882
3734
|
}
|
|
3883
|
-
var
|
|
3735
|
+
var import_shared29, pluginResolve;
|
|
3884
3736
|
var init_resolve = __esm({
|
|
3885
3737
|
"src/plugins/resolve.ts"() {
|
|
3886
3738
|
"use strict";
|
|
3887
|
-
|
|
3739
|
+
import_shared29 = require("@rsbuild/shared");
|
|
3888
3740
|
init_helpers();
|
|
3889
3741
|
pluginResolve = () => ({
|
|
3890
3742
|
name: "rsbuild:resolve",
|
|
@@ -3932,7 +3784,7 @@ async function printHeader(longestFileLength, longestLabelLength) {
|
|
|
3932
3784
|
}
|
|
3933
3785
|
return `${prev + curLabel} `;
|
|
3934
3786
|
}, " ");
|
|
3935
|
-
|
|
3787
|
+
import_shared31.logger.log(import_shared31.color.bold(import_shared31.color.blue(headerRow)));
|
|
3936
3788
|
}
|
|
3937
3789
|
async function printFileSizes(config, stats, rootPath) {
|
|
3938
3790
|
if (config.detail === false && config.total === false) {
|
|
@@ -3941,13 +3793,13 @@ async function printFileSizes(config, stats, rootPath) {
|
|
|
3941
3793
|
const { default: gzipSize } = await import("@rsbuild/shared/gzip-size");
|
|
3942
3794
|
const formatAsset = (asset, distPath, distFolder) => {
|
|
3943
3795
|
const fileName = asset.name.split("?")[0];
|
|
3944
|
-
const contents =
|
|
3796
|
+
const contents = import_shared30.fse.readFileSync(import_node_path15.default.join(distPath, fileName));
|
|
3945
3797
|
const size = contents.length;
|
|
3946
3798
|
const gzippedSize = gzipSize.sync(contents);
|
|
3947
3799
|
return {
|
|
3948
3800
|
size,
|
|
3949
|
-
folder:
|
|
3950
|
-
name:
|
|
3801
|
+
folder: import_node_path15.default.join(distFolder, import_node_path15.default.dirname(fileName)),
|
|
3802
|
+
name: import_node_path15.default.basename(fileName),
|
|
3951
3803
|
gzippedSize,
|
|
3952
3804
|
sizeLabel: calcFileSize(size),
|
|
3953
3805
|
gzipSizeLabel: getAssetColor(gzippedSize)(calcFileSize(gzippedSize))
|
|
@@ -3974,7 +3826,7 @@ async function printFileSizes(config, stats, rootPath) {
|
|
|
3974
3826
|
const filteredAssets = origin.assets.filter(
|
|
3975
3827
|
(asset) => filterAsset(asset.name)
|
|
3976
3828
|
);
|
|
3977
|
-
const distFolder =
|
|
3829
|
+
const distFolder = import_node_path15.default.relative(rootPath, distPath);
|
|
3978
3830
|
return filteredAssets.map(
|
|
3979
3831
|
(asset) => formatAsset(asset, distPath, distFolder)
|
|
3980
3832
|
);
|
|
@@ -3983,10 +3835,10 @@ async function printFileSizes(config, stats, rootPath) {
|
|
|
3983
3835
|
return;
|
|
3984
3836
|
}
|
|
3985
3837
|
assets.sort((a, b) => a.size - b.size);
|
|
3986
|
-
|
|
3838
|
+
import_shared31.logger.info("Production file sizes:\n");
|
|
3987
3839
|
const longestLabelLength = Math.max(...assets.map((a) => a.sizeLabel.length));
|
|
3988
3840
|
const longestFileLength = Math.max(
|
|
3989
|
-
...assets.map((a) => (a.folder +
|
|
3841
|
+
...assets.map((a) => (a.folder + import_node_path15.default.sep + a.name).length)
|
|
3990
3842
|
);
|
|
3991
3843
|
if (config.detail !== false) {
|
|
3992
3844
|
printHeader(longestFileLength, longestLabelLength);
|
|
@@ -3996,7 +3848,7 @@ async function printFileSizes(config, stats, rootPath) {
|
|
|
3996
3848
|
for (const asset of assets) {
|
|
3997
3849
|
let { sizeLabel } = asset;
|
|
3998
3850
|
const { name, folder, gzipSizeLabel } = asset;
|
|
3999
|
-
const fileNameLength = (folder +
|
|
3851
|
+
const fileNameLength = (folder + import_node_path15.default.sep + name).length;
|
|
4000
3852
|
const sizeLength = sizeLabel.length;
|
|
4001
3853
|
totalSize += asset.size;
|
|
4002
3854
|
totalGzipSize += asset.gzippedSize;
|
|
@@ -4005,60 +3857,60 @@ async function printFileSizes(config, stats, rootPath) {
|
|
|
4005
3857
|
const rightPadding = " ".repeat(longestLabelLength - sizeLength);
|
|
4006
3858
|
sizeLabel += rightPadding;
|
|
4007
3859
|
}
|
|
4008
|
-
let fileNameLabel =
|
|
3860
|
+
let fileNameLabel = import_shared31.color.dim(asset.folder + import_node_path15.default.sep) + coloringAssetName(asset.name);
|
|
4009
3861
|
if (fileNameLength < longestFileLength) {
|
|
4010
3862
|
const rightPadding = " ".repeat(longestFileLength - fileNameLength);
|
|
4011
3863
|
fileNameLabel += rightPadding;
|
|
4012
3864
|
}
|
|
4013
|
-
|
|
3865
|
+
import_shared31.logger.log(` ${fileNameLabel} ${sizeLabel} ${gzipSizeLabel}`);
|
|
4014
3866
|
}
|
|
4015
3867
|
}
|
|
4016
3868
|
if (config.total !== false) {
|
|
4017
|
-
const totalSizeLabel = `${
|
|
4018
|
-
|
|
3869
|
+
const totalSizeLabel = `${import_shared31.color.bold(
|
|
3870
|
+
import_shared31.color.blue("Total size:")
|
|
4019
3871
|
)} ${calcFileSize(totalSize)}`;
|
|
4020
|
-
const gzippedSizeLabel = `${
|
|
4021
|
-
|
|
3872
|
+
const gzippedSizeLabel = `${import_shared31.color.bold(
|
|
3873
|
+
import_shared31.color.blue("Gzipped size:")
|
|
4022
3874
|
)} ${calcFileSize(totalGzipSize)}`;
|
|
4023
|
-
|
|
3875
|
+
import_shared31.logger.log(`
|
|
4024
3876
|
${totalSizeLabel}
|
|
4025
3877
|
${gzippedSizeLabel}
|
|
4026
3878
|
`);
|
|
4027
3879
|
}
|
|
4028
3880
|
}
|
|
4029
|
-
var
|
|
3881
|
+
var import_node_path15, import_shared30, import_shared31, filterAsset, getAssetColor, calcFileSize, coloringAssetName, pluginFileSize;
|
|
4030
3882
|
var init_fileSize = __esm({
|
|
4031
3883
|
"src/plugins/fileSize.ts"() {
|
|
4032
3884
|
"use strict";
|
|
4033
|
-
|
|
3885
|
+
import_node_path15 = __toESM(require("path"));
|
|
3886
|
+
import_shared30 = require("@rsbuild/shared");
|
|
4034
3887
|
import_shared31 = require("@rsbuild/shared");
|
|
4035
|
-
import_shared32 = require("@rsbuild/shared");
|
|
4036
3888
|
init_constants();
|
|
4037
3889
|
filterAsset = (asset) => !/\.map$/.test(asset) && !/\.LICENSE\.txt$/.test(asset);
|
|
4038
3890
|
getAssetColor = (size) => {
|
|
4039
3891
|
if (size > 300 * 1e3) {
|
|
4040
|
-
return
|
|
3892
|
+
return import_shared31.color.red;
|
|
4041
3893
|
}
|
|
4042
3894
|
if (size > 100 * 1e3) {
|
|
4043
|
-
return
|
|
3895
|
+
return import_shared31.color.yellow;
|
|
4044
3896
|
}
|
|
4045
|
-
return
|
|
3897
|
+
return import_shared31.color.green;
|
|
4046
3898
|
};
|
|
4047
3899
|
calcFileSize = (len) => {
|
|
4048
3900
|
const val = len / 1e3;
|
|
4049
3901
|
return `${val.toFixed(val < 1 ? 2 : 1)} kB`;
|
|
4050
3902
|
};
|
|
4051
3903
|
coloringAssetName = (assetName) => {
|
|
4052
|
-
if (
|
|
4053
|
-
return
|
|
3904
|
+
if (import_shared30.JS_REGEX.test(assetName)) {
|
|
3905
|
+
return import_shared31.color.cyan(assetName);
|
|
4054
3906
|
}
|
|
4055
3907
|
if (CSS_REGEX.test(assetName)) {
|
|
4056
|
-
return
|
|
3908
|
+
return import_shared31.color.yellow(assetName);
|
|
4057
3909
|
}
|
|
4058
3910
|
if (HTML_REGEX.test(assetName)) {
|
|
4059
|
-
return
|
|
3911
|
+
return import_shared31.color.green(assetName);
|
|
4060
3912
|
}
|
|
4061
|
-
return
|
|
3913
|
+
return import_shared31.color.magenta(assetName);
|
|
4062
3914
|
};
|
|
4063
3915
|
pluginFileSize = () => ({
|
|
4064
3916
|
name: "rsbuild:file-size",
|
|
@@ -4080,8 +3932,8 @@ var init_fileSize = __esm({
|
|
|
4080
3932
|
api.context.rootPath
|
|
4081
3933
|
);
|
|
4082
3934
|
} catch (err) {
|
|
4083
|
-
|
|
4084
|
-
|
|
3935
|
+
import_shared31.logger.warn("Failed to print file size.");
|
|
3936
|
+
import_shared31.logger.warn(err);
|
|
4085
3937
|
}
|
|
4086
3938
|
}
|
|
4087
3939
|
});
|
|
@@ -4095,18 +3947,18 @@ var cleanOutput_exports = {};
|
|
|
4095
3947
|
__export(cleanOutput_exports, {
|
|
4096
3948
|
pluginCleanOutput: () => pluginCleanOutput
|
|
4097
3949
|
});
|
|
4098
|
-
var
|
|
3950
|
+
var import_node_path16, import_shared32, emptyDir, addTrailingSep, isStrictSubdir, pluginCleanOutput;
|
|
4099
3951
|
var init_cleanOutput = __esm({
|
|
4100
3952
|
"src/plugins/cleanOutput.ts"() {
|
|
4101
3953
|
"use strict";
|
|
4102
|
-
|
|
4103
|
-
|
|
3954
|
+
import_node_path16 = require("path");
|
|
3955
|
+
import_shared32 = require("@rsbuild/shared");
|
|
4104
3956
|
emptyDir = async (dir) => {
|
|
4105
|
-
if (await
|
|
4106
|
-
await
|
|
3957
|
+
if (await import_shared32.fse.pathExists(dir)) {
|
|
3958
|
+
await import_shared32.fse.emptyDir(dir);
|
|
4107
3959
|
}
|
|
4108
3960
|
};
|
|
4109
|
-
addTrailingSep = (dir) => dir.endsWith(
|
|
3961
|
+
addTrailingSep = (dir) => dir.endsWith(import_node_path16.sep) ? dir : dir + import_node_path16.sep;
|
|
4110
3962
|
isStrictSubdir = (parent, child) => {
|
|
4111
3963
|
const parentDir = addTrailingSep(parent);
|
|
4112
3964
|
const childDir = addTrailingSep(child);
|
|
@@ -4122,14 +3974,14 @@ var init_cleanOutput = __esm({
|
|
|
4122
3974
|
if (cleanDistPath === void 0) {
|
|
4123
3975
|
cleanDistPath = isStrictSubdir(rootPath, distPath);
|
|
4124
3976
|
if (!cleanDistPath) {
|
|
4125
|
-
|
|
3977
|
+
import_shared32.logger.warn(
|
|
4126
3978
|
"The dist path is not a subdir of root path, Rsbuild will not empty it."
|
|
4127
3979
|
);
|
|
4128
|
-
|
|
4129
|
-
`Please set ${
|
|
3980
|
+
import_shared32.logger.warn(
|
|
3981
|
+
`Please set ${import_shared32.color.yellow("`output.cleanDistPath`")} config manually.`
|
|
4130
3982
|
);
|
|
4131
|
-
|
|
4132
|
-
|
|
3983
|
+
import_shared32.logger.warn(`Current root path: ${import_shared32.color.dim(rootPath)}`);
|
|
3984
|
+
import_shared32.logger.warn(`Current dist path: ${import_shared32.color.dim(distPath)}`);
|
|
4133
3985
|
}
|
|
4134
3986
|
}
|
|
4135
3987
|
if (cleanDistPath) {
|
|
@@ -4156,12 +4008,12 @@ function getRegExpForExts(exts) {
|
|
|
4156
4008
|
"i"
|
|
4157
4009
|
);
|
|
4158
4010
|
}
|
|
4159
|
-
var
|
|
4011
|
+
var import_node_path17, import_shared33, chainStaticAssetRule, pluginAsset;
|
|
4160
4012
|
var init_asset = __esm({
|
|
4161
4013
|
"src/plugins/asset.ts"() {
|
|
4162
4014
|
"use strict";
|
|
4163
|
-
|
|
4164
|
-
|
|
4015
|
+
import_node_path17 = __toESM(require("path"));
|
|
4016
|
+
import_shared33 = require("@rsbuild/shared");
|
|
4165
4017
|
init_constants();
|
|
4166
4018
|
chainStaticAssetRule = ({
|
|
4167
4019
|
emit,
|
|
@@ -4191,8 +4043,8 @@ var init_asset = __esm({
|
|
|
4191
4043
|
const config = api.getNormalizedConfig();
|
|
4192
4044
|
const createAssetRule = (assetType, exts, emit2) => {
|
|
4193
4045
|
const regExp = getRegExpForExts(exts);
|
|
4194
|
-
const distDir = (0,
|
|
4195
|
-
const filename = (0,
|
|
4046
|
+
const distDir = (0, import_shared33.getDistPath)(config, assetType);
|
|
4047
|
+
const filename = (0, import_shared33.getFilename)(config, assetType, isProd6);
|
|
4196
4048
|
const { dataUriLimit } = config.output;
|
|
4197
4049
|
const maxSize = typeof dataUriLimit === "number" ? dataUriLimit : dataUriLimit[assetType];
|
|
4198
4050
|
const rule = chain.module.rule(assetType).test(regExp);
|
|
@@ -4200,7 +4052,7 @@ var init_asset = __esm({
|
|
|
4200
4052
|
emit: emit2,
|
|
4201
4053
|
rule,
|
|
4202
4054
|
maxSize,
|
|
4203
|
-
filename:
|
|
4055
|
+
filename: import_node_path17.default.posix.join(distDir, filename),
|
|
4204
4056
|
assetType
|
|
4205
4057
|
});
|
|
4206
4058
|
};
|
|
@@ -4226,24 +4078,24 @@ __export(minimize_exports, {
|
|
|
4226
4078
|
parseMinifyOptions: () => parseMinifyOptions,
|
|
4227
4079
|
pluginMinimize: () => pluginMinimize
|
|
4228
4080
|
});
|
|
4229
|
-
var
|
|
4081
|
+
var import_shared34, import_core6, getSwcMinimizerOptions, parseMinifyOptions, pluginMinimize;
|
|
4230
4082
|
var init_minimize = __esm({
|
|
4231
4083
|
"src/plugins/minimize.ts"() {
|
|
4232
4084
|
"use strict";
|
|
4233
|
-
|
|
4085
|
+
import_shared34 = require("@rsbuild/shared");
|
|
4234
4086
|
import_core6 = require("@rspack/core");
|
|
4235
4087
|
getSwcMinimizerOptions = (config) => {
|
|
4236
4088
|
const options = {};
|
|
4237
4089
|
const { removeConsole } = config.performance;
|
|
4238
4090
|
if (removeConsole === true) {
|
|
4239
4091
|
options.compress = {
|
|
4240
|
-
...(0,
|
|
4092
|
+
...(0, import_shared34.isObject)(options.compress) ? options.compress : {},
|
|
4241
4093
|
drop_console: true
|
|
4242
4094
|
};
|
|
4243
4095
|
} else if (Array.isArray(removeConsole)) {
|
|
4244
4096
|
const pureFuncs = removeConsole.map((method) => `console.${method}`);
|
|
4245
4097
|
options.compress = {
|
|
4246
|
-
...(0,
|
|
4098
|
+
...(0, import_shared34.isObject)(options.compress) ? options.compress : {},
|
|
4247
4099
|
pure_funcs: pureFuncs
|
|
4248
4100
|
};
|
|
4249
4101
|
}
|
|
@@ -4266,7 +4118,7 @@ var init_minimize = __esm({
|
|
|
4266
4118
|
options.format.asciiOnly = config.output.charset === "ascii";
|
|
4267
4119
|
const jsOptions = parseMinifyOptions(config).jsOptions;
|
|
4268
4120
|
if (jsOptions) {
|
|
4269
|
-
return (0,
|
|
4121
|
+
return (0, import_shared34.deepmerge)(options, jsOptions);
|
|
4270
4122
|
}
|
|
4271
4123
|
return options;
|
|
4272
4124
|
};
|
|
@@ -4313,10 +4165,10 @@ var init_minimize = __esm({
|
|
|
4313
4165
|
const { SwcJsMinimizerRspackPlugin, SwcCssMinimizerRspackPlugin } = import_core6.rspack;
|
|
4314
4166
|
const { minifyJs, minifyCss } = parseMinifyOptions(config);
|
|
4315
4167
|
if (minifyJs) {
|
|
4316
|
-
chain.optimization.minimizer(
|
|
4168
|
+
chain.optimization.minimizer(import_shared34.CHAIN_ID.MINIMIZER.JS).use(SwcJsMinimizerRspackPlugin, [getSwcMinimizerOptions(config)]).end();
|
|
4317
4169
|
}
|
|
4318
4170
|
if (minifyCss) {
|
|
4319
|
-
chain.optimization.minimizer(
|
|
4171
|
+
chain.optimization.minimizer(import_shared34.CHAIN_ID.MINIMIZER.CSS).use(SwcCssMinimizerRspackPlugin, []).end();
|
|
4320
4172
|
}
|
|
4321
4173
|
});
|
|
4322
4174
|
}
|
|
@@ -4333,11 +4185,12 @@ __export(HtmlBasicPlugin_exports, {
|
|
|
4333
4185
|
VOID_TAGS: () => VOID_TAGS,
|
|
4334
4186
|
hasTitle: () => hasTitle
|
|
4335
4187
|
});
|
|
4336
|
-
var
|
|
4188
|
+
var import_shared35, VOID_TAGS, HEAD_TAGS, FILE_ATTRS, hasTitle, getTagPriority, formatBasicTag, fromBasicTag, formatTags, applyTagConfig, addTitleTag, addFavicon, HtmlBasicPlugin;
|
|
4337
4189
|
var init_HtmlBasicPlugin = __esm({
|
|
4338
4190
|
"src/rspack/HtmlBasicPlugin.ts"() {
|
|
4339
4191
|
"use strict";
|
|
4340
|
-
|
|
4192
|
+
import_shared35 = require("@rsbuild/shared");
|
|
4193
|
+
init_helpers();
|
|
4341
4194
|
init_pluginHelper();
|
|
4342
4195
|
VOID_TAGS = [
|
|
4343
4196
|
"area",
|
|
@@ -4412,9 +4265,9 @@ var init_HtmlBasicPlugin = __esm({
|
|
|
4412
4265
|
if (typeof optPublicPath === "function") {
|
|
4413
4266
|
filename = optPublicPath(filename, data.publicPath);
|
|
4414
4267
|
} else if (typeof optPublicPath === "string") {
|
|
4415
|
-
filename = (
|
|
4268
|
+
filename = ensureAssetPrefix(filename, optPublicPath);
|
|
4416
4269
|
} else if (optPublicPath !== false) {
|
|
4417
|
-
filename = (
|
|
4270
|
+
filename = ensureAssetPrefix(filename, data.publicPath);
|
|
4418
4271
|
}
|
|
4419
4272
|
const optHash = tag.hash ?? tagConfig.hash;
|
|
4420
4273
|
if (typeof optHash === "function") {
|
|
@@ -4448,7 +4301,7 @@ var init_HtmlBasicPlugin = __esm({
|
|
|
4448
4301
|
publicPath: data.publicPath
|
|
4449
4302
|
};
|
|
4450
4303
|
for (const item of tagConfig.tags) {
|
|
4451
|
-
if ((0,
|
|
4304
|
+
if ((0, import_shared35.isFunction)(item)) {
|
|
4452
4305
|
tags = item(tags, utils) || tags;
|
|
4453
4306
|
} else {
|
|
4454
4307
|
tags.push(item);
|
|
@@ -4457,7 +4310,7 @@ var init_HtmlBasicPlugin = __esm({
|
|
|
4457
4310
|
(tag1, tag2) => getTagPriority(tag1, tagConfig) - getTagPriority(tag2, tagConfig)
|
|
4458
4311
|
);
|
|
4459
4312
|
}
|
|
4460
|
-
const [headTags, bodyTags] = (0,
|
|
4313
|
+
const [headTags, bodyTags] = (0, import_shared35.partition)(
|
|
4461
4314
|
tags,
|
|
4462
4315
|
(tag) => tag.head ?? HEAD_TAGS.includes(tag.tag)
|
|
4463
4316
|
);
|
|
@@ -4539,13 +4392,14 @@ var HtmlAppIconPlugin_exports = {};
|
|
|
4539
4392
|
__export(HtmlAppIconPlugin_exports, {
|
|
4540
4393
|
HtmlAppIconPlugin: () => HtmlAppIconPlugin
|
|
4541
4394
|
});
|
|
4542
|
-
var import_node_fs4,
|
|
4395
|
+
var import_node_fs4, import_node_path18, import_shared36, HtmlAppIconPlugin;
|
|
4543
4396
|
var init_HtmlAppIconPlugin = __esm({
|
|
4544
4397
|
"src/rspack/HtmlAppIconPlugin.ts"() {
|
|
4545
4398
|
"use strict";
|
|
4546
4399
|
import_node_fs4 = __toESM(require("fs"));
|
|
4547
|
-
|
|
4548
|
-
|
|
4400
|
+
import_node_path18 = require("path");
|
|
4401
|
+
import_shared36 = require("@rsbuild/shared");
|
|
4402
|
+
init_helpers();
|
|
4549
4403
|
init_pluginHelper();
|
|
4550
4404
|
HtmlAppIconPlugin = class {
|
|
4551
4405
|
constructor(options) {
|
|
@@ -4562,17 +4416,17 @@ var init_HtmlAppIconPlugin = __esm({
|
|
|
4562
4416
|
`[${this.name}] Can not find the app icon, please check if the '${this.iconPath}' file exists'.`
|
|
4563
4417
|
);
|
|
4564
4418
|
}
|
|
4565
|
-
const iconRelativePath =
|
|
4419
|
+
const iconRelativePath = import_node_path18.posix.join(this.distDir, (0, import_node_path18.basename)(this.iconPath));
|
|
4566
4420
|
compiler.hooks.compilation.tap(this.name, (compilation) => {
|
|
4567
4421
|
getHTMLPlugin().getHooks(compilation).alterAssetTagGroups.tap(this.name, (data) => {
|
|
4568
|
-
const publicPath = (0,
|
|
4422
|
+
const publicPath = (0, import_shared36.getPublicPathFromCompiler)(compiler);
|
|
4569
4423
|
data.headTags.unshift({
|
|
4570
4424
|
tagName: "link",
|
|
4571
4425
|
voidTag: true,
|
|
4572
4426
|
attributes: {
|
|
4573
4427
|
rel: "apple-touch-icon",
|
|
4574
4428
|
sizes: "180*180",
|
|
4575
|
-
href: (
|
|
4429
|
+
href: ensureAssetPrefix(iconRelativePath, publicPath)
|
|
4576
4430
|
},
|
|
4577
4431
|
meta: {}
|
|
4578
4432
|
});
|
|
@@ -4664,25 +4518,25 @@ async function getHtmlMinifyOptions(isProd6, config) {
|
|
|
4664
4518
|
minifyURLs: true
|
|
4665
4519
|
};
|
|
4666
4520
|
const htmlMinifyOptions = parseMinifyOptions(config).htmlOptions;
|
|
4667
|
-
return typeof htmlMinifyOptions === "object" ? (0,
|
|
4521
|
+
return typeof htmlMinifyOptions === "object" ? (0, import_shared37.deepmerge)(htmlMinifyDefaultOptions, htmlMinifyOptions) : htmlMinifyDefaultOptions;
|
|
4668
4522
|
}
|
|
4669
4523
|
function getTitle(entryName, config) {
|
|
4670
|
-
return (0,
|
|
4524
|
+
return (0, import_shared37.reduceConfigsMergeContext)({
|
|
4671
4525
|
initial: "",
|
|
4672
4526
|
config: config.html.title,
|
|
4673
4527
|
ctx: { entryName }
|
|
4674
4528
|
});
|
|
4675
4529
|
}
|
|
4676
4530
|
function getInject(entryName, config) {
|
|
4677
|
-
return (0,
|
|
4531
|
+
return (0, import_shared37.reduceConfigsMergeContext)({
|
|
4678
4532
|
initial: "head",
|
|
4679
4533
|
config: config.html.inject,
|
|
4680
4534
|
ctx: { entryName }
|
|
4681
4535
|
});
|
|
4682
4536
|
}
|
|
4683
4537
|
async function getTemplate(entryName, config, rootPath) {
|
|
4684
|
-
const DEFAULT_TEMPLATE =
|
|
4685
|
-
const templatePath = (0,
|
|
4538
|
+
const DEFAULT_TEMPLATE = import_node_path19.default.resolve(STATIC_PATH, "template.html");
|
|
4539
|
+
const templatePath = (0, import_shared37.reduceConfigsMergeContext)({
|
|
4686
4540
|
initial: DEFAULT_TEMPLATE,
|
|
4687
4541
|
config: config.html.template,
|
|
4688
4542
|
ctx: { entryName }
|
|
@@ -4692,32 +4546,32 @@ async function getTemplate(entryName, config, rootPath) {
|
|
|
4692
4546
|
templatePath
|
|
4693
4547
|
};
|
|
4694
4548
|
}
|
|
4695
|
-
const absolutePath = (0,
|
|
4549
|
+
const absolutePath = (0, import_node_path19.isAbsolute)(templatePath) ? templatePath : import_node_path19.default.resolve(rootPath, templatePath);
|
|
4696
4550
|
if (!existTemplatePath.includes(absolutePath)) {
|
|
4697
4551
|
if (!await isFileExists(absolutePath)) {
|
|
4698
4552
|
throw new Error(
|
|
4699
|
-
`Failed to resolve HTML template, please check if the file exists: ${
|
|
4553
|
+
`Failed to resolve HTML template, please check if the file exists: ${import_shared37.color.cyan(
|
|
4700
4554
|
absolutePath
|
|
4701
4555
|
)}`
|
|
4702
4556
|
);
|
|
4703
4557
|
}
|
|
4704
4558
|
existTemplatePath.push(absolutePath);
|
|
4705
4559
|
}
|
|
4706
|
-
const templateContent = await
|
|
4560
|
+
const templateContent = await import_shared37.fse.readFile(absolutePath, "utf-8");
|
|
4707
4561
|
return {
|
|
4708
4562
|
templatePath: absolutePath,
|
|
4709
4563
|
templateContent
|
|
4710
4564
|
};
|
|
4711
4565
|
}
|
|
4712
4566
|
function getFavicon(entryName, config) {
|
|
4713
|
-
return (0,
|
|
4567
|
+
return (0, import_shared37.reduceConfigsMergeContext)({
|
|
4714
4568
|
initial: "",
|
|
4715
4569
|
config: config.html.favicon,
|
|
4716
4570
|
ctx: { entryName }
|
|
4717
4571
|
});
|
|
4718
4572
|
}
|
|
4719
4573
|
function getMetaTags(entryName, config, templateContent) {
|
|
4720
|
-
const metaTags = (0,
|
|
4574
|
+
const metaTags = (0, import_shared37.reduceConfigsMergeContext)({
|
|
4721
4575
|
initial: {},
|
|
4722
4576
|
config: config.html.meta,
|
|
4723
4577
|
ctx: { entryName }
|
|
@@ -4745,7 +4599,7 @@ function getTemplateParameters(entryName, config, assetPrefix) {
|
|
|
4745
4599
|
options: pluginOptions
|
|
4746
4600
|
}
|
|
4747
4601
|
};
|
|
4748
|
-
return (0,
|
|
4602
|
+
return (0, import_shared37.reduceConfigsWithContext)({
|
|
4749
4603
|
initial: defaultOptions2,
|
|
4750
4604
|
config: templateParameters,
|
|
4751
4605
|
ctx: { entryName }
|
|
@@ -4755,7 +4609,7 @@ function getTemplateParameters(entryName, config, assetPrefix) {
|
|
|
4755
4609
|
function getChunks(entryName, entryValue) {
|
|
4756
4610
|
const chunks = [entryName];
|
|
4757
4611
|
for (const item of entryValue) {
|
|
4758
|
-
if (!(0,
|
|
4612
|
+
if (!(0, import_shared37.isPlainObject)(item)) {
|
|
4759
4613
|
continue;
|
|
4760
4614
|
}
|
|
4761
4615
|
const { dependOn } = item;
|
|
@@ -4770,19 +4624,19 @@ function getChunks(entryName, entryValue) {
|
|
|
4770
4624
|
}
|
|
4771
4625
|
return chunks;
|
|
4772
4626
|
}
|
|
4773
|
-
var
|
|
4627
|
+
var import_node_path19, import_shared37, existTemplatePath, getTagConfig, pluginHtml;
|
|
4774
4628
|
var init_html = __esm({
|
|
4775
4629
|
"src/plugins/html.ts"() {
|
|
4776
4630
|
"use strict";
|
|
4777
|
-
|
|
4778
|
-
|
|
4631
|
+
import_node_path19 = __toESM(require("path"));
|
|
4632
|
+
import_shared37 = require("@rsbuild/shared");
|
|
4779
4633
|
init_constants();
|
|
4780
4634
|
init_helpers();
|
|
4781
4635
|
init_minimize();
|
|
4782
4636
|
existTemplatePath = [];
|
|
4783
4637
|
getTagConfig = (api) => {
|
|
4784
4638
|
const config = api.getNormalizedConfig();
|
|
4785
|
-
const tags = (0,
|
|
4639
|
+
const tags = (0, import_shared37.castArray)(config.html.tags).filter(Boolean);
|
|
4786
4640
|
if (!tags.length) {
|
|
4787
4641
|
return void 0;
|
|
4788
4642
|
}
|
|
@@ -4799,7 +4653,7 @@ var init_html = __esm({
|
|
|
4799
4653
|
api.modifyBundlerChain(
|
|
4800
4654
|
async (chain, { HtmlPlugin, isProd: isProd6, CHAIN_ID: CHAIN_ID3, target }) => {
|
|
4801
4655
|
const config = api.getNormalizedConfig();
|
|
4802
|
-
if ((0,
|
|
4656
|
+
if ((0, import_shared37.isHtmlDisabled)(config, target)) {
|
|
4803
4657
|
return;
|
|
4804
4658
|
}
|
|
4805
4659
|
const minify = await getHtmlMinifyOptions(isProd6, config);
|
|
@@ -4851,13 +4705,13 @@ var init_html = __esm({
|
|
|
4851
4705
|
pluginOptions.title = getTitle(entryName, config);
|
|
4852
4706
|
const favicon = getFavicon(entryName, config);
|
|
4853
4707
|
if (favicon) {
|
|
4854
|
-
if ((0,
|
|
4708
|
+
if ((0, import_shared37.isURL)(favicon)) {
|
|
4855
4709
|
htmlInfo.favicon = favicon;
|
|
4856
4710
|
} else {
|
|
4857
4711
|
pluginOptions.favicon = favicon;
|
|
4858
4712
|
}
|
|
4859
4713
|
}
|
|
4860
|
-
const finalOptions2 = (0,
|
|
4714
|
+
const finalOptions2 = (0, import_shared37.reduceConfigsWithContext)({
|
|
4861
4715
|
initial: pluginOptions,
|
|
4862
4716
|
config: typeof config.tools.htmlPlugin === "boolean" ? {} : config.tools.htmlPlugin,
|
|
4863
4717
|
ctx: { entryName, entryValue }
|
|
@@ -4878,8 +4732,8 @@ var init_html = __esm({
|
|
|
4878
4732
|
}
|
|
4879
4733
|
if (appIcon) {
|
|
4880
4734
|
const { HtmlAppIconPlugin: HtmlAppIconPlugin2 } = await Promise.resolve().then(() => (init_HtmlAppIconPlugin(), HtmlAppIconPlugin_exports));
|
|
4881
|
-
const distDir = (0,
|
|
4882
|
-
const iconPath =
|
|
4735
|
+
const distDir = (0, import_shared37.getDistPath)(config, "image");
|
|
4736
|
+
const iconPath = import_node_path19.default.isAbsolute(appIcon) ? appIcon : import_node_path19.default.join(api.context.rootPath, appIcon);
|
|
4883
4737
|
chain.plugin(CHAIN_ID3.PLUGIN.APP_ICON).use(HtmlAppIconPlugin2, [{ iconPath, distDir }]);
|
|
4884
4738
|
}
|
|
4885
4739
|
}
|
|
@@ -4913,23 +4767,23 @@ var wasm_exports = {};
|
|
|
4913
4767
|
__export(wasm_exports, {
|
|
4914
4768
|
pluginWasm: () => pluginWasm
|
|
4915
4769
|
});
|
|
4916
|
-
var
|
|
4770
|
+
var import_node_path20, import_shared38, pluginWasm;
|
|
4917
4771
|
var init_wasm = __esm({
|
|
4918
4772
|
"src/plugins/wasm.ts"() {
|
|
4919
4773
|
"use strict";
|
|
4920
|
-
|
|
4921
|
-
|
|
4774
|
+
import_node_path20 = require("path");
|
|
4775
|
+
import_shared38 = require("@rsbuild/shared");
|
|
4922
4776
|
pluginWasm = () => ({
|
|
4923
4777
|
name: "rsbuild:wasm",
|
|
4924
4778
|
setup(api) {
|
|
4925
4779
|
api.modifyBundlerChain(async (chain, { CHAIN_ID: CHAIN_ID3 }) => {
|
|
4926
4780
|
const config = api.getNormalizedConfig();
|
|
4927
|
-
const distPath = (0,
|
|
4781
|
+
const distPath = (0, import_shared38.getDistPath)(config, "wasm");
|
|
4928
4782
|
chain.experiments({
|
|
4929
4783
|
...chain.get("experiments"),
|
|
4930
4784
|
asyncWebAssembly: true
|
|
4931
4785
|
});
|
|
4932
|
-
const wasmFilename =
|
|
4786
|
+
const wasmFilename = import_node_path20.posix.join(distPath, "[hash].module.wasm");
|
|
4933
4787
|
chain.output.merge({
|
|
4934
4788
|
webassemblyModuleFilename: wasmFilename
|
|
4935
4789
|
});
|
|
@@ -4977,15 +4831,15 @@ var nodeAddons_exports = {};
|
|
|
4977
4831
|
__export(nodeAddons_exports, {
|
|
4978
4832
|
pluginNodeAddons: () => pluginNodeAddons
|
|
4979
4833
|
});
|
|
4980
|
-
var
|
|
4834
|
+
var import_node_path21, getFilename3, pluginNodeAddons;
|
|
4981
4835
|
var init_nodeAddons = __esm({
|
|
4982
4836
|
"src/plugins/nodeAddons.ts"() {
|
|
4983
4837
|
"use strict";
|
|
4984
|
-
|
|
4838
|
+
import_node_path21 = __toESM(require("path"));
|
|
4985
4839
|
getFilename3 = (resourcePath) => {
|
|
4986
4840
|
let basename2 = "";
|
|
4987
4841
|
if (resourcePath) {
|
|
4988
|
-
const parsed =
|
|
4842
|
+
const parsed = import_node_path21.default.parse(resourcePath);
|
|
4989
4843
|
if (parsed.dir) {
|
|
4990
4844
|
basename2 = parsed.name;
|
|
4991
4845
|
}
|
|
@@ -5026,11 +4880,11 @@ var define_exports = {};
|
|
|
5026
4880
|
__export(define_exports, {
|
|
5027
4881
|
pluginDefine: () => pluginDefine
|
|
5028
4882
|
});
|
|
5029
|
-
var
|
|
4883
|
+
var import_shared39, pluginDefine;
|
|
5030
4884
|
var init_define = __esm({
|
|
5031
4885
|
"src/plugins/define.ts"() {
|
|
5032
4886
|
"use strict";
|
|
5033
|
-
|
|
4887
|
+
import_shared39 = require("@rsbuild/shared");
|
|
5034
4888
|
init_helpers();
|
|
5035
4889
|
pluginDefine = () => ({
|
|
5036
4890
|
name: "rsbuild:define",
|
|
@@ -5038,7 +4892,7 @@ var init_define = __esm({
|
|
|
5038
4892
|
api.modifyBundlerChain((chain, { CHAIN_ID: CHAIN_ID3, bundler }) => {
|
|
5039
4893
|
const config = api.getNormalizedConfig();
|
|
5040
4894
|
const builtinVars = {
|
|
5041
|
-
"process.env.NODE_ENV": JSON.stringify((0,
|
|
4895
|
+
"process.env.NODE_ENV": JSON.stringify((0, import_shared39.getNodeEnv)()),
|
|
5042
4896
|
"process.env.ASSET_PREFIX": JSON.stringify(
|
|
5043
4897
|
getPublicPathFromChain(chain, false)
|
|
5044
4898
|
)
|
|
@@ -5057,11 +4911,11 @@ var progress_exports = {};
|
|
|
5057
4911
|
__export(progress_exports, {
|
|
5058
4912
|
pluginProgress: () => pluginProgress
|
|
5059
4913
|
});
|
|
5060
|
-
var
|
|
4914
|
+
var import_shared40, import_core7, pluginProgress;
|
|
5061
4915
|
var init_progress = __esm({
|
|
5062
4916
|
"src/plugins/progress.ts"() {
|
|
5063
4917
|
"use strict";
|
|
5064
|
-
|
|
4918
|
+
import_shared40 = require("@rsbuild/shared");
|
|
5065
4919
|
import_core7 = require("@rspack/core");
|
|
5066
4920
|
pluginProgress = () => ({
|
|
5067
4921
|
name: "rsbuild:progress",
|
|
@@ -5072,11 +4926,11 @@ var init_progress = __esm({
|
|
|
5072
4926
|
api.modifyBundlerChain(async (chain, { target, CHAIN_ID: CHAIN_ID3 }) => {
|
|
5073
4927
|
const config = api.getNormalizedConfig();
|
|
5074
4928
|
const options = config.dev.progressBar ?? // enable progress bar in production by default
|
|
5075
|
-
(0,
|
|
4929
|
+
(0, import_shared40.isProd)();
|
|
5076
4930
|
if (!options) {
|
|
5077
4931
|
return;
|
|
5078
4932
|
}
|
|
5079
|
-
const prefix = options !== true && options.id !== void 0 ? options.id :
|
|
4933
|
+
const prefix = options !== true && options.id !== void 0 ? options.id : import_shared40.TARGET_ID_MAP[target];
|
|
5080
4934
|
chain.plugin(CHAIN_ID3.PLUGIN.PROGRESS).use(import_core7.rspack.ProgressPlugin, [
|
|
5081
4935
|
{
|
|
5082
4936
|
prefix,
|
|
@@ -5110,14 +4964,14 @@ async function getDefaultSwcConfig(config, rootPath, target) {
|
|
|
5110
4964
|
},
|
|
5111
4965
|
isModule: "unknown",
|
|
5112
4966
|
env: {
|
|
5113
|
-
targets: await (0,
|
|
4967
|
+
targets: await (0, import_shared41.getBrowserslistWithDefault)(rootPath, config, target)
|
|
5114
4968
|
}
|
|
5115
4969
|
};
|
|
5116
4970
|
}
|
|
5117
4971
|
async function applyCoreJs(swcConfig, polyfillMode) {
|
|
5118
4972
|
const coreJsPath = require.resolve("core-js/package.json");
|
|
5119
|
-
const version2 = (0,
|
|
5120
|
-
const coreJsDir =
|
|
4973
|
+
const version2 = (0, import_shared41.getCoreJsVersion)(coreJsPath);
|
|
4974
|
+
const coreJsDir = import_node_path22.default.dirname(coreJsPath);
|
|
5121
4975
|
swcConfig.env.coreJs = version2;
|
|
5122
4976
|
if (polyfillMode === "usage") {
|
|
5123
4977
|
swcConfig.env.shippedProposals = true;
|
|
@@ -5149,12 +5003,12 @@ function applySwcDecoratorConfig(swcConfig, config) {
|
|
|
5149
5003
|
throw new Error("Unknown decorators version: ${version}");
|
|
5150
5004
|
}
|
|
5151
5005
|
}
|
|
5152
|
-
var
|
|
5006
|
+
var import_node_path22, import_shared41, builtinSwcLoaderName, pluginSwc;
|
|
5153
5007
|
var init_swc = __esm({
|
|
5154
5008
|
"src/plugins/swc.ts"() {
|
|
5155
5009
|
"use strict";
|
|
5156
|
-
|
|
5157
|
-
|
|
5010
|
+
import_node_path22 = __toESM(require("path"));
|
|
5011
|
+
import_shared41 = require("@rsbuild/shared");
|
|
5158
5012
|
init_constants();
|
|
5159
5013
|
builtinSwcLoaderName = "builtin:swc-loader";
|
|
5160
5014
|
pluginSwc = () => ({
|
|
@@ -5167,11 +5021,11 @@ var init_swc = __esm({
|
|
|
5167
5021
|
order: "pre",
|
|
5168
5022
|
handler: async (chain, { CHAIN_ID: CHAIN_ID3, target }) => {
|
|
5169
5023
|
const config = api.getNormalizedConfig();
|
|
5170
|
-
const rule = chain.module.rule(CHAIN_ID3.RULE.JS).test(
|
|
5024
|
+
const rule = chain.module.rule(CHAIN_ID3.RULE.JS).test(import_shared41.SCRIPT_REGEX).type("javascript/auto");
|
|
5171
5025
|
const dataUriRule = chain.module.rule(CHAIN_ID3.RULE.JS_DATA_URI).mimetype({
|
|
5172
5026
|
or: ["text/javascript", "application/javascript"]
|
|
5173
5027
|
});
|
|
5174
|
-
(0,
|
|
5028
|
+
(0, import_shared41.applyScriptCondition)({
|
|
5175
5029
|
rule,
|
|
5176
5030
|
chain,
|
|
5177
5031
|
config,
|
|
@@ -5189,10 +5043,10 @@ var init_swc = __esm({
|
|
|
5189
5043
|
if (swcConfig.jsc?.externalHelpers) {
|
|
5190
5044
|
chain.resolve.alias.set(
|
|
5191
5045
|
"@swc/helpers",
|
|
5192
|
-
|
|
5046
|
+
import_node_path22.default.dirname(require.resolve("@swc/helpers/package.json"))
|
|
5193
5047
|
);
|
|
5194
5048
|
}
|
|
5195
|
-
if ((0,
|
|
5049
|
+
if ((0, import_shared41.isWebTarget)(target)) {
|
|
5196
5050
|
const polyfillMode = config.output.polyfill;
|
|
5197
5051
|
if (polyfillMode === "off") {
|
|
5198
5052
|
swcConfig.env.mode = void 0;
|
|
@@ -5204,13 +5058,13 @@ var init_swc = __esm({
|
|
|
5204
5058
|
}
|
|
5205
5059
|
}
|
|
5206
5060
|
}
|
|
5207
|
-
const mergedSwcConfig = (0,
|
|
5061
|
+
const mergedSwcConfig = (0, import_shared41.reduceConfigs)({
|
|
5208
5062
|
initial: swcConfig,
|
|
5209
5063
|
config: config.tools.swc,
|
|
5210
|
-
mergeFn:
|
|
5064
|
+
mergeFn: import_shared41.deepmerge
|
|
5211
5065
|
});
|
|
5212
5066
|
rule.use(CHAIN_ID3.USE.SWC).loader(builtinSwcLoaderName).options(mergedSwcConfig);
|
|
5213
|
-
dataUriRule.resolve.set("fullySpecified", false).end().use(CHAIN_ID3.USE.SWC).loader(builtinSwcLoaderName).options((0,
|
|
5067
|
+
dataUriRule.resolve.set("fullySpecified", false).end().use(CHAIN_ID3.USE.SWC).loader(builtinSwcLoaderName).options((0, import_shared41.cloneDeep)(mergedSwcConfig));
|
|
5214
5068
|
}
|
|
5215
5069
|
});
|
|
5216
5070
|
}
|
|
@@ -5277,11 +5131,11 @@ function splitByExperience(ctx) {
|
|
|
5277
5131
|
const { override, polyfill, defaultConfig, userDefinedCacheGroups } = ctx;
|
|
5278
5132
|
const experienceCacheGroup = {};
|
|
5279
5133
|
const packageRegExps = {
|
|
5280
|
-
lodash: (0,
|
|
5281
|
-
axios: (0,
|
|
5134
|
+
lodash: (0, import_shared42.createDependenciesRegExp)("lodash", "lodash-es"),
|
|
5135
|
+
axios: (0, import_shared42.createDependenciesRegExp)("axios", /axios-.+/)
|
|
5282
5136
|
};
|
|
5283
5137
|
if (polyfill === "entry" || polyfill === "usage") {
|
|
5284
|
-
packageRegExps.polyfill = (0,
|
|
5138
|
+
packageRegExps.polyfill = (0, import_shared42.createDependenciesRegExp)(
|
|
5285
5139
|
"tslib",
|
|
5286
5140
|
"core-js",
|
|
5287
5141
|
"@babel/runtime",
|
|
@@ -5330,7 +5184,7 @@ function splitByModule(ctx) {
|
|
|
5330
5184
|
// Core group
|
|
5331
5185
|
vendors: {
|
|
5332
5186
|
priority: -9,
|
|
5333
|
-
test:
|
|
5187
|
+
test: import_shared42.NODE_MODULES_REGEX,
|
|
5334
5188
|
name(module2) {
|
|
5335
5189
|
return module2 ? getPackageNameFromModulePath(module2.context) : void 0;
|
|
5336
5190
|
}
|
|
@@ -5373,7 +5227,7 @@ function singleVendor(ctx) {
|
|
|
5373
5227
|
const { override, defaultConfig, userDefinedCacheGroups } = ctx;
|
|
5374
5228
|
const singleVendorCacheGroup = {
|
|
5375
5229
|
singleVendor: {
|
|
5376
|
-
test:
|
|
5230
|
+
test: import_shared42.NODE_MODULES_REGEX,
|
|
5377
5231
|
priority: 0,
|
|
5378
5232
|
chunks: "all",
|
|
5379
5233
|
name: "vendor",
|
|
@@ -5392,12 +5246,12 @@ function singleVendor(ctx) {
|
|
|
5392
5246
|
}
|
|
5393
5247
|
};
|
|
5394
5248
|
}
|
|
5395
|
-
var import_node_assert,
|
|
5249
|
+
var import_node_assert, import_shared42, MODULE_PATH_REGEX, SPLIT_STRATEGY_DISPATCHER, pluginSplitChunks;
|
|
5396
5250
|
var init_splitChunks = __esm({
|
|
5397
5251
|
"src/plugins/splitChunks.ts"() {
|
|
5398
5252
|
"use strict";
|
|
5399
5253
|
import_node_assert = __toESM(require("assert"));
|
|
5400
|
-
|
|
5254
|
+
import_shared42 = require("@rsbuild/shared");
|
|
5401
5255
|
MODULE_PATH_REGEX = /.*[\\/]node_modules[\\/](?!\.pnpm[\\/])(?:(@[^\\/]+)[\\/])?([^\\/]+)/;
|
|
5402
5256
|
SPLIT_STRATEGY_DISPATCHER = {
|
|
5403
5257
|
"split-by-experience": splitByExperience,
|
|
@@ -5480,10 +5334,10 @@ async function openBrowser(url2) {
|
|
|
5480
5334
|
);
|
|
5481
5335
|
return true;
|
|
5482
5336
|
}
|
|
5483
|
-
(0,
|
|
5337
|
+
(0, import_shared43.debug)("Failed to find the target browser.");
|
|
5484
5338
|
} catch (err) {
|
|
5485
|
-
(0,
|
|
5486
|
-
|
|
5339
|
+
(0, import_shared43.debug)("Failed to open start URL with apple script.");
|
|
5340
|
+
import_shared43.logger.debug(err);
|
|
5487
5341
|
}
|
|
5488
5342
|
}
|
|
5489
5343
|
try {
|
|
@@ -5491,13 +5345,13 @@ async function openBrowser(url2) {
|
|
|
5491
5345
|
await open(url2);
|
|
5492
5346
|
return true;
|
|
5493
5347
|
} catch (err) {
|
|
5494
|
-
|
|
5495
|
-
|
|
5348
|
+
import_shared43.logger.error("Failed to open start URL.");
|
|
5349
|
+
import_shared43.logger.error(err);
|
|
5496
5350
|
return false;
|
|
5497
5351
|
}
|
|
5498
5352
|
}
|
|
5499
5353
|
function resolveUrl(str, base) {
|
|
5500
|
-
if (
|
|
5354
|
+
if (canParse(str)) {
|
|
5501
5355
|
return str;
|
|
5502
5356
|
}
|
|
5503
5357
|
try {
|
|
@@ -5555,14 +5409,15 @@ function pluginOpen() {
|
|
|
5555
5409
|
}
|
|
5556
5410
|
};
|
|
5557
5411
|
}
|
|
5558
|
-
var import_node_child_process, import_node_util,
|
|
5412
|
+
var import_node_child_process, import_node_util, import_shared43, execAsync, supportedChromiumBrowsers, getTargetBrowser, replacePlaceholder, openedURLs, normalizeOpenConfig;
|
|
5559
5413
|
var init_open = __esm({
|
|
5560
5414
|
"src/plugins/open.ts"() {
|
|
5561
5415
|
"use strict";
|
|
5562
5416
|
import_node_child_process = require("child_process");
|
|
5563
5417
|
import_node_util = require("util");
|
|
5564
|
-
|
|
5418
|
+
import_shared43 = require("@rsbuild/shared");
|
|
5565
5419
|
init_constants();
|
|
5420
|
+
init_helpers();
|
|
5566
5421
|
execAsync = (0, import_node_util.promisify)(import_node_child_process.exec);
|
|
5567
5422
|
supportedChromiumBrowsers = [
|
|
5568
5423
|
"Google Chrome Canary",
|
|
@@ -5600,7 +5455,7 @@ var init_open = __esm({
|
|
|
5600
5455
|
return { targets: open, before: beforeStartUrl };
|
|
5601
5456
|
}
|
|
5602
5457
|
return {
|
|
5603
|
-
targets: open.target ? (0,
|
|
5458
|
+
targets: open.target ? (0, import_shared43.castArray)(open.target) : [],
|
|
5604
5459
|
before: open.before
|
|
5605
5460
|
};
|
|
5606
5461
|
};
|
|
@@ -5612,12 +5467,12 @@ var InlineChunkHtmlPlugin_exports = {};
|
|
|
5612
5467
|
__export(InlineChunkHtmlPlugin_exports, {
|
|
5613
5468
|
InlineChunkHtmlPlugin: () => InlineChunkHtmlPlugin
|
|
5614
5469
|
});
|
|
5615
|
-
var
|
|
5470
|
+
var import_node_path23, import_shared44, InlineChunkHtmlPlugin;
|
|
5616
5471
|
var init_InlineChunkHtmlPlugin = __esm({
|
|
5617
5472
|
"src/rspack/InlineChunkHtmlPlugin.ts"() {
|
|
5618
5473
|
"use strict";
|
|
5619
|
-
|
|
5620
|
-
|
|
5474
|
+
import_node_path23 = require("path");
|
|
5475
|
+
import_shared44 = require("@rsbuild/shared");
|
|
5621
5476
|
init_pluginHelper();
|
|
5622
5477
|
InlineChunkHtmlPlugin = class {
|
|
5623
5478
|
constructor({
|
|
@@ -5650,8 +5505,8 @@ var init_InlineChunkHtmlPlugin = __esm({
|
|
|
5650
5505
|
const { devtool } = compilation.options;
|
|
5651
5506
|
if (devtool && // If the source map is inlined, we do not need to update the sourceMappingURL
|
|
5652
5507
|
!devtool.includes("inline") && source.includes("# sourceMappingURL")) {
|
|
5653
|
-
const prefix = (0,
|
|
5654
|
-
(0,
|
|
5508
|
+
const prefix = (0, import_shared44.addTrailingSlash)(
|
|
5509
|
+
(0, import_node_path23.join)(publicPath, this.distPath[type] || "")
|
|
5655
5510
|
);
|
|
5656
5511
|
return source.replace(
|
|
5657
5512
|
/# sourceMappingURL=/,
|
|
@@ -5662,7 +5517,7 @@ var init_InlineChunkHtmlPlugin = __esm({
|
|
|
5662
5517
|
}
|
|
5663
5518
|
matchTests(name, source, tests) {
|
|
5664
5519
|
return tests.some((test) => {
|
|
5665
|
-
if ((0,
|
|
5520
|
+
if ((0, import_shared44.isFunction)(test)) {
|
|
5666
5521
|
const size = source.length;
|
|
5667
5522
|
return test({ name, size });
|
|
5668
5523
|
}
|
|
@@ -5748,7 +5603,7 @@ var init_InlineChunkHtmlPlugin = __esm({
|
|
|
5748
5603
|
}
|
|
5749
5604
|
apply(compiler) {
|
|
5750
5605
|
compiler.hooks.compilation.tap(this.name, (compilation) => {
|
|
5751
|
-
const publicPath = (0,
|
|
5606
|
+
const publicPath = (0, import_shared44.getPublicPathFromCompiler)(compiler);
|
|
5752
5607
|
const tagFunction = (tag) => this.getInlinedTag(publicPath, tag, compilation);
|
|
5753
5608
|
const hooks = getHTMLPlugin().getHooks(compilation);
|
|
5754
5609
|
hooks.alterAssetTagGroups.tap(this.name, (assets) => {
|
|
@@ -5788,18 +5643,18 @@ var inlineChunk_exports = {};
|
|
|
5788
5643
|
__export(inlineChunk_exports, {
|
|
5789
5644
|
pluginInlineChunk: () => pluginInlineChunk
|
|
5790
5645
|
});
|
|
5791
|
-
var
|
|
5646
|
+
var import_shared45, pluginInlineChunk;
|
|
5792
5647
|
var init_inlineChunk = __esm({
|
|
5793
5648
|
"src/plugins/inlineChunk.ts"() {
|
|
5794
5649
|
"use strict";
|
|
5795
|
-
|
|
5650
|
+
import_shared45 = require("@rsbuild/shared");
|
|
5796
5651
|
init_constants();
|
|
5797
5652
|
pluginInlineChunk = () => ({
|
|
5798
5653
|
name: "rsbuild:inline-chunk",
|
|
5799
5654
|
setup(api) {
|
|
5800
5655
|
api.modifyBundlerChain(async (chain, { target, CHAIN_ID: CHAIN_ID3, isDev: isDev3 }) => {
|
|
5801
5656
|
const config = api.getNormalizedConfig();
|
|
5802
|
-
if ((0,
|
|
5657
|
+
if ((0, import_shared45.isHtmlDisabled)(config, target) || isDev3) {
|
|
5803
5658
|
return;
|
|
5804
5659
|
}
|
|
5805
5660
|
const { InlineChunkHtmlPlugin: InlineChunkHtmlPlugin2 } = await Promise.resolve().then(() => (init_InlineChunkHtmlPlugin(), InlineChunkHtmlPlugin_exports));
|
|
@@ -5807,7 +5662,7 @@ var init_inlineChunk = __esm({
|
|
|
5807
5662
|
const scriptTests = [];
|
|
5808
5663
|
const styleTests = [];
|
|
5809
5664
|
if (inlineScripts) {
|
|
5810
|
-
scriptTests.push(inlineScripts === true ?
|
|
5665
|
+
scriptTests.push(inlineScripts === true ? import_shared45.JS_REGEX : inlineScripts);
|
|
5811
5666
|
}
|
|
5812
5667
|
if (inlineStyles) {
|
|
5813
5668
|
styleTests.push(inlineStyles === true ? CSS_REGEX : inlineStyles);
|
|
@@ -5819,7 +5674,7 @@ var init_inlineChunk = __esm({
|
|
|
5819
5674
|
{
|
|
5820
5675
|
styleTests,
|
|
5821
5676
|
scriptTests,
|
|
5822
|
-
distPath: (0,
|
|
5677
|
+
distPath: (0, import_shared45.pick)(config.output.distPath, ["js", "css"])
|
|
5823
5678
|
}
|
|
5824
5679
|
]);
|
|
5825
5680
|
});
|
|
@@ -5838,7 +5693,7 @@ function pluginBundleAnalyzer() {
|
|
|
5838
5693
|
name: "rsbuild:bundle-analyzer",
|
|
5839
5694
|
setup(api) {
|
|
5840
5695
|
api.modifyRsbuildConfig((config) => {
|
|
5841
|
-
if ((0,
|
|
5696
|
+
if ((0, import_shared46.isProd)() || !isUseAnalyzer(config)) {
|
|
5842
5697
|
return;
|
|
5843
5698
|
}
|
|
5844
5699
|
config.dev ||= {};
|
|
@@ -5863,11 +5718,11 @@ function pluginBundleAnalyzer() {
|
|
|
5863
5718
|
}
|
|
5864
5719
|
};
|
|
5865
5720
|
}
|
|
5866
|
-
var
|
|
5721
|
+
var import_shared46, isUseAnalyzer;
|
|
5867
5722
|
var init_bundleAnalyzer = __esm({
|
|
5868
5723
|
"src/plugins/bundleAnalyzer.ts"() {
|
|
5869
5724
|
"use strict";
|
|
5870
|
-
|
|
5725
|
+
import_shared46 = require("@rsbuild/shared");
|
|
5871
5726
|
isUseAnalyzer = (config) => process.env.BUNDLE_ANALYZE || config.performance?.bundleAnalyze;
|
|
5872
5727
|
}
|
|
5873
5728
|
});
|
|
@@ -5877,11 +5732,11 @@ var rsdoctor_exports = {};
|
|
|
5877
5732
|
__export(rsdoctor_exports, {
|
|
5878
5733
|
pluginRsdoctor: () => pluginRsdoctor
|
|
5879
5734
|
});
|
|
5880
|
-
var
|
|
5735
|
+
var import_shared47, pluginRsdoctor;
|
|
5881
5736
|
var init_rsdoctor = __esm({
|
|
5882
5737
|
"src/plugins/rsdoctor.ts"() {
|
|
5883
5738
|
"use strict";
|
|
5884
|
-
|
|
5739
|
+
import_shared47 = require("@rsbuild/shared");
|
|
5885
5740
|
pluginRsdoctor = () => ({
|
|
5886
5741
|
name: "rsbuild:rsdoctor",
|
|
5887
5742
|
setup(api) {
|
|
@@ -5898,8 +5753,8 @@ var init_rsdoctor = __esm({
|
|
|
5898
5753
|
});
|
|
5899
5754
|
module2 = await import(path13);
|
|
5900
5755
|
} catch (err) {
|
|
5901
|
-
|
|
5902
|
-
`\`process.env.RSDOCTOR\` enabled, please install ${
|
|
5756
|
+
import_shared47.logger.warn(
|
|
5757
|
+
`\`process.env.RSDOCTOR\` enabled, please install ${import_shared47.color.bold(import_shared47.color.yellow(packageName))} package.`
|
|
5903
5758
|
);
|
|
5904
5759
|
return;
|
|
5905
5760
|
}
|
|
@@ -5920,7 +5775,7 @@ var init_rsdoctor = __esm({
|
|
|
5920
5775
|
isAutoRegister = true;
|
|
5921
5776
|
}
|
|
5922
5777
|
if (isAutoRegister) {
|
|
5923
|
-
|
|
5778
|
+
import_shared47.logger.info(`${import_shared47.color.bold(import_shared47.color.yellow(packageName))} enabled.`);
|
|
5924
5779
|
}
|
|
5925
5780
|
});
|
|
5926
5781
|
}
|
|
@@ -5981,7 +5836,7 @@ function determineAsValue({
|
|
|
5981
5836
|
file
|
|
5982
5837
|
}) {
|
|
5983
5838
|
const url2 = new import_node_url3.URL(file || href, "https://example.com");
|
|
5984
|
-
const extension =
|
|
5839
|
+
const extension = import_node_path24.default.extname(url2.pathname).slice(1);
|
|
5985
5840
|
if (["css"].includes(extension)) {
|
|
5986
5841
|
return "style";
|
|
5987
5842
|
}
|
|
@@ -6002,11 +5857,11 @@ function determineAsValue({
|
|
|
6002
5857
|
}
|
|
6003
5858
|
return "script";
|
|
6004
5859
|
}
|
|
6005
|
-
var
|
|
5860
|
+
var import_node_path24, import_node_url3;
|
|
6006
5861
|
var init_determineAsValue = __esm({
|
|
6007
5862
|
"src/rspack/preload/helpers/determineAsValue.ts"() {
|
|
6008
5863
|
"use strict";
|
|
6009
|
-
|
|
5864
|
+
import_node_path24 = __toESM(require("path"));
|
|
6010
5865
|
import_node_url3 = require("url");
|
|
6011
5866
|
init_constants();
|
|
6012
5867
|
}
|
|
@@ -6116,10 +5971,10 @@ function generateLinks(options, type, compilation, htmlPluginData, HTMLCount) {
|
|
|
6116
5971
|
);
|
|
6117
5972
|
const sortedFilteredFiles = filteredFiles.sort();
|
|
6118
5973
|
const links = [];
|
|
6119
|
-
const publicPath = (0,
|
|
5974
|
+
const publicPath = (0, import_shared48.getPublicPathFromCompiler)(compilation.compiler);
|
|
6120
5975
|
const { crossOriginLoading } = compilation.compiler.options.output;
|
|
6121
5976
|
for (const file of sortedFilteredFiles) {
|
|
6122
|
-
const href = (
|
|
5977
|
+
const href = ensureAssetPrefix(file, publicPath);
|
|
6123
5978
|
const attributes = {
|
|
6124
5979
|
href,
|
|
6125
5980
|
rel: type
|
|
@@ -6147,11 +6002,12 @@ function generateLinks(options, type, compilation, htmlPluginData, HTMLCount) {
|
|
|
6147
6002
|
}
|
|
6148
6003
|
return links;
|
|
6149
6004
|
}
|
|
6150
|
-
var
|
|
6005
|
+
var import_shared48, defaultOptions, HtmlPreloadOrPrefetchPlugin;
|
|
6151
6006
|
var init_HtmlPreloadOrPrefetchPlugin = __esm({
|
|
6152
6007
|
"src/rspack/preload/HtmlPreloadOrPrefetchPlugin.ts"() {
|
|
6153
6008
|
"use strict";
|
|
6154
|
-
|
|
6009
|
+
import_shared48 = require("@rsbuild/shared");
|
|
6010
|
+
init_helpers();
|
|
6155
6011
|
init_pluginHelper();
|
|
6156
6012
|
init_helpers2();
|
|
6157
6013
|
defaultOptions = {
|
|
@@ -6173,7 +6029,7 @@ var init_HtmlPreloadOrPrefetchPlugin = __esm({
|
|
|
6173
6029
|
apply(compiler) {
|
|
6174
6030
|
compiler.hooks.compilation.tap(this.constructor.name, (compilation) => {
|
|
6175
6031
|
getHTMLPlugin().getHooks(compilation).beforeAssetTagGeneration.tap(
|
|
6176
|
-
`HTML${(0,
|
|
6032
|
+
`HTML${(0, import_shared48.upperFirst)(this.type)}Plugin`,
|
|
6177
6033
|
(htmlPluginData) => {
|
|
6178
6034
|
this.resourceHints = generateLinks(
|
|
6179
6035
|
this.options,
|
|
@@ -6186,7 +6042,7 @@ var init_HtmlPreloadOrPrefetchPlugin = __esm({
|
|
|
6186
6042
|
}
|
|
6187
6043
|
);
|
|
6188
6044
|
getHTMLPlugin().getHooks(compilation).alterAssetTags.tap(
|
|
6189
|
-
`HTML${(0,
|
|
6045
|
+
`HTML${(0, import_shared48.upperFirst)(this.type)}Plugin`,
|
|
6190
6046
|
(htmlPluginData) => {
|
|
6191
6047
|
if (this.resourceHints) {
|
|
6192
6048
|
htmlPluginData.assetTags.styles = [
|
|
@@ -6211,11 +6067,11 @@ var resourceHints_exports = {};
|
|
|
6211
6067
|
__export(resourceHints_exports, {
|
|
6212
6068
|
pluginResourceHints: () => pluginResourceHints
|
|
6213
6069
|
});
|
|
6214
|
-
var
|
|
6070
|
+
var import_shared49, generateLinks2, pluginResourceHints;
|
|
6215
6071
|
var init_resourceHints = __esm({
|
|
6216
6072
|
"src/plugins/resourceHints.ts"() {
|
|
6217
6073
|
"use strict";
|
|
6218
|
-
|
|
6074
|
+
import_shared49 = require("@rsbuild/shared");
|
|
6219
6075
|
generateLinks2 = (options, rel) => options.map((option) => ({
|
|
6220
6076
|
tag: "link",
|
|
6221
6077
|
attrs: {
|
|
@@ -6250,7 +6106,7 @@ var init_resourceHints = __esm({
|
|
|
6250
6106
|
const {
|
|
6251
6107
|
performance: { preload, prefetch }
|
|
6252
6108
|
} = config;
|
|
6253
|
-
if ((0,
|
|
6109
|
+
if ((0, import_shared49.isHtmlDisabled)(config, target)) {
|
|
6254
6110
|
return;
|
|
6255
6111
|
}
|
|
6256
6112
|
const HTMLCount = chain.entryPoints.values().length;
|
|
@@ -6313,12 +6169,12 @@ var server_exports = {};
|
|
|
6313
6169
|
__export(server_exports, {
|
|
6314
6170
|
pluginServer: () => pluginServer
|
|
6315
6171
|
});
|
|
6316
|
-
var
|
|
6172
|
+
var import_node_path25, import_shared50, pluginServer;
|
|
6317
6173
|
var init_server = __esm({
|
|
6318
6174
|
"src/plugins/server.ts"() {
|
|
6319
6175
|
"use strict";
|
|
6320
|
-
|
|
6321
|
-
|
|
6176
|
+
import_node_path25 = require("path");
|
|
6177
|
+
import_shared50 = require("@rsbuild/shared");
|
|
6322
6178
|
init_config();
|
|
6323
6179
|
pluginServer = () => ({
|
|
6324
6180
|
name: "rsbuild:server",
|
|
@@ -6331,12 +6187,12 @@ var init_server = __esm({
|
|
|
6331
6187
|
if (!copyOnBuild || !name) {
|
|
6332
6188
|
continue;
|
|
6333
6189
|
}
|
|
6334
|
-
const normalizedPath = (0,
|
|
6335
|
-
if (!
|
|
6190
|
+
const normalizedPath = (0, import_node_path25.isAbsolute)(name) ? name : (0, import_node_path25.join)(api.context.rootPath, name);
|
|
6191
|
+
if (!import_shared50.fse.existsSync(normalizedPath)) {
|
|
6336
6192
|
continue;
|
|
6337
6193
|
}
|
|
6338
6194
|
try {
|
|
6339
|
-
await
|
|
6195
|
+
await import_shared50.fse.copy(normalizedPath, api.context.distPath, {
|
|
6340
6196
|
// dereference symlinks
|
|
6341
6197
|
dereference: true
|
|
6342
6198
|
});
|
|
@@ -6503,18 +6359,18 @@ function pluginModuleFederation() {
|
|
|
6503
6359
|
chain.plugin("mf-patch-split-chunks").use(PatchSplitChunksPlugin, [options.name]);
|
|
6504
6360
|
}
|
|
6505
6361
|
const publicPath = chain.output.get("publicPath");
|
|
6506
|
-
if (publicPath ===
|
|
6362
|
+
if (publicPath === import_shared51.DEFAULT_ASSET_PREFIX) {
|
|
6507
6363
|
chain.output.set("publicPath", "auto");
|
|
6508
6364
|
}
|
|
6509
6365
|
});
|
|
6510
6366
|
}
|
|
6511
6367
|
};
|
|
6512
6368
|
}
|
|
6513
|
-
var
|
|
6369
|
+
var import_shared51, import_core8, PatchSplitChunksPlugin;
|
|
6514
6370
|
var init_moduleFederation = __esm({
|
|
6515
6371
|
"src/plugins/moduleFederation.ts"() {
|
|
6516
6372
|
"use strict";
|
|
6517
|
-
|
|
6373
|
+
import_shared51 = require("@rsbuild/shared");
|
|
6518
6374
|
import_core8 = require("@rspack/core");
|
|
6519
6375
|
PatchSplitChunksPlugin = class {
|
|
6520
6376
|
constructor(name) {
|
|
@@ -6582,14 +6438,14 @@ __export(rspackProfile_exports, {
|
|
|
6582
6438
|
pluginRspackProfile: () => pluginRspackProfile,
|
|
6583
6439
|
stopProfiler: () => stopProfiler
|
|
6584
6440
|
});
|
|
6585
|
-
var import_node_inspector,
|
|
6441
|
+
var import_node_inspector, import_node_path26, import_shared52, import_shared53, import_core9, stopProfiler, pluginRspackProfile;
|
|
6586
6442
|
var init_rspackProfile = __esm({
|
|
6587
6443
|
"src/plugins/rspackProfile.ts"() {
|
|
6588
6444
|
"use strict";
|
|
6589
6445
|
import_node_inspector = __toESM(require("inspector"));
|
|
6590
|
-
|
|
6446
|
+
import_node_path26 = __toESM(require("path"));
|
|
6447
|
+
import_shared52 = require("@rsbuild/shared");
|
|
6591
6448
|
import_shared53 = require("@rsbuild/shared");
|
|
6592
|
-
import_shared54 = require("@rsbuild/shared");
|
|
6593
6449
|
import_core9 = require("@rspack/core");
|
|
6594
6450
|
stopProfiler = (output, profileSession) => {
|
|
6595
6451
|
if (!profileSession) {
|
|
@@ -6597,10 +6453,10 @@ var init_rspackProfile = __esm({
|
|
|
6597
6453
|
}
|
|
6598
6454
|
profileSession.post("Profiler.stop", (error, param) => {
|
|
6599
6455
|
if (error) {
|
|
6600
|
-
|
|
6456
|
+
import_shared53.logger.error("Failed to generate JS CPU profile:", error);
|
|
6601
6457
|
return;
|
|
6602
6458
|
}
|
|
6603
|
-
|
|
6459
|
+
import_shared52.fse.writeFileSync(output, JSON.stringify(param.profile));
|
|
6604
6460
|
});
|
|
6605
6461
|
};
|
|
6606
6462
|
pluginRspackProfile = () => ({
|
|
@@ -6614,7 +6470,7 @@ var init_rspackProfile = __esm({
|
|
|
6614
6470
|
return;
|
|
6615
6471
|
}
|
|
6616
6472
|
const timestamp = Date.now();
|
|
6617
|
-
const profileDir =
|
|
6473
|
+
const profileDir = import_node_path26.default.join(
|
|
6618
6474
|
api.context.distPath,
|
|
6619
6475
|
`rspack-profile-${timestamp}`
|
|
6620
6476
|
);
|
|
@@ -6622,11 +6478,11 @@ var init_rspackProfile = __esm({
|
|
|
6622
6478
|
const enableProfileTrace = RSPACK_PROFILE === "ALL" || RSPACK_PROFILE.includes("TRACE");
|
|
6623
6479
|
const enableCPUProfile = RSPACK_PROFILE === "ALL" || RSPACK_PROFILE.includes("CPU");
|
|
6624
6480
|
const enableLogging = RSPACK_PROFILE === "ALL" || RSPACK_PROFILE.includes("LOGGING");
|
|
6625
|
-
const traceFilePath =
|
|
6626
|
-
const cpuProfilePath =
|
|
6627
|
-
const loggingFilePath =
|
|
6481
|
+
const traceFilePath = import_node_path26.default.join(profileDir, "trace.json");
|
|
6482
|
+
const cpuProfilePath = import_node_path26.default.join(profileDir, "jscpuprofile.json");
|
|
6483
|
+
const loggingFilePath = import_node_path26.default.join(profileDir, "logging.json");
|
|
6628
6484
|
const onStart = () => {
|
|
6629
|
-
|
|
6485
|
+
import_shared52.fse.ensureDirSync(profileDir);
|
|
6630
6486
|
if (enableProfileTrace) {
|
|
6631
6487
|
import_core9.rspack.experimental_registerGlobalTrace(
|
|
6632
6488
|
"trace",
|
|
@@ -6650,7 +6506,7 @@ var init_rspackProfile = __esm({
|
|
|
6650
6506
|
logging: "verbose",
|
|
6651
6507
|
loggingTrace: true
|
|
6652
6508
|
});
|
|
6653
|
-
|
|
6509
|
+
import_shared52.fse.writeFileSync(loggingFilePath, JSON.stringify(logging));
|
|
6654
6510
|
}
|
|
6655
6511
|
});
|
|
6656
6512
|
api.onExit(() => {
|
|
@@ -6658,7 +6514,7 @@ var init_rspackProfile = __esm({
|
|
|
6658
6514
|
import_core9.rspack.experimental_cleanupGlobalTrace();
|
|
6659
6515
|
}
|
|
6660
6516
|
stopProfiler(cpuProfilePath, profileSession);
|
|
6661
|
-
|
|
6517
|
+
import_shared53.logger.info(`Saved Rspack profile file to ${profileDir}`);
|
|
6662
6518
|
});
|
|
6663
6519
|
}
|
|
6664
6520
|
});
|
|
@@ -6670,11 +6526,11 @@ var lazyCompilation_exports = {};
|
|
|
6670
6526
|
__export(lazyCompilation_exports, {
|
|
6671
6527
|
pluginLazyCompilation: () => pluginLazyCompilation
|
|
6672
6528
|
});
|
|
6673
|
-
var
|
|
6529
|
+
var import_shared54, pluginLazyCompilation;
|
|
6674
6530
|
var init_lazyCompilation = __esm({
|
|
6675
6531
|
"src/plugins/lazyCompilation.ts"() {
|
|
6676
6532
|
"use strict";
|
|
6677
|
-
|
|
6533
|
+
import_shared54 = require("@rsbuild/shared");
|
|
6678
6534
|
pluginLazyCompilation = () => ({
|
|
6679
6535
|
name: "rsbuild:lazy-compilation",
|
|
6680
6536
|
setup(api) {
|
|
@@ -6720,7 +6576,7 @@ var init_lazyCompilation = __esm({
|
|
|
6720
6576
|
if (!name || isExcludedModule(name)) {
|
|
6721
6577
|
return false;
|
|
6722
6578
|
}
|
|
6723
|
-
if ((0,
|
|
6579
|
+
if ((0, import_shared54.isRegExp)(test)) {
|
|
6724
6580
|
return name ? test.test(name) : false;
|
|
6725
6581
|
}
|
|
6726
6582
|
return test(module2);
|
|
@@ -6742,18 +6598,18 @@ var sri_exports = {};
|
|
|
6742
6598
|
__export(sri_exports, {
|
|
6743
6599
|
pluginSri: () => pluginSri
|
|
6744
6600
|
});
|
|
6745
|
-
var import_node_crypto2,
|
|
6601
|
+
var import_node_crypto2, import_shared55, getAssetName, pluginSri;
|
|
6746
6602
|
var init_sri = __esm({
|
|
6747
6603
|
"src/plugins/sri.ts"() {
|
|
6748
6604
|
"use strict";
|
|
6749
6605
|
import_node_crypto2 = __toESM(require("crypto"));
|
|
6750
|
-
|
|
6606
|
+
import_shared55 = require("@rsbuild/shared");
|
|
6751
6607
|
init_constants();
|
|
6752
6608
|
getAssetName = (url2, assetPrefix) => {
|
|
6753
6609
|
if (url2.startsWith(assetPrefix)) {
|
|
6754
|
-
return (0,
|
|
6610
|
+
return (0, import_shared55.removeLeadingSlash)(url2.replace(assetPrefix, ""));
|
|
6755
6611
|
}
|
|
6756
|
-
return (0,
|
|
6612
|
+
return (0, import_shared55.removeLeadingSlash)(url2);
|
|
6757
6613
|
};
|
|
6758
6614
|
pluginSri = () => ({
|
|
6759
6615
|
name: "rsbuild:sri",
|
|
@@ -6762,7 +6618,7 @@ var init_sri = __esm({
|
|
|
6762
6618
|
const getAlgorithm = () => {
|
|
6763
6619
|
const config = api.getNormalizedConfig();
|
|
6764
6620
|
const { sri } = config.security;
|
|
6765
|
-
const enable = sri.enable === "auto" ? (0,
|
|
6621
|
+
const enable = sri.enable === "auto" ? (0, import_shared55.isProd)() : sri.enable;
|
|
6766
6622
|
if (!enable) {
|
|
6767
6623
|
return null;
|
|
6768
6624
|
}
|
|
@@ -6829,7 +6685,7 @@ var init_sri = __esm({
|
|
|
6829
6685
|
`integrity="${integrity}"`
|
|
6830
6686
|
);
|
|
6831
6687
|
} else {
|
|
6832
|
-
|
|
6688
|
+
import_shared55.logger.debug(
|
|
6833
6689
|
`[rsbuild:sri] failed to generate integrity for ${assetName}.`
|
|
6834
6690
|
);
|
|
6835
6691
|
replacedHtml = replacedHtml.replace(
|
|
@@ -6882,7 +6738,7 @@ var init_sri = __esm({
|
|
|
6882
6738
|
}
|
|
6883
6739
|
api.modifyBundlerChain((chain, { target }) => {
|
|
6884
6740
|
const config = api.getNormalizedConfig();
|
|
6885
|
-
if ((0,
|
|
6741
|
+
if ((0, import_shared55.isHtmlDisabled)(config, target)) {
|
|
6886
6742
|
return;
|
|
6887
6743
|
}
|
|
6888
6744
|
const algorithm = getAlgorithm();
|
|
@@ -6901,11 +6757,11 @@ var nonce_exports = {};
|
|
|
6901
6757
|
__export(nonce_exports, {
|
|
6902
6758
|
pluginNonce: () => pluginNonce
|
|
6903
6759
|
});
|
|
6904
|
-
var
|
|
6760
|
+
var import_shared56, pluginNonce;
|
|
6905
6761
|
var init_nonce = __esm({
|
|
6906
6762
|
"src/plugins/nonce.ts"() {
|
|
6907
6763
|
"use strict";
|
|
6908
|
-
|
|
6764
|
+
import_shared56 = require("@rsbuild/shared");
|
|
6909
6765
|
pluginNonce = () => ({
|
|
6910
6766
|
name: "rsbuild:nonce",
|
|
6911
6767
|
setup(api) {
|
|
@@ -6914,7 +6770,7 @@ var init_nonce = __esm({
|
|
|
6914
6770
|
if (!nonce) {
|
|
6915
6771
|
return;
|
|
6916
6772
|
}
|
|
6917
|
-
(0,
|
|
6773
|
+
(0, import_shared56.applyToCompiler)(compiler, (compiler2) => {
|
|
6918
6774
|
const { plugins } = compiler2.options;
|
|
6919
6775
|
const hasHTML = plugins.some(
|
|
6920
6776
|
(plugin) => plugin && plugin.constructor.name === "HtmlBasicPlugin"
|
|
@@ -6922,7 +6778,7 @@ var init_nonce = __esm({
|
|
|
6922
6778
|
if (!hasHTML) {
|
|
6923
6779
|
return;
|
|
6924
6780
|
}
|
|
6925
|
-
const injectCode = (0,
|
|
6781
|
+
const injectCode = (0, import_shared56.createVirtualModule)(
|
|
6926
6782
|
`__webpack_nonce__ = "${nonce}";`
|
|
6927
6783
|
);
|
|
6928
6784
|
new compiler2.webpack.EntryPlugin(compiler2.context, injectCode, {
|
|
@@ -6953,13 +6809,185 @@ var init_nonce = __esm({
|
|
|
6953
6809
|
}
|
|
6954
6810
|
});
|
|
6955
6811
|
|
|
6956
|
-
// src/
|
|
6957
|
-
var
|
|
6958
|
-
__export(
|
|
6959
|
-
|
|
6960
|
-
|
|
6961
|
-
});
|
|
6962
|
-
async function
|
|
6812
|
+
// src/server/prodServer.ts
|
|
6813
|
+
var prodServer_exports = {};
|
|
6814
|
+
__export(prodServer_exports, {
|
|
6815
|
+
RsbuildProdServer: () => RsbuildProdServer,
|
|
6816
|
+
startProdServer: () => startProdServer
|
|
6817
|
+
});
|
|
6818
|
+
async function startProdServer(context, config, { getPortSilently } = {}) {
|
|
6819
|
+
if (!(0, import_shared57.getNodeEnv)()) {
|
|
6820
|
+
(0, import_shared57.setNodeEnv)("production");
|
|
6821
|
+
}
|
|
6822
|
+
const { port, host, https } = await getServerConfig({
|
|
6823
|
+
config,
|
|
6824
|
+
getPortSilently
|
|
6825
|
+
});
|
|
6826
|
+
const { default: connect } = await import("../compiled/connect/index.js");
|
|
6827
|
+
const middlewares = connect();
|
|
6828
|
+
const serverConfig = config.server;
|
|
6829
|
+
const server = new RsbuildProdServer(
|
|
6830
|
+
{
|
|
6831
|
+
pwd: context.rootPath,
|
|
6832
|
+
output: {
|
|
6833
|
+
path: config.output.distPath.root || ROOT_DIST_DIR,
|
|
6834
|
+
assetPrefix: config.output.assetPrefix
|
|
6835
|
+
},
|
|
6836
|
+
serverConfig
|
|
6837
|
+
},
|
|
6838
|
+
middlewares
|
|
6839
|
+
);
|
|
6840
|
+
await context.hooks.onBeforeStartProdServer.call();
|
|
6841
|
+
const httpServer = await createHttpServer({
|
|
6842
|
+
serverConfig,
|
|
6843
|
+
middlewares: server.middlewares
|
|
6844
|
+
});
|
|
6845
|
+
await server.onInit(httpServer);
|
|
6846
|
+
return new Promise((resolve) => {
|
|
6847
|
+
httpServer.listen(
|
|
6848
|
+
{
|
|
6849
|
+
host,
|
|
6850
|
+
port
|
|
6851
|
+
},
|
|
6852
|
+
async () => {
|
|
6853
|
+
const routes = formatRoutes(
|
|
6854
|
+
context.entry,
|
|
6855
|
+
config.output.distPath.html,
|
|
6856
|
+
config.html.outputStructure
|
|
6857
|
+
);
|
|
6858
|
+
await context.hooks.onAfterStartProdServer.call({
|
|
6859
|
+
port,
|
|
6860
|
+
routes
|
|
6861
|
+
});
|
|
6862
|
+
const protocol = https ? "https" : "http";
|
|
6863
|
+
const urls = getAddressUrls({ protocol, port, host });
|
|
6864
|
+
printServerURLs({
|
|
6865
|
+
urls,
|
|
6866
|
+
port,
|
|
6867
|
+
routes,
|
|
6868
|
+
protocol,
|
|
6869
|
+
printUrls: serverConfig.printUrls
|
|
6870
|
+
});
|
|
6871
|
+
const onClose = () => {
|
|
6872
|
+
server.close();
|
|
6873
|
+
httpServer.close();
|
|
6874
|
+
};
|
|
6875
|
+
resolve({
|
|
6876
|
+
port,
|
|
6877
|
+
urls: urls.map((item) => item.url),
|
|
6878
|
+
server: {
|
|
6879
|
+
close: async () => {
|
|
6880
|
+
onClose();
|
|
6881
|
+
}
|
|
6882
|
+
}
|
|
6883
|
+
});
|
|
6884
|
+
}
|
|
6885
|
+
);
|
|
6886
|
+
});
|
|
6887
|
+
}
|
|
6888
|
+
var import_node_path27, import_shared57, RsbuildProdServer;
|
|
6889
|
+
var init_prodServer = __esm({
|
|
6890
|
+
"src/server/prodServer.ts"() {
|
|
6891
|
+
"use strict";
|
|
6892
|
+
import_node_path27 = require("path");
|
|
6893
|
+
import_shared57 = require("@rsbuild/shared");
|
|
6894
|
+
init_constants();
|
|
6895
|
+
init_helper();
|
|
6896
|
+
init_httpServer();
|
|
6897
|
+
init_middlewares();
|
|
6898
|
+
RsbuildProdServer = class {
|
|
6899
|
+
constructor(options, middlewares) {
|
|
6900
|
+
__publicField(this, "app");
|
|
6901
|
+
__publicField(this, "options");
|
|
6902
|
+
__publicField(this, "middlewares");
|
|
6903
|
+
this.options = options;
|
|
6904
|
+
this.middlewares = middlewares;
|
|
6905
|
+
}
|
|
6906
|
+
// Complete the preparation of services
|
|
6907
|
+
async onInit(app) {
|
|
6908
|
+
this.app = app;
|
|
6909
|
+
await this.applyDefaultMiddlewares();
|
|
6910
|
+
}
|
|
6911
|
+
async applyDefaultMiddlewares() {
|
|
6912
|
+
const { headers, proxy, historyApiFallback, compress } = this.options.serverConfig;
|
|
6913
|
+
if ((0, import_shared57.isDebug)()) {
|
|
6914
|
+
this.middlewares.use(await getRequestLoggerMiddleware());
|
|
6915
|
+
}
|
|
6916
|
+
if (compress) {
|
|
6917
|
+
const { default: compression } = await import("../compiled/http-compression/index.js");
|
|
6918
|
+
this.middlewares.use((req, res, next) => {
|
|
6919
|
+
compression({
|
|
6920
|
+
gzip: true,
|
|
6921
|
+
brotli: false
|
|
6922
|
+
})(req, res, next);
|
|
6923
|
+
});
|
|
6924
|
+
}
|
|
6925
|
+
if (headers) {
|
|
6926
|
+
this.middlewares.use((_req, res, next) => {
|
|
6927
|
+
for (const [key, value] of Object.entries(headers)) {
|
|
6928
|
+
res.setHeader(key, value);
|
|
6929
|
+
}
|
|
6930
|
+
next();
|
|
6931
|
+
});
|
|
6932
|
+
}
|
|
6933
|
+
if (proxy) {
|
|
6934
|
+
const { createProxyMiddleware: createProxyMiddleware2 } = await Promise.resolve().then(() => (init_proxy(), proxy_exports));
|
|
6935
|
+
const { middlewares, upgrade } = createProxyMiddleware2(proxy);
|
|
6936
|
+
for (const middleware of middlewares) {
|
|
6937
|
+
this.middlewares.use(middleware);
|
|
6938
|
+
}
|
|
6939
|
+
this.app.on("upgrade", upgrade);
|
|
6940
|
+
}
|
|
6941
|
+
this.applyStaticAssetMiddleware();
|
|
6942
|
+
if (historyApiFallback) {
|
|
6943
|
+
const { default: connectHistoryApiFallback } = await import("../compiled/connect-history-api-fallback/index.js");
|
|
6944
|
+
const historyApiFallbackMiddleware = connectHistoryApiFallback(
|
|
6945
|
+
historyApiFallback === true ? {} : historyApiFallback
|
|
6946
|
+
);
|
|
6947
|
+
this.middlewares.use(historyApiFallbackMiddleware);
|
|
6948
|
+
await this.applyStaticAssetMiddleware();
|
|
6949
|
+
}
|
|
6950
|
+
this.middlewares.use(faviconFallbackMiddleware);
|
|
6951
|
+
}
|
|
6952
|
+
async applyStaticAssetMiddleware() {
|
|
6953
|
+
const {
|
|
6954
|
+
output: { path: path13, assetPrefix },
|
|
6955
|
+
serverConfig: { htmlFallback },
|
|
6956
|
+
pwd
|
|
6957
|
+
} = this.options;
|
|
6958
|
+
const { default: sirv } = await import("../compiled/sirv/index.js");
|
|
6959
|
+
const assetMiddleware = sirv((0, import_node_path27.join)(pwd, path13), {
|
|
6960
|
+
etag: true,
|
|
6961
|
+
dev: true,
|
|
6962
|
+
ignores: ["favicon.ico"],
|
|
6963
|
+
single: htmlFallback === "index"
|
|
6964
|
+
});
|
|
6965
|
+
this.middlewares.use((req, res, next) => {
|
|
6966
|
+
const url2 = req.url;
|
|
6967
|
+
if (assetPrefix && url2?.startsWith(assetPrefix)) {
|
|
6968
|
+
req.url = url2.slice(assetPrefix.length);
|
|
6969
|
+
assetMiddleware(req, res, (...args) => {
|
|
6970
|
+
req.url = url2;
|
|
6971
|
+
next(...args);
|
|
6972
|
+
});
|
|
6973
|
+
} else {
|
|
6974
|
+
assetMiddleware(req, res, next);
|
|
6975
|
+
}
|
|
6976
|
+
});
|
|
6977
|
+
}
|
|
6978
|
+
close() {
|
|
6979
|
+
}
|
|
6980
|
+
};
|
|
6981
|
+
}
|
|
6982
|
+
});
|
|
6983
|
+
|
|
6984
|
+
// src/createRsbuild.ts
|
|
6985
|
+
var createRsbuild_exports = {};
|
|
6986
|
+
__export(createRsbuild_exports, {
|
|
6987
|
+
createRsbuild: () => createRsbuild,
|
|
6988
|
+
pickRsbuildConfig: () => pickRsbuildConfig
|
|
6989
|
+
});
|
|
6990
|
+
async function applyDefaultPlugins(pluginManager, context) {
|
|
6963
6991
|
const { pluginBasic: pluginBasic2 } = await Promise.resolve().then(() => (init_basic(), basic_exports));
|
|
6964
6992
|
const { pluginEntry: pluginEntry2 } = await Promise.resolve().then(() => (init_entry(), entry_exports));
|
|
6965
6993
|
const { pluginCache: pluginCache2 } = await Promise.resolve().then(() => (init_cache(), cache_exports));
|
|
@@ -7058,6 +7086,11 @@ async function createRsbuild(options = {}) {
|
|
|
7058
7086
|
rsbuildOptions,
|
|
7059
7087
|
setCssExtractPlugin
|
|
7060
7088
|
});
|
|
7089
|
+
const preview = async (options2) => {
|
|
7090
|
+
const { startProdServer: startProdServer2 } = await Promise.resolve().then(() => (init_prodServer(), prodServer_exports));
|
|
7091
|
+
const config = await initRsbuildConfig({ context, pluginManager });
|
|
7092
|
+
return startProdServer2(context, config, options2);
|
|
7093
|
+
};
|
|
7061
7094
|
const rsbuild = {
|
|
7062
7095
|
...(0, import_shared58.pick)(pluginManager, [
|
|
7063
7096
|
"addPlugins",
|
|
@@ -7083,13 +7116,13 @@ async function createRsbuild(options = {}) {
|
|
|
7083
7116
|
]),
|
|
7084
7117
|
...(0, import_shared58.pick)(providerInstance, [
|
|
7085
7118
|
"build",
|
|
7086
|
-
"preview",
|
|
7087
7119
|
"initConfigs",
|
|
7088
7120
|
"inspectConfig",
|
|
7089
7121
|
"createCompiler",
|
|
7090
7122
|
"createDevServer",
|
|
7091
7123
|
"startDevServer"
|
|
7092
7124
|
]),
|
|
7125
|
+
preview,
|
|
7093
7126
|
context: pluginAPI.context
|
|
7094
7127
|
};
|
|
7095
7128
|
if (rsbuildConfig.plugins) {
|
|
@@ -7105,6 +7138,7 @@ var init_createRsbuild = __esm({
|
|
|
7105
7138
|
import_shared58 = require("@rsbuild/shared");
|
|
7106
7139
|
init_createContext();
|
|
7107
7140
|
init_initPlugins();
|
|
7141
|
+
init_internal();
|
|
7108
7142
|
init_pluginHelper();
|
|
7109
7143
|
init_pluginManager();
|
|
7110
7144
|
getRspackProvider = async () => {
|
|
@@ -7201,68 +7235,9 @@ var init_init = __esm({
|
|
|
7201
7235
|
}
|
|
7202
7236
|
});
|
|
7203
7237
|
|
|
7204
|
-
// src/index.ts
|
|
7205
|
-
var src_exports = {};
|
|
7206
|
-
__export(src_exports, {
|
|
7207
|
-
PLUGIN_CSS_NAME: () => PLUGIN_CSS_NAME,
|
|
7208
|
-
PLUGIN_SWC_NAME: () => PLUGIN_SWC_NAME,
|
|
7209
|
-
__internalHelper: () => internal_exports,
|
|
7210
|
-
createRsbuild: () => createRsbuild,
|
|
7211
|
-
defineConfig: () => defineConfig,
|
|
7212
|
-
loadConfig: () => loadConfig,
|
|
7213
|
-
loadEnv: () => loadEnv,
|
|
7214
|
-
logger: () => import_shared62.logger,
|
|
7215
|
-
mergeRsbuildConfig: () => mergeRsbuildConfig,
|
|
7216
|
-
rspack: () => import_core10.rspack,
|
|
7217
|
-
version: () => version
|
|
7218
|
-
});
|
|
7219
|
-
module.exports = __toCommonJS(src_exports);
|
|
7220
|
-
var import_core10 = require("@rspack/core");
|
|
7221
|
-
|
|
7222
|
-
// src/internal.ts
|
|
7223
|
-
var internal_exports = {};
|
|
7224
|
-
__export(internal_exports, {
|
|
7225
|
-
applySwcDecoratorConfig: () => applySwcDecoratorConfig,
|
|
7226
|
-
createDevServer: () => createDevServer,
|
|
7227
|
-
createPluginManager: () => createPluginManager,
|
|
7228
|
-
formatStats: () => formatStats,
|
|
7229
|
-
getChainUtils: () => getChainUtils,
|
|
7230
|
-
getDevMiddleware: () => getDevMiddleware,
|
|
7231
|
-
getHTMLPlugin: () => getHTMLPlugin,
|
|
7232
|
-
getStatsOptions: () => getStatsOptions,
|
|
7233
|
-
getSwcMinimizerOptions: () => getSwcMinimizerOptions,
|
|
7234
|
-
initHooks: () => initHooks,
|
|
7235
|
-
initPlugins: () => initPlugins,
|
|
7236
|
-
initRsbuildConfig: () => initRsbuildConfig,
|
|
7237
|
-
outputInspectConfigFiles: () => outputInspectConfigFiles,
|
|
7238
|
-
prepareCli: () => prepareCli,
|
|
7239
|
-
runCli: () => runCli,
|
|
7240
|
-
setHTMLPlugin: () => setHTMLPlugin,
|
|
7241
|
-
startProdServer: () => startProdServer,
|
|
7242
|
-
stringifyConfig: () => stringifyConfig
|
|
7243
|
-
});
|
|
7244
|
-
|
|
7245
7238
|
// src/cli/commands.ts
|
|
7246
|
-
var import_node_fs5 = require("fs");
|
|
7247
|
-
var import_node_path28 = require("path");
|
|
7248
|
-
var import_shared60 = require("@rsbuild/shared");
|
|
7249
|
-
var import_commander = require("../compiled/commander/index.js");
|
|
7250
|
-
init_helpers();
|
|
7251
|
-
init_init();
|
|
7252
|
-
var applyCommonOptions = (command) => {
|
|
7253
|
-
command.option(
|
|
7254
|
-
"-c --config <config>",
|
|
7255
|
-
"specify the configuration file, can be a relative or absolute path"
|
|
7256
|
-
).option(
|
|
7257
|
-
"--env-mode <mode>",
|
|
7258
|
-
"specify the env mode to load the `.env.[mode]` file"
|
|
7259
|
-
);
|
|
7260
|
-
};
|
|
7261
|
-
var applyServerOptions = (command) => {
|
|
7262
|
-
command.option("-o --open [url]", "open the page in browser on startup").option("--port <port>", "specify a port number for server to listen").option("--host <host>", "specify the host that the server listens to");
|
|
7263
|
-
};
|
|
7264
7239
|
function runCli() {
|
|
7265
|
-
import_commander.program.name("rsbuild").usage("<command> [options]").version("0.7.
|
|
7240
|
+
import_commander.program.name("rsbuild").usage("<command> [options]").version("0.7.8");
|
|
7266
7241
|
const devCommand = import_commander.program.command("dev");
|
|
7267
7242
|
const buildCommand = import_commander.program.command("build");
|
|
7268
7243
|
const previewCommand = import_commander.program.command("preview");
|
|
@@ -7337,9 +7312,32 @@ function runCli() {
|
|
|
7337
7312
|
});
|
|
7338
7313
|
import_commander.program.parse();
|
|
7339
7314
|
}
|
|
7315
|
+
var import_node_fs5, import_node_path28, import_shared60, import_commander, applyCommonOptions, applyServerOptions;
|
|
7316
|
+
var init_commands = __esm({
|
|
7317
|
+
"src/cli/commands.ts"() {
|
|
7318
|
+
"use strict";
|
|
7319
|
+
import_node_fs5 = require("fs");
|
|
7320
|
+
import_node_path28 = require("path");
|
|
7321
|
+
import_shared60 = require("@rsbuild/shared");
|
|
7322
|
+
import_commander = require("../compiled/commander/index.js");
|
|
7323
|
+
init_helpers();
|
|
7324
|
+
init_init();
|
|
7325
|
+
applyCommonOptions = (command) => {
|
|
7326
|
+
command.option(
|
|
7327
|
+
"-c --config <config>",
|
|
7328
|
+
"specify the configuration file, can be a relative or absolute path"
|
|
7329
|
+
).option(
|
|
7330
|
+
"--env-mode <mode>",
|
|
7331
|
+
"specify the env mode to load the `.env.[mode]` file"
|
|
7332
|
+
);
|
|
7333
|
+
};
|
|
7334
|
+
applyServerOptions = (command) => {
|
|
7335
|
+
command.option("-o --open [url]", "open the page in browser on startup").option("--port <port>", "specify a port number for server to listen").option("--host <host>", "specify the host that the server listens to");
|
|
7336
|
+
};
|
|
7337
|
+
}
|
|
7338
|
+
});
|
|
7340
7339
|
|
|
7341
7340
|
// src/cli/prepare.ts
|
|
7342
|
-
var import_shared61 = require("@rsbuild/shared");
|
|
7343
7341
|
function initNodeEnv() {
|
|
7344
7342
|
if (!process.env.NODE_ENV) {
|
|
7345
7343
|
const command = process.argv[2];
|
|
@@ -7352,34 +7350,84 @@ function prepareCli() {
|
|
|
7352
7350
|
if (!npm_execpath || npm_execpath.includes("npx-cli.js") || npm_execpath.includes(".bun")) {
|
|
7353
7351
|
console.log();
|
|
7354
7352
|
}
|
|
7355
|
-
import_shared61.logger.greet(` ${`Rsbuild v${"0.7.
|
|
7353
|
+
import_shared61.logger.greet(` ${`Rsbuild v${"0.7.8"}`}
|
|
7356
7354
|
`);
|
|
7357
7355
|
}
|
|
7356
|
+
var import_shared61;
|
|
7357
|
+
var init_prepare = __esm({
|
|
7358
|
+
"src/cli/prepare.ts"() {
|
|
7359
|
+
"use strict";
|
|
7360
|
+
import_shared61 = require("@rsbuild/shared");
|
|
7361
|
+
}
|
|
7362
|
+
});
|
|
7358
7363
|
|
|
7359
7364
|
// src/internal.ts
|
|
7360
|
-
|
|
7361
|
-
|
|
7362
|
-
|
|
7363
|
-
|
|
7364
|
-
|
|
7365
|
-
|
|
7366
|
-
|
|
7367
|
-
|
|
7368
|
-
|
|
7369
|
-
|
|
7370
|
-
|
|
7371
|
-
|
|
7372
|
-
|
|
7373
|
-
|
|
7365
|
+
var internal_exports = {};
|
|
7366
|
+
__export(internal_exports, {
|
|
7367
|
+
applySwcDecoratorConfig: () => applySwcDecoratorConfig,
|
|
7368
|
+
createDevServer: () => createDevServer,
|
|
7369
|
+
createPluginManager: () => createPluginManager,
|
|
7370
|
+
formatStats: () => formatStats,
|
|
7371
|
+
getChainUtils: () => getChainUtils,
|
|
7372
|
+
getDevMiddleware: () => getDevMiddleware,
|
|
7373
|
+
getHTMLPlugin: () => getHTMLPlugin,
|
|
7374
|
+
getStatsOptions: () => getStatsOptions,
|
|
7375
|
+
getSwcMinimizerOptions: () => getSwcMinimizerOptions,
|
|
7376
|
+
initHooks: () => initHooks,
|
|
7377
|
+
initPlugins: () => initPlugins,
|
|
7378
|
+
initRsbuildConfig: () => initRsbuildConfig,
|
|
7379
|
+
outputInspectConfigFiles: () => outputInspectConfigFiles,
|
|
7380
|
+
prepareCli: () => prepareCli,
|
|
7381
|
+
runCli: () => runCli,
|
|
7382
|
+
setHTMLPlugin: () => setHTMLPlugin,
|
|
7383
|
+
stringifyConfig: () => stringifyConfig
|
|
7384
|
+
});
|
|
7385
|
+
var init_internal = __esm({
|
|
7386
|
+
"src/internal.ts"() {
|
|
7387
|
+
"use strict";
|
|
7388
|
+
init_commands();
|
|
7389
|
+
init_prepare();
|
|
7390
|
+
init_pluginManager();
|
|
7391
|
+
init_initHooks();
|
|
7392
|
+
init_initConfigs();
|
|
7393
|
+
init_config();
|
|
7394
|
+
init_pluginHelper();
|
|
7395
|
+
init_helpers();
|
|
7396
|
+
init_rspackConfig();
|
|
7397
|
+
init_swc();
|
|
7398
|
+
init_minimize();
|
|
7399
|
+
init_devMiddleware();
|
|
7400
|
+
init_devServer();
|
|
7401
|
+
}
|
|
7402
|
+
});
|
|
7374
7403
|
|
|
7375
7404
|
// src/index.ts
|
|
7405
|
+
var src_exports = {};
|
|
7406
|
+
__export(src_exports, {
|
|
7407
|
+
PLUGIN_CSS_NAME: () => PLUGIN_CSS_NAME,
|
|
7408
|
+
PLUGIN_SWC_NAME: () => PLUGIN_SWC_NAME,
|
|
7409
|
+
__internalHelper: () => internal_exports,
|
|
7410
|
+
createRsbuild: () => createRsbuild,
|
|
7411
|
+
defineConfig: () => defineConfig,
|
|
7412
|
+
ensureAssetPrefix: () => ensureAssetPrefix,
|
|
7413
|
+
loadConfig: () => loadConfig,
|
|
7414
|
+
loadEnv: () => loadEnv,
|
|
7415
|
+
logger: () => import_shared62.logger,
|
|
7416
|
+
mergeRsbuildConfig: () => mergeRsbuildConfig,
|
|
7417
|
+
rspack: () => import_core10.rspack,
|
|
7418
|
+
version: () => version
|
|
7419
|
+
});
|
|
7420
|
+
module.exports = __toCommonJS(src_exports);
|
|
7421
|
+
var import_core10 = require("@rspack/core");
|
|
7422
|
+
init_internal();
|
|
7376
7423
|
init_loadEnv();
|
|
7377
7424
|
init_createRsbuild();
|
|
7378
7425
|
init_config();
|
|
7379
7426
|
var import_shared62 = require("@rsbuild/shared");
|
|
7380
7427
|
init_mergeConfig();
|
|
7428
|
+
init_helpers();
|
|
7381
7429
|
init_constants();
|
|
7382
|
-
var version = "0.7.
|
|
7430
|
+
var version = "0.7.8";
|
|
7383
7431
|
// Annotate the CommonJS export names for ESM import in node:
|
|
7384
7432
|
0 && (module.exports = {
|
|
7385
7433
|
PLUGIN_CSS_NAME,
|
|
@@ -7387,6 +7435,7 @@ var version = "0.7.7";
|
|
|
7387
7435
|
__internalHelper,
|
|
7388
7436
|
createRsbuild,
|
|
7389
7437
|
defineConfig,
|
|
7438
|
+
ensureAssetPrefix,
|
|
7390
7439
|
loadConfig,
|
|
7391
7440
|
loadEnv,
|
|
7392
7441
|
logger,
|