@rsbuild/core 0.7.2 → 0.7.4
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 +20 -20
- package/compiled/postcss-load-config/index.js +102 -33
- package/compiled/postcss-load-config/package.json +1 -1
- package/compiled/postcss-loader/index.js +16 -16
- package/compiled/rspack-manifest-plugin/index.js +4 -4
- package/dist/index.cjs +569 -267
- package/dist/index.js +556 -275
- package/dist-types/config.d.ts +11 -1
- package/dist-types/constants.d.ts +21 -2
- package/dist-types/helpers.d.ts +2 -2
- package/dist-types/index.d.ts +1 -1
- package/dist-types/internal.d.ts +1 -0
- package/dist-types/plugins/nonce.d.ts +2 -0
- package/dist-types/plugins/{startUrl.d.ts → open.d.ts} +2 -1
- package/dist-types/plugins/sri.d.ts +2 -0
- package/dist-types/rspack/HtmlBasicPlugin.d.ts +2 -2
- package/dist-types/server/devServer.d.ts +1 -1
- package/dist-types/server/httpServer.d.ts +1 -1
- package/dist-types/server/middlewares.d.ts +1 -1
- package/dist-types/server/prodServer.d.ts +1 -1
- package/dist-types/server/socketServer.d.ts +1 -1
- package/package.json +6 -5
package/dist/index.js
CHANGED
|
@@ -23,12 +23,12 @@ var __publicField = (obj, key, value) => {
|
|
|
23
23
|
return value;
|
|
24
24
|
};
|
|
25
25
|
|
|
26
|
-
// ../../node_modules/.pnpm/@modern-js+module-tools@2.
|
|
26
|
+
// ../../node_modules/.pnpm/@modern-js+module-tools@2.52.0_eslint@9.4.0_typescript@5.4.5/node_modules/@modern-js/module-tools/shims/esm.js
|
|
27
27
|
import { fileURLToPath } from "url";
|
|
28
28
|
import path from "path";
|
|
29
29
|
var getFilename, getDirname, __dirname, __filename;
|
|
30
30
|
var init_esm = __esm({
|
|
31
|
-
"../../node_modules/.pnpm/@modern-js+module-tools@2.
|
|
31
|
+
"../../node_modules/.pnpm/@modern-js+module-tools@2.52.0_eslint@9.4.0_typescript@5.4.5/node_modules/@modern-js/module-tools/shims/esm.js"() {
|
|
32
32
|
"use strict";
|
|
33
33
|
getFilename = () => fileURLToPath(import.meta.url);
|
|
34
34
|
getDirname = () => path.dirname(getFilename());
|
|
@@ -118,19 +118,53 @@ var init_format = __esm({
|
|
|
118
118
|
|
|
119
119
|
// src/constants.ts
|
|
120
120
|
import { join } from "path";
|
|
121
|
-
var
|
|
121
|
+
var ROOT_DIST_DIR, HTML_DIST_DIR, SERVER_DIST_DIR, SERVICE_WORKER_DIST_DIR, JS_DIST_DIR, CSS_DIST_DIR, SVG_DIST_DIR, FONT_DIST_DIR, WASM_DIST_DIR, IMAGE_DIST_DIR, MEDIA_DIST_DIR, LOADER_PATH, STATIC_PATH, COMPILED_PATH, TS_CONFIG_FILE, DEFAULT_PORT, DEFAULT_DATA_URL_SIZE, DEFAULT_MOUNT_ID, DEFAULT_DEV_HOST, HTML_REGEX, CSS_REGEX, PLUGIN_SWC_NAME, PLUGIN_CSS_NAME, FONT_EXTENSIONS, IMAGE_EXTENSIONS, VIDEO_EXTENSIONS, AUDIO_EXTENSIONS;
|
|
122
122
|
var init_constants = __esm({
|
|
123
123
|
"src/constants.ts"() {
|
|
124
124
|
"use strict";
|
|
125
125
|
init_esm();
|
|
126
|
-
|
|
127
|
-
|
|
126
|
+
ROOT_DIST_DIR = "dist";
|
|
127
|
+
HTML_DIST_DIR = "/";
|
|
128
|
+
SERVER_DIST_DIR = "server";
|
|
129
|
+
SERVICE_WORKER_DIST_DIR = "worker";
|
|
130
|
+
JS_DIST_DIR = "static/js";
|
|
131
|
+
CSS_DIST_DIR = "static/css";
|
|
132
|
+
SVG_DIST_DIR = "static/svg";
|
|
133
|
+
FONT_DIST_DIR = "static/font";
|
|
134
|
+
WASM_DIST_DIR = "static/wasm";
|
|
135
|
+
IMAGE_DIST_DIR = "static/image";
|
|
136
|
+
MEDIA_DIST_DIR = "static/media";
|
|
128
137
|
LOADER_PATH = join(__dirname);
|
|
129
138
|
STATIC_PATH = join(__dirname, "../static");
|
|
130
139
|
COMPILED_PATH = join(__dirname, "../compiled");
|
|
131
140
|
TS_CONFIG_FILE = "tsconfig.json";
|
|
141
|
+
DEFAULT_PORT = 3e3;
|
|
142
|
+
DEFAULT_DATA_URL_SIZE = 4096;
|
|
143
|
+
DEFAULT_MOUNT_ID = "root";
|
|
144
|
+
DEFAULT_DEV_HOST = "0.0.0.0";
|
|
132
145
|
HTML_REGEX = /\.html$/;
|
|
133
146
|
CSS_REGEX = /\.css$/;
|
|
147
|
+
PLUGIN_SWC_NAME = "rsbuild:swc";
|
|
148
|
+
PLUGIN_CSS_NAME = "rsbuild:css";
|
|
149
|
+
FONT_EXTENSIONS = ["woff", "woff2", "eot", "ttf", "otf", "ttc"];
|
|
150
|
+
IMAGE_EXTENSIONS = [
|
|
151
|
+
"png",
|
|
152
|
+
"jpg",
|
|
153
|
+
"jpeg",
|
|
154
|
+
"pjpeg",
|
|
155
|
+
"pjp",
|
|
156
|
+
"gif",
|
|
157
|
+
"bmp",
|
|
158
|
+
"webp",
|
|
159
|
+
"ico",
|
|
160
|
+
"apng",
|
|
161
|
+
"avif",
|
|
162
|
+
"tif",
|
|
163
|
+
"tiff",
|
|
164
|
+
"jfif"
|
|
165
|
+
];
|
|
166
|
+
VIDEO_EXTENSIONS = ["mp4", "webm", "ogg", "mov"];
|
|
167
|
+
AUDIO_EXTENSIONS = ["mp3", "wav", "flac", "aac", "m4a", "opus"];
|
|
134
168
|
}
|
|
135
169
|
});
|
|
136
170
|
|
|
@@ -371,6 +405,7 @@ var init_mergeConfig = __esm({
|
|
|
371
405
|
"output.cssModules.auto",
|
|
372
406
|
"output.targets",
|
|
373
407
|
"output.emitAssets",
|
|
408
|
+
"server.open",
|
|
374
409
|
"server.printUrls",
|
|
375
410
|
"dev.startUrl",
|
|
376
411
|
"provider"
|
|
@@ -459,27 +494,15 @@ var init_restart = __esm({
|
|
|
459
494
|
import fs from "fs";
|
|
460
495
|
import { isAbsolute, join as join2 } from "path";
|
|
461
496
|
import {
|
|
462
|
-
CSS_DIST_DIR,
|
|
463
497
|
DEFAULT_ASSET_PREFIX as DEFAULT_ASSET_PREFIX2,
|
|
464
|
-
|
|
465
|
-
DEFAULT_DEV_HOST,
|
|
466
|
-
DEFAULT_MOUNT_ID,
|
|
467
|
-
DEFAULT_PORT,
|
|
468
|
-
FONT_DIST_DIR,
|
|
469
|
-
HTML_DIST_DIR,
|
|
470
|
-
IMAGE_DIST_DIR,
|
|
471
|
-
JS_DIST_DIR,
|
|
472
|
-
MEDIA_DIST_DIR,
|
|
473
|
-
ROOT_DIST_DIR,
|
|
474
|
-
SERVER_DIST_DIR,
|
|
475
|
-
SERVICE_WORKER_DIST_DIR,
|
|
476
|
-
SVG_DIST_DIR,
|
|
477
|
-
WASM_DIST_DIR,
|
|
498
|
+
RspackChain,
|
|
478
499
|
color as color3,
|
|
479
500
|
debounce,
|
|
501
|
+
fse as fse2,
|
|
480
502
|
getNodeEnv,
|
|
481
503
|
isObject,
|
|
482
|
-
logger as logger2
|
|
504
|
+
logger as logger2,
|
|
505
|
+
upperFirst
|
|
483
506
|
} from "@rsbuild/shared";
|
|
484
507
|
function getDefaultEntry(root) {
|
|
485
508
|
const files = [
|
|
@@ -583,6 +606,55 @@ async function loadConfig({
|
|
|
583
606
|
throw err;
|
|
584
607
|
}
|
|
585
608
|
}
|
|
609
|
+
async function outputInspectConfigFiles({
|
|
610
|
+
rsbuildConfig,
|
|
611
|
+
rawRsbuildConfig,
|
|
612
|
+
bundlerConfigs,
|
|
613
|
+
inspectOptions,
|
|
614
|
+
configType
|
|
615
|
+
}) {
|
|
616
|
+
const { outputPath } = inspectOptions;
|
|
617
|
+
const files = [
|
|
618
|
+
{
|
|
619
|
+
path: join2(outputPath, "rsbuild.config.mjs"),
|
|
620
|
+
label: "Rsbuild Config",
|
|
621
|
+
content: rawRsbuildConfig
|
|
622
|
+
},
|
|
623
|
+
...bundlerConfigs.map((content, index) => {
|
|
624
|
+
const suffix = rsbuildConfig.output.targets[index];
|
|
625
|
+
const outputFile = `${configType}.config.${suffix}.mjs`;
|
|
626
|
+
let outputFilePath = join2(outputPath, outputFile);
|
|
627
|
+
if (fse2.existsSync(outputFilePath)) {
|
|
628
|
+
outputFilePath = outputFilePath.replace(/\.mjs$/, `.${Date.now()}.mjs`);
|
|
629
|
+
}
|
|
630
|
+
return {
|
|
631
|
+
path: outputFilePath,
|
|
632
|
+
label: `${upperFirst(configType)} Config (${suffix})`,
|
|
633
|
+
content
|
|
634
|
+
};
|
|
635
|
+
})
|
|
636
|
+
];
|
|
637
|
+
await Promise.all(
|
|
638
|
+
files.map(
|
|
639
|
+
(item) => fse2.outputFile(item.path, `export default ${item.content}`)
|
|
640
|
+
)
|
|
641
|
+
);
|
|
642
|
+
const fileInfos = files.map(
|
|
643
|
+
(item) => ` - ${color3.bold(color3.yellow(item.label))}: ${color3.underline(
|
|
644
|
+
item.path
|
|
645
|
+
)}`
|
|
646
|
+
).join("\n");
|
|
647
|
+
logger2.success(
|
|
648
|
+
`Inspect config succeed, open following files to view the content:
|
|
649
|
+
|
|
650
|
+
${fileInfos}
|
|
651
|
+
`
|
|
652
|
+
);
|
|
653
|
+
}
|
|
654
|
+
async function stringifyConfig(config, verbose) {
|
|
655
|
+
const stringify = RspackChain.toString;
|
|
656
|
+
return stringify(config, { verbose });
|
|
657
|
+
}
|
|
586
658
|
var getDefaultDevConfig, getDefaultServerConfig, getDefaultSourceConfig, getDefaultHtmlConfig, getDefaultSecurityConfig, getDefaultToolsConfig, getDefaultPerformanceConfig, getDefaultOutputConfig, createDefaultConfig, withDefaultConfig, normalizeConfig, resolveConfigPath;
|
|
587
659
|
var init_config = __esm({
|
|
588
660
|
"src/config.ts"() {
|
|
@@ -604,6 +676,7 @@ var init_config = __esm({
|
|
|
604
676
|
getDefaultServerConfig = () => ({
|
|
605
677
|
port: DEFAULT_PORT,
|
|
606
678
|
host: DEFAULT_DEV_HOST,
|
|
679
|
+
open: false,
|
|
607
680
|
htmlFallback: "index",
|
|
608
681
|
compress: true,
|
|
609
682
|
printUrls: true,
|
|
@@ -636,7 +709,10 @@ var init_config = __esm({
|
|
|
636
709
|
scriptLoading: "defer"
|
|
637
710
|
});
|
|
638
711
|
getDefaultSecurityConfig = () => ({
|
|
639
|
-
nonce: ""
|
|
712
|
+
nonce: "",
|
|
713
|
+
sri: {
|
|
714
|
+
enable: false
|
|
715
|
+
}
|
|
640
716
|
});
|
|
641
717
|
getDefaultToolsConfig = () => ({
|
|
642
718
|
cssExtract: {
|
|
@@ -757,8 +833,8 @@ var init_config = __esm({
|
|
|
757
833
|
import fs2 from "fs";
|
|
758
834
|
import { join as join3 } from "path";
|
|
759
835
|
import { getNodeEnv as getNodeEnv2 } from "@rsbuild/shared";
|
|
760
|
-
import { expand } from "../compiled/dotenv-expand/index.js";
|
|
761
836
|
import { parse } from "../compiled/dotenv/index.js";
|
|
837
|
+
import { expand } from "../compiled/dotenv-expand/index.js";
|
|
762
838
|
function loadEnv({
|
|
763
839
|
cwd = process.cwd(),
|
|
764
840
|
mode = getNodeEnv2(),
|
|
@@ -889,17 +965,16 @@ import {
|
|
|
889
965
|
castArray as castArray2,
|
|
890
966
|
color as color4,
|
|
891
967
|
createVirtualModule,
|
|
892
|
-
|
|
968
|
+
reduceConfigsMergeContext
|
|
893
969
|
} from "@rsbuild/shared";
|
|
894
970
|
function getEntryObject(config, target) {
|
|
895
971
|
if (!config.source?.entry) {
|
|
896
972
|
return {};
|
|
897
973
|
}
|
|
898
|
-
return
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
useObjectParam: true
|
|
974
|
+
return reduceConfigsMergeContext({
|
|
975
|
+
initial: {},
|
|
976
|
+
config: config.source?.entry,
|
|
977
|
+
ctx: { target }
|
|
903
978
|
});
|
|
904
979
|
}
|
|
905
980
|
var pluginEntry;
|
|
@@ -967,7 +1042,7 @@ async function createContextByConfig(options, bundlerType, config = {}) {
|
|
|
967
1042
|
return {
|
|
968
1043
|
entry: getEntryObject(config, "web"),
|
|
969
1044
|
targets: config.output?.targets || [],
|
|
970
|
-
version: "0.7.
|
|
1045
|
+
version: "0.7.4",
|
|
971
1046
|
rootPath,
|
|
972
1047
|
distPath,
|
|
973
1048
|
cachePath,
|
|
@@ -1369,9 +1444,7 @@ __export(inspectConfig_exports, {
|
|
|
1369
1444
|
import { isAbsolute as isAbsolute3, join as join6 } from "path";
|
|
1370
1445
|
import {
|
|
1371
1446
|
getNodeEnv as getNodeEnv3,
|
|
1372
|
-
|
|
1373
|
-
setNodeEnv,
|
|
1374
|
-
stringifyConfig
|
|
1447
|
+
setNodeEnv
|
|
1375
1448
|
} from "@rsbuild/shared";
|
|
1376
1449
|
async function inspectConfig({
|
|
1377
1450
|
context,
|
|
@@ -1432,6 +1505,7 @@ var init_inspectConfig = __esm({
|
|
|
1432
1505
|
"src/provider/inspectConfig.ts"() {
|
|
1433
1506
|
"use strict";
|
|
1434
1507
|
init_esm();
|
|
1508
|
+
init_config();
|
|
1435
1509
|
init_initConfigs();
|
|
1436
1510
|
}
|
|
1437
1511
|
});
|
|
@@ -1443,8 +1517,8 @@ import {
|
|
|
1443
1517
|
chainToConfig,
|
|
1444
1518
|
debug as debug2,
|
|
1445
1519
|
getNodeEnv as getNodeEnv4,
|
|
1446
|
-
|
|
1447
|
-
|
|
1520
|
+
modifyBundlerChain,
|
|
1521
|
+
reduceConfigsAsyncWithContext
|
|
1448
1522
|
} from "@rsbuild/shared";
|
|
1449
1523
|
import { rspack as rspack2 } from "@rspack/core";
|
|
1450
1524
|
async function modifyRspackConfig(context, rspackConfig, utils) {
|
|
@@ -1454,10 +1528,10 @@ async function modifyRspackConfig(context, rspackConfig, utils) {
|
|
|
1454
1528
|
utils
|
|
1455
1529
|
);
|
|
1456
1530
|
if (context.config.tools?.rspack) {
|
|
1457
|
-
modifiedConfig =
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
utils,
|
|
1531
|
+
modifiedConfig = await reduceConfigsAsyncWithContext({
|
|
1532
|
+
initial: modifiedConfig,
|
|
1533
|
+
config: context.config.tools.rspack,
|
|
1534
|
+
ctx: utils,
|
|
1461
1535
|
mergeFn: utils.mergeConfig
|
|
1462
1536
|
});
|
|
1463
1537
|
}
|
|
@@ -2189,8 +2263,6 @@ var init_getDevMiddlewares = __esm({
|
|
|
2189
2263
|
import net from "net";
|
|
2190
2264
|
import os from "os";
|
|
2191
2265
|
import {
|
|
2192
|
-
DEFAULT_DEV_HOST as DEFAULT_DEV_HOST2,
|
|
2193
|
-
DEFAULT_PORT as DEFAULT_PORT2,
|
|
2194
2266
|
color as color8,
|
|
2195
2267
|
deepmerge,
|
|
2196
2268
|
isFunction as isFunction4,
|
|
@@ -2266,6 +2338,7 @@ var init_helper = __esm({
|
|
|
2266
2338
|
"src/server/helper.ts"() {
|
|
2267
2339
|
"use strict";
|
|
2268
2340
|
init_esm();
|
|
2341
|
+
init_constants();
|
|
2269
2342
|
formatPrefix = (prefix) => {
|
|
2270
2343
|
if (!prefix) {
|
|
2271
2344
|
return "/";
|
|
@@ -2340,10 +2413,10 @@ var init_helper = __esm({
|
|
|
2340
2413
|
config,
|
|
2341
2414
|
getPortSilently
|
|
2342
2415
|
}) => {
|
|
2343
|
-
const host = config.server.host ||
|
|
2416
|
+
const host = config.server.host || DEFAULT_DEV_HOST;
|
|
2344
2417
|
const port = await getPort({
|
|
2345
2418
|
host,
|
|
2346
|
-
port: config.server.port ||
|
|
2419
|
+
port: config.server.port || DEFAULT_PORT,
|
|
2347
2420
|
strictPort: config.server.strictPort || false,
|
|
2348
2421
|
silent: getPortSilently
|
|
2349
2422
|
});
|
|
@@ -2417,7 +2490,7 @@ var init_helper = __esm({
|
|
|
2417
2490
|
port,
|
|
2418
2491
|
host
|
|
2419
2492
|
}) => {
|
|
2420
|
-
if (host && host !==
|
|
2493
|
+
if (host && host !== DEFAULT_DEV_HOST) {
|
|
2421
2494
|
return [
|
|
2422
2495
|
{
|
|
2423
2496
|
label: isLoopbackHost(host) ? LOCAL_LABEL : NETWORK_LABEL,
|
|
@@ -2800,7 +2873,6 @@ __export(devServer_exports, {
|
|
|
2800
2873
|
});
|
|
2801
2874
|
import fs3 from "fs";
|
|
2802
2875
|
import {
|
|
2803
|
-
ROOT_DIST_DIR as ROOT_DIST_DIR2,
|
|
2804
2876
|
debug as debug6,
|
|
2805
2877
|
getNodeEnv as getNodeEnv5,
|
|
2806
2878
|
getPublicPathFromCompiler,
|
|
@@ -2892,7 +2964,7 @@ async function createDevServer(options, createDevMiddleware2, config, {
|
|
|
2892
2964
|
dev: devConfig,
|
|
2893
2965
|
server: serverConfig,
|
|
2894
2966
|
output: {
|
|
2895
|
-
distPath: config.output.distPath.root ||
|
|
2967
|
+
distPath: config.output.distPath.root || ROOT_DIST_DIR
|
|
2896
2968
|
},
|
|
2897
2969
|
outputFileSystem
|
|
2898
2970
|
});
|
|
@@ -2965,6 +3037,7 @@ var init_devServer = __esm({
|
|
|
2965
3037
|
"src/server/devServer.ts"() {
|
|
2966
3038
|
"use strict";
|
|
2967
3039
|
init_esm();
|
|
3040
|
+
init_constants();
|
|
2968
3041
|
init_getDevMiddlewares();
|
|
2969
3042
|
init_helper();
|
|
2970
3043
|
init_httpServer();
|
|
@@ -2982,7 +3055,6 @@ __export(prodServer_exports, {
|
|
|
2982
3055
|
});
|
|
2983
3056
|
import { join as join8 } from "path";
|
|
2984
3057
|
import {
|
|
2985
|
-
ROOT_DIST_DIR as ROOT_DIST_DIR3,
|
|
2986
3058
|
getNodeEnv as getNodeEnv6,
|
|
2987
3059
|
isDebug as isDebug4,
|
|
2988
3060
|
setNodeEnv as setNodeEnv3
|
|
@@ -3002,7 +3074,7 @@ async function startProdServer(context, config, { getPortSilently } = {}) {
|
|
|
3002
3074
|
{
|
|
3003
3075
|
pwd: context.rootPath,
|
|
3004
3076
|
output: {
|
|
3005
|
-
path: config.output.distPath.root ||
|
|
3077
|
+
path: config.output.distPath.root || ROOT_DIST_DIR,
|
|
3006
3078
|
assetPrefix: config.output.assetPrefix
|
|
3007
3079
|
},
|
|
3008
3080
|
serverConfig
|
|
@@ -3062,6 +3134,7 @@ var init_prodServer = __esm({
|
|
|
3062
3134
|
"src/server/prodServer.ts"() {
|
|
3063
3135
|
"use strict";
|
|
3064
3136
|
init_esm();
|
|
3137
|
+
init_constants();
|
|
3065
3138
|
init_helper();
|
|
3066
3139
|
init_httpServer();
|
|
3067
3140
|
init_middlewares();
|
|
@@ -3325,12 +3398,12 @@ var init_basic = __esm({
|
|
|
3325
3398
|
name: "rsbuild:basic",
|
|
3326
3399
|
setup(api) {
|
|
3327
3400
|
api.modifyBundlerChain(
|
|
3328
|
-
(chain, { env, isProd:
|
|
3401
|
+
(chain, { env, isProd: isProd5, target, bundler, CHAIN_ID: CHAIN_ID3 }) => {
|
|
3329
3402
|
const config = api.getNormalizedConfig();
|
|
3330
3403
|
chain.name(TARGET_ID_MAP2[target]);
|
|
3331
3404
|
chain.devtool(getJsSourceMap(config));
|
|
3332
3405
|
chain.context(api.context.rootPath);
|
|
3333
|
-
chain.mode(
|
|
3406
|
+
chain.mode(isProd5 ? "production" : "development");
|
|
3334
3407
|
chain.merge({
|
|
3335
3408
|
infrastructureLogging: {
|
|
3336
3409
|
// Using `error` level to avoid `cache.PackFileCacheStrategy` logs
|
|
@@ -3343,9 +3416,9 @@ var init_basic = __esm({
|
|
|
3343
3416
|
exportsPresence: "error"
|
|
3344
3417
|
}
|
|
3345
3418
|
});
|
|
3346
|
-
const isMinimize =
|
|
3419
|
+
const isMinimize = isProd5 && config.output.minify !== false;
|
|
3347
3420
|
chain.optimization.minimize(isMinimize);
|
|
3348
|
-
const usingHMR = isUsingHMR(config, { target, isProd:
|
|
3421
|
+
const usingHMR = isUsingHMR(config, { target, isProd: isProd5 });
|
|
3349
3422
|
if (usingHMR) {
|
|
3350
3423
|
chain.plugin(CHAIN_ID3.PLUGIN.HMR).use(bundler.HotModuleReplacementPlugin);
|
|
3351
3424
|
}
|
|
@@ -3370,17 +3443,17 @@ __export(cache_exports, {
|
|
|
3370
3443
|
});
|
|
3371
3444
|
import crypto from "crypto";
|
|
3372
3445
|
import { isAbsolute as isAbsolute5, join as join9 } from "path";
|
|
3373
|
-
import { fse as
|
|
3446
|
+
import { fse as fse3 } from "@rsbuild/shared";
|
|
3374
3447
|
async function validateCache(cacheDirectory, buildDependencies) {
|
|
3375
3448
|
const configFile = join9(cacheDirectory, "buildDependencies.json");
|
|
3376
3449
|
if (await isFileExists(configFile)) {
|
|
3377
|
-
const prevBuildDependencies = await
|
|
3450
|
+
const prevBuildDependencies = await fse3.readJSON(configFile);
|
|
3378
3451
|
if (JSON.stringify(prevBuildDependencies) === JSON.stringify(buildDependencies)) {
|
|
3379
3452
|
return;
|
|
3380
3453
|
}
|
|
3381
|
-
await
|
|
3454
|
+
await fse3.remove(cacheDirectory);
|
|
3382
3455
|
}
|
|
3383
|
-
await
|
|
3456
|
+
await fse3.outputJSON(configFile, buildDependencies);
|
|
3384
3457
|
}
|
|
3385
3458
|
function getDigestHash(digest) {
|
|
3386
3459
|
const fsHash = crypto.createHash("md5");
|
|
@@ -3516,7 +3589,8 @@ import {
|
|
|
3516
3589
|
getBrowserslistWithDefault as getBrowserslistWithDefault2,
|
|
3517
3590
|
isFunction as isFunction5,
|
|
3518
3591
|
isPlainObject as isPlainObject2,
|
|
3519
|
-
|
|
3592
|
+
reduceConfigs,
|
|
3593
|
+
reduceConfigsWithContext
|
|
3520
3594
|
} from "@rsbuild/shared";
|
|
3521
3595
|
async function loadUserPostcssrc(root) {
|
|
3522
3596
|
const cached = userPostcssrcCache.get(root);
|
|
@@ -3540,7 +3614,7 @@ async function applyCSSRule({
|
|
|
3540
3614
|
rule,
|
|
3541
3615
|
config,
|
|
3542
3616
|
context,
|
|
3543
|
-
utils: { target, isProd:
|
|
3617
|
+
utils: { target, isProd: isProd5, CHAIN_ID: CHAIN_ID3 },
|
|
3544
3618
|
importLoaders = 1
|
|
3545
3619
|
}) {
|
|
3546
3620
|
const browserslist = await getBrowserslistWithDefault2(
|
|
@@ -3549,7 +3623,7 @@ async function applyCSSRule({
|
|
|
3549
3623
|
target
|
|
3550
3624
|
);
|
|
3551
3625
|
const enableExtractCSS = isUseCssExtract(config, target);
|
|
3552
|
-
const localIdentName = getCSSModulesLocalIdentName(config,
|
|
3626
|
+
const localIdentName = getCSSModulesLocalIdentName(config, isProd5);
|
|
3553
3627
|
const cssLoaderOptions = getCSSLoaderOptions({
|
|
3554
3628
|
config,
|
|
3555
3629
|
importLoaders,
|
|
@@ -3560,9 +3634,9 @@ async function applyCSSRule({
|
|
|
3560
3634
|
if (enableExtractCSS) {
|
|
3561
3635
|
rule.use(CHAIN_ID3.USE.MINI_CSS_EXTRACT).loader(getCssExtractPlugin().loader).options(config.tools.cssExtract.loaderOptions).end();
|
|
3562
3636
|
} else {
|
|
3563
|
-
const styleLoaderOptions =
|
|
3564
|
-
|
|
3565
|
-
|
|
3637
|
+
const styleLoaderOptions = reduceConfigs({
|
|
3638
|
+
initial: {},
|
|
3639
|
+
config: config.tools.styleLoader
|
|
3566
3640
|
});
|
|
3567
3641
|
rule.use(CHAIN_ID3.USE.STYLE).loader(getCompiledPath("style-loader")).options(styleLoaderOptions).end();
|
|
3568
3642
|
}
|
|
@@ -3591,8 +3665,8 @@ var init_css = __esm({
|
|
|
3591
3665
|
init_pluginHelper();
|
|
3592
3666
|
enableNativeCss = (config) => !config.output.injectStyles;
|
|
3593
3667
|
isUseCssExtract = (config, target) => !config.output.injectStyles && target !== "node" && target !== "web-worker";
|
|
3594
|
-
getCSSModulesLocalIdentName = (config,
|
|
3595
|
-
(
|
|
3668
|
+
getCSSModulesLocalIdentName = (config, isProd5) => config.output.cssModules.localIdentName || // Using shorter classname in production to reduce bundle size
|
|
3669
|
+
(isProd5 ? "[local]-[hash:base64:6]" : "[path][name]__[local]-[hash:base64:6]");
|
|
3596
3670
|
normalizeCssLoaderOptions = (options, exportOnlyLocals) => {
|
|
3597
3671
|
if (options.modules && exportOnlyLocals) {
|
|
3598
3672
|
let { modules } = options;
|
|
@@ -3629,12 +3703,12 @@ var init_css = __esm({
|
|
|
3629
3703
|
});
|
|
3630
3704
|
if (!hasAutoprefixer) {
|
|
3631
3705
|
const { default: autoprefixer } = await import("@rsbuild/shared/autoprefixer");
|
|
3632
|
-
const autoprefixerOptions =
|
|
3633
|
-
|
|
3706
|
+
const autoprefixerOptions = reduceConfigs({
|
|
3707
|
+
initial: {
|
|
3634
3708
|
flexbox: "no-2009",
|
|
3635
3709
|
overrideBrowserslist: browserslist
|
|
3636
3710
|
},
|
|
3637
|
-
|
|
3711
|
+
config: config.tools.autoprefixer
|
|
3638
3712
|
});
|
|
3639
3713
|
pluginObjects.push(autoprefixer(autoprefixerOptions));
|
|
3640
3714
|
}
|
|
@@ -3669,10 +3743,10 @@ var init_css = __esm({
|
|
|
3669
3743
|
},
|
|
3670
3744
|
sourceMap: config.output.sourceMap.css
|
|
3671
3745
|
};
|
|
3672
|
-
const mergedConfig =
|
|
3673
|
-
|
|
3674
|
-
|
|
3675
|
-
utils
|
|
3746
|
+
const mergedConfig = reduceConfigsWithContext({
|
|
3747
|
+
initial: defaultPostcssConfig,
|
|
3748
|
+
config: config.tools.postcss,
|
|
3749
|
+
ctx: utils
|
|
3676
3750
|
});
|
|
3677
3751
|
if (extraPlugins.length) {
|
|
3678
3752
|
mergedConfig?.postcssOptions?.plugins.push(...extraPlugins);
|
|
@@ -3696,9 +3770,9 @@ var init_css = __esm({
|
|
|
3696
3770
|
},
|
|
3697
3771
|
sourceMap: config.output.sourceMap.css
|
|
3698
3772
|
};
|
|
3699
|
-
const mergedCssLoaderOptions =
|
|
3700
|
-
|
|
3701
|
-
|
|
3773
|
+
const mergedCssLoaderOptions = reduceConfigs({
|
|
3774
|
+
initial: defaultOptions2,
|
|
3775
|
+
config: config.tools.cssLoader,
|
|
3702
3776
|
mergeFn: deepmerge2
|
|
3703
3777
|
});
|
|
3704
3778
|
const cssLoaderOptions = normalizeCssLoaderOptions(
|
|
@@ -3741,20 +3815,18 @@ __export(output_exports, {
|
|
|
3741
3815
|
import { posix } from "path";
|
|
3742
3816
|
import {
|
|
3743
3817
|
DEFAULT_ASSET_PREFIX as DEFAULT_ASSET_PREFIX3,
|
|
3744
|
-
DEFAULT_DEV_HOST as DEFAULT_DEV_HOST3,
|
|
3745
|
-
DEFAULT_PORT as DEFAULT_PORT3,
|
|
3746
3818
|
getDistPath as getDistPath3,
|
|
3747
3819
|
getFilename as getFilename2
|
|
3748
3820
|
} from "@rsbuild/shared";
|
|
3749
3821
|
import { rspack as rspack5 } from "@rspack/core";
|
|
3750
3822
|
function getPublicPath({
|
|
3751
|
-
isProd:
|
|
3823
|
+
isProd: isProd5,
|
|
3752
3824
|
config,
|
|
3753
3825
|
context
|
|
3754
3826
|
}) {
|
|
3755
3827
|
const { dev, output } = config;
|
|
3756
3828
|
let publicPath = DEFAULT_ASSET_PREFIX3;
|
|
3757
|
-
if (
|
|
3829
|
+
if (isProd5) {
|
|
3758
3830
|
if (typeof output.assetPrefix === "string") {
|
|
3759
3831
|
publicPath = output.assetPrefix;
|
|
3760
3832
|
}
|
|
@@ -3762,9 +3834,9 @@ function getPublicPath({
|
|
|
3762
3834
|
publicPath = dev.assetPrefix;
|
|
3763
3835
|
} else if (dev.assetPrefix === true) {
|
|
3764
3836
|
const protocol = context.devServer?.https ? "https" : "http";
|
|
3765
|
-
const hostname = context.devServer?.hostname ||
|
|
3766
|
-
const port = context.devServer?.port ||
|
|
3767
|
-
if (hostname ===
|
|
3837
|
+
const hostname = context.devServer?.hostname || DEFAULT_DEV_HOST;
|
|
3838
|
+
const port = context.devServer?.port || DEFAULT_PORT;
|
|
3839
|
+
if (hostname === DEFAULT_DEV_HOST) {
|
|
3768
3840
|
const localHostname = "localhost";
|
|
3769
3841
|
publicPath = `${protocol}://${localHostname}:${port}/`;
|
|
3770
3842
|
} else {
|
|
@@ -3778,6 +3850,7 @@ var init_output = __esm({
|
|
|
3778
3850
|
"src/plugins/output.ts"() {
|
|
3779
3851
|
"use strict";
|
|
3780
3852
|
init_esm();
|
|
3853
|
+
init_constants();
|
|
3781
3854
|
init_helpers();
|
|
3782
3855
|
init_pluginHelper();
|
|
3783
3856
|
init_css();
|
|
@@ -3785,20 +3858,34 @@ var init_output = __esm({
|
|
|
3785
3858
|
name: "rsbuild:output",
|
|
3786
3859
|
setup(api) {
|
|
3787
3860
|
api.modifyBundlerChain(
|
|
3788
|
-
async (chain, { CHAIN_ID: CHAIN_ID3, target, isProd:
|
|
3861
|
+
async (chain, { CHAIN_ID: CHAIN_ID3, target, isProd: isProd5, isServer, isServiceWorker }) => {
|
|
3789
3862
|
const config = api.getNormalizedConfig();
|
|
3790
3863
|
const publicPath = getPublicPath({
|
|
3791
3864
|
config,
|
|
3792
|
-
isProd:
|
|
3865
|
+
isProd: isProd5,
|
|
3793
3866
|
context: api.context
|
|
3794
3867
|
});
|
|
3795
3868
|
const jsPath = getDistPath3(config, "js");
|
|
3796
3869
|
const jsAsyncPath = getDistPath3(config, "jsAsync");
|
|
3797
|
-
const jsFilename = getFilename2(config, "js",
|
|
3798
|
-
|
|
3870
|
+
const jsFilename = getFilename2(config, "js", isProd5);
|
|
3871
|
+
const isJsFilenameFn = typeof jsFilename === "function";
|
|
3872
|
+
chain.output.path(api.context.distPath).filename(
|
|
3873
|
+
isJsFilenameFn ? (...args) => {
|
|
3874
|
+
const name = jsFilename(...args);
|
|
3875
|
+
return posix.join(jsPath, name);
|
|
3876
|
+
} : posix.join(jsPath, jsFilename)
|
|
3877
|
+
).chunkFilename(
|
|
3878
|
+
isJsFilenameFn ? (...args) => {
|
|
3879
|
+
const name = jsFilename(...args);
|
|
3880
|
+
return posix.join(jsAsyncPath, name);
|
|
3881
|
+
} : posix.join(jsAsyncPath, jsFilename)
|
|
3882
|
+
).publicPath(publicPath).pathinfo(false).hashFunction("xxhash64");
|
|
3799
3883
|
if (isServer) {
|
|
3800
3884
|
const serverPath = getDistPath3(config, "server");
|
|
3801
|
-
chain.output.path(posix.join(api.context.distPath, serverPath)).filename("[name].js").chunkFilename("[name].js").
|
|
3885
|
+
chain.output.path(posix.join(api.context.distPath, serverPath)).filename("[name].js").chunkFilename("[name].js").library({
|
|
3886
|
+
...chain.output.get("library") || {},
|
|
3887
|
+
type: "commonjs2"
|
|
3888
|
+
});
|
|
3802
3889
|
}
|
|
3803
3890
|
if (isServiceWorker) {
|
|
3804
3891
|
const workerPath = getDistPath3(config, "worker");
|
|
@@ -3813,7 +3900,7 @@ var init_output = __esm({
|
|
|
3813
3900
|
if (isUseCssExtract(config, target)) {
|
|
3814
3901
|
const extractPluginOptions = config.tools.cssExtract.pluginOptions;
|
|
3815
3902
|
const cssPath = getDistPath3(config, "css");
|
|
3816
|
-
const cssFilename = getFilename2(config, "css",
|
|
3903
|
+
const cssFilename = getFilename2(config, "css", isProd5);
|
|
3817
3904
|
const cssAsyncPath = getDistPath3(config, "cssAsync");
|
|
3818
3905
|
chain.plugin(CHAIN_ID3.PLUGIN.MINI_CSS_EXTRACT).use(getCssExtractPlugin(), [
|
|
3819
3906
|
{
|
|
@@ -3837,7 +3924,7 @@ __export(resolve_exports, {
|
|
|
3837
3924
|
});
|
|
3838
3925
|
import {
|
|
3839
3926
|
castArray as castArray4,
|
|
3840
|
-
|
|
3927
|
+
reduceConfigsWithContext as reduceConfigsWithContext2
|
|
3841
3928
|
} from "@rsbuild/shared";
|
|
3842
3929
|
function applyFullySpecified({
|
|
3843
3930
|
chain,
|
|
@@ -3867,10 +3954,10 @@ function applyAlias({
|
|
|
3867
3954
|
if (!alias) {
|
|
3868
3955
|
return;
|
|
3869
3956
|
}
|
|
3870
|
-
const mergedAlias =
|
|
3871
|
-
|
|
3872
|
-
|
|
3873
|
-
|
|
3957
|
+
const mergedAlias = reduceConfigsWithContext2({
|
|
3958
|
+
initial: {},
|
|
3959
|
+
config: alias,
|
|
3960
|
+
ctx: { target }
|
|
3874
3961
|
});
|
|
3875
3962
|
for (const name of Object.keys(mergedAlias)) {
|
|
3876
3963
|
const values = castArray4(mergedAlias[name]);
|
|
@@ -3929,7 +4016,7 @@ __export(fileSize_exports, {
|
|
|
3929
4016
|
pluginFileSize: () => pluginFileSize
|
|
3930
4017
|
});
|
|
3931
4018
|
import path7 from "path";
|
|
3932
|
-
import { JS_REGEX, fse as
|
|
4019
|
+
import { JS_REGEX, fse as fse4 } from "@rsbuild/shared";
|
|
3933
4020
|
import { color as color9, logger as logger11 } from "@rsbuild/shared";
|
|
3934
4021
|
async function printHeader(longestFileLength, longestLabelLength) {
|
|
3935
4022
|
const longestLengths = [longestFileLength, longestLabelLength];
|
|
@@ -3950,7 +4037,7 @@ async function printFileSizes(config, stats, rootPath) {
|
|
|
3950
4037
|
const { default: gzipSize } = await import("@rsbuild/shared/gzip-size");
|
|
3951
4038
|
const formatAsset = (asset, distPath, distFolder) => {
|
|
3952
4039
|
const fileName = asset.name.split("?")[0];
|
|
3953
|
-
const contents =
|
|
4040
|
+
const contents = fse4.readFileSync(path7.join(distPath, fileName));
|
|
3954
4041
|
const size = contents.length;
|
|
3955
4042
|
const gzippedSize = gzipSize.sync(contents);
|
|
3956
4043
|
return {
|
|
@@ -4103,15 +4190,15 @@ __export(cleanOutput_exports, {
|
|
|
4103
4190
|
pluginCleanOutput: () => pluginCleanOutput
|
|
4104
4191
|
});
|
|
4105
4192
|
import { sep } from "path";
|
|
4106
|
-
import { color as color10, fse as
|
|
4193
|
+
import { color as color10, fse as fse5, logger as logger12 } from "@rsbuild/shared";
|
|
4107
4194
|
var emptyDir, addTrailingSep, isStrictSubdir, pluginCleanOutput;
|
|
4108
4195
|
var init_cleanOutput = __esm({
|
|
4109
4196
|
"src/plugins/cleanOutput.ts"() {
|
|
4110
4197
|
"use strict";
|
|
4111
4198
|
init_esm();
|
|
4112
4199
|
emptyDir = async (dir) => {
|
|
4113
|
-
if (await
|
|
4114
|
-
await
|
|
4200
|
+
if (await fse5.pathExists(dir)) {
|
|
4201
|
+
await fse5.emptyDir(dir);
|
|
4115
4202
|
}
|
|
4116
4203
|
};
|
|
4117
4204
|
addTrailingSep = (dir) => dir.endsWith(sep) ? dir : dir + sep;
|
|
@@ -4158,14 +4245,7 @@ __export(asset_exports, {
|
|
|
4158
4245
|
pluginAsset: () => pluginAsset
|
|
4159
4246
|
});
|
|
4160
4247
|
import path8 from "path";
|
|
4161
|
-
import {
|
|
4162
|
-
AUDIO_EXTENSIONS,
|
|
4163
|
-
FONT_EXTENSIONS,
|
|
4164
|
-
IMAGE_EXTENSIONS,
|
|
4165
|
-
VIDEO_EXTENSIONS,
|
|
4166
|
-
getDistPath as getDistPath4,
|
|
4167
|
-
getFilename as getFilename3
|
|
4168
|
-
} from "@rsbuild/shared";
|
|
4248
|
+
import { getDistPath as getDistPath4, getFilename as getFilename3 } from "@rsbuild/shared";
|
|
4169
4249
|
function getRegExpForExts(exts) {
|
|
4170
4250
|
const matcher = exts.map((ext) => ext.trim()).map((ext) => ext.startsWith(".") ? ext.slice(1) : ext).join("|");
|
|
4171
4251
|
return new RegExp(
|
|
@@ -4178,6 +4258,7 @@ var init_asset = __esm({
|
|
|
4178
4258
|
"src/plugins/asset.ts"() {
|
|
4179
4259
|
"use strict";
|
|
4180
4260
|
init_esm();
|
|
4261
|
+
init_constants();
|
|
4181
4262
|
chainStaticAssetRule = ({
|
|
4182
4263
|
emit,
|
|
4183
4264
|
rule,
|
|
@@ -4202,12 +4283,12 @@ var init_asset = __esm({
|
|
|
4202
4283
|
pluginAsset = () => ({
|
|
4203
4284
|
name: "rsbuild:asset",
|
|
4204
4285
|
setup(api) {
|
|
4205
|
-
api.modifyBundlerChain((chain, { isProd:
|
|
4286
|
+
api.modifyBundlerChain((chain, { isProd: isProd5, target }) => {
|
|
4206
4287
|
const config = api.getNormalizedConfig();
|
|
4207
4288
|
const createAssetRule = (assetType, exts, emit2) => {
|
|
4208
4289
|
const regExp = getRegExpForExts(exts);
|
|
4209
4290
|
const distDir = getDistPath4(config, assetType);
|
|
4210
|
-
const filename = getFilename3(config, assetType,
|
|
4291
|
+
const filename = getFilename3(config, assetType, isProd5);
|
|
4211
4292
|
const { dataUriLimit } = config.output;
|
|
4212
4293
|
const maxSize = typeof dataUriLimit === "number" ? dataUriLimit : dataUriLimit[assetType];
|
|
4213
4294
|
const rule = chain.module.rule(assetType).test(regExp);
|
|
@@ -4290,9 +4371,9 @@ var init_minimize = __esm({
|
|
|
4290
4371
|
}
|
|
4291
4372
|
return options;
|
|
4292
4373
|
};
|
|
4293
|
-
parseMinifyOptions = (config,
|
|
4374
|
+
parseMinifyOptions = (config, isProd5 = true) => {
|
|
4294
4375
|
const minify = config.output.minify;
|
|
4295
|
-
if (minify === false || !
|
|
4376
|
+
if (minify === false || !isProd5) {
|
|
4296
4377
|
return {
|
|
4297
4378
|
minifyJs: false,
|
|
4298
4379
|
minifyCss: false,
|
|
@@ -4324,9 +4405,9 @@ var init_minimize = __esm({
|
|
|
4324
4405
|
if (api.context.bundlerType === "webpack") {
|
|
4325
4406
|
return;
|
|
4326
4407
|
}
|
|
4327
|
-
api.modifyBundlerChain(async (chain, { isProd:
|
|
4408
|
+
api.modifyBundlerChain(async (chain, { isProd: isProd5 }) => {
|
|
4328
4409
|
const config = api.getNormalizedConfig();
|
|
4329
|
-
const isMinimize =
|
|
4410
|
+
const isMinimize = isProd5 && config.output.minify !== false;
|
|
4330
4411
|
if (!isMinimize) {
|
|
4331
4412
|
return;
|
|
4332
4413
|
}
|
|
@@ -4534,13 +4615,18 @@ var init_HtmlBasicPlugin = __esm({
|
|
|
4534
4615
|
addTitleTag(headTags, data.plugin.options?.title);
|
|
4535
4616
|
}
|
|
4536
4617
|
addFavicon(headTags, favicon);
|
|
4537
|
-
const
|
|
4618
|
+
const tags = {
|
|
4538
4619
|
headTags: headTags.map(formatBasicTag),
|
|
4539
4620
|
bodyTags: bodyTags.map(formatBasicTag)
|
|
4540
|
-
}
|
|
4621
|
+
};
|
|
4622
|
+
const modified = this.modifyTagsFn ? await this.modifyTagsFn(tags, {
|
|
4623
|
+
compilation,
|
|
4624
|
+
assetPrefix: data.publicPath,
|
|
4625
|
+
filename: data.outputName
|
|
4626
|
+
}) : tags;
|
|
4541
4627
|
Object.assign(data, {
|
|
4542
|
-
headTags:
|
|
4543
|
-
bodyTags:
|
|
4628
|
+
headTags: modified.headTags.map(fromBasicTag),
|
|
4629
|
+
bodyTags: modified.bodyTags.map(fromBasicTag)
|
|
4544
4630
|
});
|
|
4545
4631
|
if (tagConfig) {
|
|
4546
4632
|
const hash = compilation.hash ?? "";
|
|
@@ -4636,18 +4722,16 @@ __export(html_exports, {
|
|
|
4636
4722
|
});
|
|
4637
4723
|
import path9, { isAbsolute as isAbsolute6 } from "path";
|
|
4638
4724
|
import {
|
|
4639
|
-
applyToCompiler as applyToCompiler2,
|
|
4640
4725
|
castArray as castArray5,
|
|
4641
4726
|
color as color11,
|
|
4642
|
-
createVirtualModule as createVirtualModule2,
|
|
4643
4727
|
deepmerge as deepmerge4,
|
|
4644
|
-
fse as
|
|
4728
|
+
fse as fse6,
|
|
4645
4729
|
getDistPath as getDistPath5,
|
|
4646
4730
|
isHtmlDisabled,
|
|
4647
|
-
isNil,
|
|
4648
4731
|
isPlainObject as isPlainObject3,
|
|
4649
4732
|
isURL,
|
|
4650
|
-
|
|
4733
|
+
reduceConfigsMergeContext as reduceConfigsMergeContext2,
|
|
4734
|
+
reduceConfigsWithContext as reduceConfigsWithContext3
|
|
4651
4735
|
} from "@rsbuild/shared";
|
|
4652
4736
|
function applyRemoveConsole(options, config) {
|
|
4653
4737
|
const { removeConsole } = config.performance;
|
|
@@ -4681,8 +4765,8 @@ function getTerserMinifyOptions(config) {
|
|
|
4681
4765
|
const finalOptions = applyRemoveConsole(options, config);
|
|
4682
4766
|
return finalOptions;
|
|
4683
4767
|
}
|
|
4684
|
-
async function getHtmlMinifyOptions(
|
|
4685
|
-
if (!
|
|
4768
|
+
async function getHtmlMinifyOptions(isProd5, config) {
|
|
4769
|
+
if (!isProd5 || !config.output.minify || !parseMinifyOptions(config).minifyHtml) {
|
|
4686
4770
|
return false;
|
|
4687
4771
|
}
|
|
4688
4772
|
const minifyJS = getTerserMinifyOptions(config);
|
|
@@ -4703,29 +4787,25 @@ async function getHtmlMinifyOptions(isProd4, config) {
|
|
|
4703
4787
|
return typeof htmlMinifyOptions === "object" ? deepmerge4(htmlMinifyDefaultOptions, htmlMinifyOptions) : htmlMinifyDefaultOptions;
|
|
4704
4788
|
}
|
|
4705
4789
|
function getTitle(entryName, config) {
|
|
4706
|
-
return
|
|
4707
|
-
|
|
4708
|
-
|
|
4709
|
-
|
|
4710
|
-
useObjectParam: true
|
|
4790
|
+
return reduceConfigsMergeContext2({
|
|
4791
|
+
initial: "",
|
|
4792
|
+
config: config.html.title,
|
|
4793
|
+
ctx: { entryName }
|
|
4711
4794
|
});
|
|
4712
4795
|
}
|
|
4713
4796
|
function getInject(entryName, config) {
|
|
4714
|
-
return
|
|
4715
|
-
|
|
4716
|
-
|
|
4717
|
-
|
|
4718
|
-
useObjectParam: true,
|
|
4719
|
-
isFalsy: isNil
|
|
4797
|
+
return reduceConfigsMergeContext2({
|
|
4798
|
+
initial: "head",
|
|
4799
|
+
config: config.html.inject,
|
|
4800
|
+
ctx: { entryName }
|
|
4720
4801
|
});
|
|
4721
4802
|
}
|
|
4722
4803
|
async function getTemplate(entryName, config, rootPath) {
|
|
4723
4804
|
const DEFAULT_TEMPLATE = path9.resolve(STATIC_PATH, "template.html");
|
|
4724
|
-
const templatePath =
|
|
4725
|
-
|
|
4726
|
-
|
|
4727
|
-
|
|
4728
|
-
useObjectParam: true
|
|
4805
|
+
const templatePath = reduceConfigsMergeContext2({
|
|
4806
|
+
initial: DEFAULT_TEMPLATE,
|
|
4807
|
+
config: config.html.template,
|
|
4808
|
+
ctx: { entryName }
|
|
4729
4809
|
});
|
|
4730
4810
|
if (templatePath === DEFAULT_TEMPLATE) {
|
|
4731
4811
|
return {
|
|
@@ -4743,26 +4823,24 @@ async function getTemplate(entryName, config, rootPath) {
|
|
|
4743
4823
|
}
|
|
4744
4824
|
existTemplatePath.push(absolutePath);
|
|
4745
4825
|
}
|
|
4746
|
-
const templateContent = await
|
|
4826
|
+
const templateContent = await fse6.readFile(absolutePath, "utf-8");
|
|
4747
4827
|
return {
|
|
4748
4828
|
templatePath: absolutePath,
|
|
4749
4829
|
templateContent
|
|
4750
4830
|
};
|
|
4751
4831
|
}
|
|
4752
4832
|
function getFavicon(entryName, config) {
|
|
4753
|
-
return
|
|
4754
|
-
|
|
4755
|
-
|
|
4756
|
-
|
|
4757
|
-
useObjectParam: true
|
|
4833
|
+
return reduceConfigsMergeContext2({
|
|
4834
|
+
initial: "",
|
|
4835
|
+
config: config.html.favicon,
|
|
4836
|
+
ctx: { entryName }
|
|
4758
4837
|
});
|
|
4759
4838
|
}
|
|
4760
4839
|
function getMetaTags(entryName, config, templateContent) {
|
|
4761
|
-
const metaTags =
|
|
4762
|
-
|
|
4763
|
-
|
|
4764
|
-
|
|
4765
|
-
useObjectParam: true
|
|
4840
|
+
const metaTags = reduceConfigsMergeContext2({
|
|
4841
|
+
initial: {},
|
|
4842
|
+
config: config.html.meta,
|
|
4843
|
+
ctx: { entryName }
|
|
4766
4844
|
});
|
|
4767
4845
|
if (templateContent && metaTags.charset) {
|
|
4768
4846
|
const charsetRegExp = /<meta[^>]+charset=["'][^>]*>/i;
|
|
@@ -4787,10 +4865,10 @@ function getTemplateParameters(entryName, config, assetPrefix) {
|
|
|
4787
4865
|
options: pluginOptions
|
|
4788
4866
|
}
|
|
4789
4867
|
};
|
|
4790
|
-
return
|
|
4791
|
-
|
|
4792
|
-
|
|
4793
|
-
|
|
4868
|
+
return reduceConfigsWithContext3({
|
|
4869
|
+
initial: defaultOptions2,
|
|
4870
|
+
config: templateParameters,
|
|
4871
|
+
ctx: { entryName }
|
|
4794
4872
|
});
|
|
4795
4873
|
};
|
|
4796
4874
|
}
|
|
@@ -4838,12 +4916,12 @@ var init_html = __esm({
|
|
|
4838
4916
|
name: "rsbuild:html",
|
|
4839
4917
|
setup(api) {
|
|
4840
4918
|
api.modifyBundlerChain(
|
|
4841
|
-
async (chain, { HtmlPlugin, isProd:
|
|
4919
|
+
async (chain, { HtmlPlugin, isProd: isProd5, CHAIN_ID: CHAIN_ID3, target }) => {
|
|
4842
4920
|
const config = api.getNormalizedConfig();
|
|
4843
4921
|
if (isHtmlDisabled(config, target)) {
|
|
4844
4922
|
return;
|
|
4845
4923
|
}
|
|
4846
|
-
const minify = await getHtmlMinifyOptions(
|
|
4924
|
+
const minify = await getHtmlMinifyOptions(isProd5, config);
|
|
4847
4925
|
const assetPrefix = getPublicPathFromChain(chain, false);
|
|
4848
4926
|
const entries = chain.entryPoints.entries() || {};
|
|
4849
4927
|
const entryNames = Object.keys(entries);
|
|
@@ -4852,11 +4930,7 @@ var init_html = __esm({
|
|
|
4852
4930
|
const finalOptions = await Promise.all(
|
|
4853
4931
|
entryNames.map(async (entryName) => {
|
|
4854
4932
|
const entryValue = entries[entryName].values();
|
|
4855
|
-
const chunks = getChunks(
|
|
4856
|
-
entryName,
|
|
4857
|
-
// EntryDescription type is different between webpack and Rspack
|
|
4858
|
-
entryValue
|
|
4859
|
-
);
|
|
4933
|
+
const chunks = getChunks(entryName, entryValue);
|
|
4860
4934
|
const inject = getInject(entryName, config);
|
|
4861
4935
|
const filename = htmlPaths[entryName];
|
|
4862
4936
|
const { templatePath, templateContent } = await getTemplate(
|
|
@@ -4902,13 +4976,10 @@ var init_html = __esm({
|
|
|
4902
4976
|
pluginOptions.favicon = favicon;
|
|
4903
4977
|
}
|
|
4904
4978
|
}
|
|
4905
|
-
const finalOptions2 =
|
|
4906
|
-
|
|
4907
|
-
|
|
4908
|
-
|
|
4909
|
-
entryName,
|
|
4910
|
-
entryValue
|
|
4911
|
-
}
|
|
4979
|
+
const finalOptions2 = reduceConfigsWithContext3({
|
|
4980
|
+
initial: pluginOptions,
|
|
4981
|
+
config: typeof config.tools.htmlPlugin === "boolean" ? {} : config.tools.htmlPlugin,
|
|
4982
|
+
ctx: { entryName, entryValue }
|
|
4912
4983
|
});
|
|
4913
4984
|
return finalOptions2;
|
|
4914
4985
|
})
|
|
@@ -4933,52 +5004,21 @@ var init_html = __esm({
|
|
|
4933
5004
|
}
|
|
4934
5005
|
}
|
|
4935
5006
|
);
|
|
4936
|
-
api.onAfterCreateCompiler(({ compiler }) => {
|
|
4937
|
-
const { nonce } = api.getNormalizedConfig().security;
|
|
4938
|
-
if (!nonce) {
|
|
4939
|
-
return;
|
|
4940
|
-
}
|
|
4941
|
-
applyToCompiler2(compiler, (compiler2) => {
|
|
4942
|
-
const { plugins } = compiler2.options;
|
|
4943
|
-
const hasHTML = plugins.some(
|
|
4944
|
-
(plugin) => plugin && plugin.constructor.name === "HtmlBasicPlugin"
|
|
4945
|
-
);
|
|
4946
|
-
if (!hasHTML) {
|
|
4947
|
-
return;
|
|
4948
|
-
}
|
|
4949
|
-
const injectCode = createVirtualModule2(
|
|
4950
|
-
`__webpack_nonce__ = "${nonce}";`
|
|
4951
|
-
);
|
|
4952
|
-
new compiler2.webpack.EntryPlugin(compiler2.context, injectCode, {
|
|
4953
|
-
name: void 0
|
|
4954
|
-
}).apply(compiler2);
|
|
4955
|
-
});
|
|
4956
|
-
});
|
|
4957
5007
|
api.modifyHTMLTags({
|
|
4958
5008
|
// ensure `crossorigin` and `nonce` can be applied to all tags
|
|
4959
5009
|
order: "post",
|
|
4960
5010
|
handler: ({ headTags, bodyTags }) => {
|
|
4961
5011
|
const config = api.getNormalizedConfig();
|
|
4962
5012
|
const { crossorigin } = config.html;
|
|
4963
|
-
const { nonce } = config.security;
|
|
4964
5013
|
const allTags = [...headTags, ...bodyTags];
|
|
4965
5014
|
if (crossorigin) {
|
|
4966
5015
|
const formattedCrossorigin = crossorigin === true ? "anonymous" : crossorigin;
|
|
4967
5016
|
for (const tag of allTags) {
|
|
4968
5017
|
if (tag.tag === "script" && tag.attrs?.src || tag.tag === "link" && tag.attrs?.rel === "stylesheet") {
|
|
4969
|
-
tag.attrs ||= {};
|
|
4970
5018
|
tag.attrs.crossorigin ??= formattedCrossorigin;
|
|
4971
5019
|
}
|
|
4972
5020
|
}
|
|
4973
5021
|
}
|
|
4974
|
-
if (nonce) {
|
|
4975
|
-
for (const tag of allTags) {
|
|
4976
|
-
if (tag.tag === "script" || tag.tag === "style") {
|
|
4977
|
-
tag.attrs ??= {};
|
|
4978
|
-
tag.attrs.nonce = nonce;
|
|
4979
|
-
}
|
|
4980
|
-
}
|
|
4981
|
-
}
|
|
4982
5022
|
return { headTags, bodyTags };
|
|
4983
5023
|
}
|
|
4984
5024
|
});
|
|
@@ -5188,7 +5228,7 @@ import {
|
|
|
5188
5228
|
getBrowserslistWithDefault as getBrowserslistWithDefault3,
|
|
5189
5229
|
getCoreJsVersion,
|
|
5190
5230
|
isWebTarget,
|
|
5191
|
-
|
|
5231
|
+
reduceConfigs as reduceConfigs2
|
|
5192
5232
|
} from "@rsbuild/shared";
|
|
5193
5233
|
async function getDefaultSwcConfig(config, rootPath, target) {
|
|
5194
5234
|
return {
|
|
@@ -5294,9 +5334,9 @@ var init_swc = __esm({
|
|
|
5294
5334
|
await applyCoreJs(swcConfig, chain, polyfillMode);
|
|
5295
5335
|
}
|
|
5296
5336
|
}
|
|
5297
|
-
const mergedSwcConfig =
|
|
5298
|
-
|
|
5299
|
-
|
|
5337
|
+
const mergedSwcConfig = reduceConfigs2({
|
|
5338
|
+
initial: swcConfig,
|
|
5339
|
+
config: config.tools.swc,
|
|
5300
5340
|
mergeFn: deepmerge5
|
|
5301
5341
|
});
|
|
5302
5342
|
rule.use(CHAIN_ID3.USE.SWC).loader(builtinSwcLoaderName).options(mergedSwcConfig);
|
|
@@ -5545,10 +5585,7 @@ var init_splitChunks = __esm({
|
|
|
5545
5585
|
rootPath: api.context.rootPath,
|
|
5546
5586
|
polyfill: config.output.polyfill
|
|
5547
5587
|
});
|
|
5548
|
-
chain.optimization.splitChunks(
|
|
5549
|
-
// @ts-expect-error splitChunks type mismatch
|
|
5550
|
-
splitChunksOptions
|
|
5551
|
-
);
|
|
5588
|
+
chain.optimization.splitChunks(splitChunksOptions);
|
|
5552
5589
|
}
|
|
5553
5590
|
);
|
|
5554
5591
|
}
|
|
@@ -5556,16 +5593,22 @@ var init_splitChunks = __esm({
|
|
|
5556
5593
|
}
|
|
5557
5594
|
});
|
|
5558
5595
|
|
|
5559
|
-
// src/plugins/
|
|
5560
|
-
var
|
|
5561
|
-
__export(
|
|
5596
|
+
// src/plugins/open.ts
|
|
5597
|
+
var open_exports = {};
|
|
5598
|
+
__export(open_exports, {
|
|
5562
5599
|
openBrowser: () => openBrowser,
|
|
5563
|
-
|
|
5564
|
-
replacePlaceholder: () => replacePlaceholder
|
|
5600
|
+
pluginOpen: () => pluginOpen,
|
|
5601
|
+
replacePlaceholder: () => replacePlaceholder,
|
|
5602
|
+
resolveUrl: () => resolveUrl
|
|
5565
5603
|
});
|
|
5566
5604
|
import { exec } from "child_process";
|
|
5567
5605
|
import { promisify } from "util";
|
|
5568
|
-
import {
|
|
5606
|
+
import {
|
|
5607
|
+
canParse,
|
|
5608
|
+
castArray as castArray6,
|
|
5609
|
+
debug as debug7,
|
|
5610
|
+
logger as logger13
|
|
5611
|
+
} from "@rsbuild/shared";
|
|
5569
5612
|
async function openBrowser(url2) {
|
|
5570
5613
|
const shouldTryOpenChromeWithAppleScript = process.platform === "darwin";
|
|
5571
5614
|
if (shouldTryOpenChromeWithAppleScript) {
|
|
@@ -5598,30 +5641,45 @@ async function openBrowser(url2) {
|
|
|
5598
5641
|
return false;
|
|
5599
5642
|
}
|
|
5600
5643
|
}
|
|
5601
|
-
function
|
|
5644
|
+
function resolveUrl(str, base) {
|
|
5645
|
+
if (canParse(str)) {
|
|
5646
|
+
return str;
|
|
5647
|
+
}
|
|
5648
|
+
try {
|
|
5649
|
+
const url2 = new URL(str, base);
|
|
5650
|
+
return url2.href;
|
|
5651
|
+
} catch (e) {
|
|
5652
|
+
throw new Error(
|
|
5653
|
+
"[rsbuild:open]: Invalid input: not a valid URL or pathname"
|
|
5654
|
+
);
|
|
5655
|
+
}
|
|
5656
|
+
}
|
|
5657
|
+
function pluginOpen() {
|
|
5602
5658
|
return {
|
|
5603
|
-
name: "rsbuild:
|
|
5659
|
+
name: "rsbuild:open",
|
|
5604
5660
|
setup(api) {
|
|
5605
5661
|
const onStartServer = async (params) => {
|
|
5606
5662
|
const { port, routes } = params;
|
|
5607
5663
|
const config = api.getNormalizedConfig();
|
|
5608
|
-
const {
|
|
5664
|
+
const { beforeStartUrl } = config.dev;
|
|
5665
|
+
const open = config.server.open || config.dev.startUrl;
|
|
5609
5666
|
const { https } = api.context.devServer || {};
|
|
5610
5667
|
const isCodesandbox = process.env.CSB === "true";
|
|
5611
|
-
const shouldOpen = Boolean(
|
|
5668
|
+
const shouldOpen = Boolean(open) && !isCodesandbox;
|
|
5612
5669
|
if (!shouldOpen) {
|
|
5613
5670
|
return;
|
|
5614
5671
|
}
|
|
5615
5672
|
const urls = [];
|
|
5616
|
-
|
|
5617
|
-
|
|
5673
|
+
const protocol = https ? "https" : "http";
|
|
5674
|
+
const baseUrl = `${protocol}://localhost:${port}`;
|
|
5675
|
+
if (open === true || !open) {
|
|
5618
5676
|
if (routes.length) {
|
|
5619
|
-
urls.push(`${
|
|
5677
|
+
urls.push(`${baseUrl}${routes[0].pathname}`);
|
|
5620
5678
|
}
|
|
5621
5679
|
} else {
|
|
5622
5680
|
urls.push(
|
|
5623
|
-
...castArray6(
|
|
5624
|
-
(item) => replacePlaceholder(item, port)
|
|
5681
|
+
...castArray6(open).map(
|
|
5682
|
+
(item) => resolveUrl(replacePlaceholder(item, port), baseUrl)
|
|
5625
5683
|
)
|
|
5626
5684
|
);
|
|
5627
5685
|
}
|
|
@@ -5647,8 +5705,8 @@ function pluginStartUrl() {
|
|
|
5647
5705
|
};
|
|
5648
5706
|
}
|
|
5649
5707
|
var execAsync, supportedChromiumBrowsers, getTargetBrowser, replacePlaceholder, openedURLs;
|
|
5650
|
-
var
|
|
5651
|
-
"src/plugins/
|
|
5708
|
+
var init_open = __esm({
|
|
5709
|
+
"src/plugins/open.ts"() {
|
|
5652
5710
|
"use strict";
|
|
5653
5711
|
init_esm();
|
|
5654
5712
|
init_constants();
|
|
@@ -6060,12 +6118,6 @@ var init_extractChunks = __esm({
|
|
|
6060
6118
|
// src/rspack/preload/helpers/determineAsValue.ts
|
|
6061
6119
|
import path12 from "path";
|
|
6062
6120
|
import { URL as URL2 } from "url";
|
|
6063
|
-
import {
|
|
6064
|
-
AUDIO_EXTENSIONS as AUDIO_EXTENSIONS2,
|
|
6065
|
-
FONT_EXTENSIONS as FONT_EXTENSIONS2,
|
|
6066
|
-
IMAGE_EXTENSIONS as IMAGE_EXTENSIONS2,
|
|
6067
|
-
VIDEO_EXTENSIONS as VIDEO_EXTENSIONS2
|
|
6068
|
-
} from "@rsbuild/shared";
|
|
6069
6121
|
function determineAsValue({
|
|
6070
6122
|
href,
|
|
6071
6123
|
file
|
|
@@ -6075,16 +6127,16 @@ function determineAsValue({
|
|
|
6075
6127
|
if (["css"].includes(extension)) {
|
|
6076
6128
|
return "style";
|
|
6077
6129
|
}
|
|
6078
|
-
if (
|
|
6130
|
+
if (IMAGE_EXTENSIONS.includes(extension)) {
|
|
6079
6131
|
return "image";
|
|
6080
6132
|
}
|
|
6081
|
-
if (
|
|
6133
|
+
if (VIDEO_EXTENSIONS.includes(extension)) {
|
|
6082
6134
|
return "video";
|
|
6083
6135
|
}
|
|
6084
|
-
if (
|
|
6136
|
+
if (AUDIO_EXTENSIONS.includes(extension)) {
|
|
6085
6137
|
return "audio";
|
|
6086
6138
|
}
|
|
6087
|
-
if (
|
|
6139
|
+
if (FONT_EXTENSIONS.includes(extension)) {
|
|
6088
6140
|
return "font";
|
|
6089
6141
|
}
|
|
6090
6142
|
if (["vtt"].includes(extension)) {
|
|
@@ -6096,6 +6148,7 @@ var init_determineAsValue = __esm({
|
|
|
6096
6148
|
"src/rspack/preload/helpers/determineAsValue.ts"() {
|
|
6097
6149
|
"use strict";
|
|
6098
6150
|
init_esm();
|
|
6151
|
+
init_constants();
|
|
6099
6152
|
}
|
|
6100
6153
|
});
|
|
6101
6154
|
|
|
@@ -6166,7 +6219,7 @@ __export(HtmlPreloadOrPrefetchPlugin_exports, {
|
|
|
6166
6219
|
});
|
|
6167
6220
|
import {
|
|
6168
6221
|
getPublicPathFromCompiler as getPublicPathFromCompiler4,
|
|
6169
|
-
upperFirst,
|
|
6222
|
+
upperFirst as upperFirst2,
|
|
6170
6223
|
withPublicPath as withPublicPath3
|
|
6171
6224
|
} from "@rsbuild/shared";
|
|
6172
6225
|
function filterResourceHints(resourceHints, scripts) {
|
|
@@ -6268,7 +6321,7 @@ var init_HtmlPreloadOrPrefetchPlugin = __esm({
|
|
|
6268
6321
|
apply(compiler) {
|
|
6269
6322
|
compiler.hooks.compilation.tap(this.constructor.name, (compilation) => {
|
|
6270
6323
|
getHTMLPlugin().getHooks(compilation).beforeAssetTagGeneration.tap(
|
|
6271
|
-
`HTML${
|
|
6324
|
+
`HTML${upperFirst2(this.type)}Plugin`,
|
|
6272
6325
|
(htmlPluginData) => {
|
|
6273
6326
|
this.resourceHints = generateLinks(
|
|
6274
6327
|
this.options,
|
|
@@ -6281,7 +6334,7 @@ var init_HtmlPreloadOrPrefetchPlugin = __esm({
|
|
|
6281
6334
|
}
|
|
6282
6335
|
);
|
|
6283
6336
|
getHTMLPlugin().getHooks(compilation).alterAssetTags.tap(
|
|
6284
|
-
`HTML${
|
|
6337
|
+
`HTML${upperFirst2(this.type)}Plugin`,
|
|
6285
6338
|
(htmlPluginData) => {
|
|
6286
6339
|
if (this.resourceHints) {
|
|
6287
6340
|
htmlPluginData.assetTags.styles = [
|
|
@@ -6413,7 +6466,7 @@ __export(server_exports, {
|
|
|
6413
6466
|
pluginServer: () => pluginServer
|
|
6414
6467
|
});
|
|
6415
6468
|
import { isAbsolute as isAbsolute7, join as join11 } from "path";
|
|
6416
|
-
import { fse as
|
|
6469
|
+
import { fse as fse7 } from "@rsbuild/shared";
|
|
6417
6470
|
var pluginServer;
|
|
6418
6471
|
var init_server = __esm({
|
|
6419
6472
|
"src/plugins/server.ts"() {
|
|
@@ -6430,11 +6483,11 @@ var init_server = __esm({
|
|
|
6430
6483
|
return;
|
|
6431
6484
|
}
|
|
6432
6485
|
const publicDir = isAbsolute7(name) ? name : join11(api.context.rootPath, name);
|
|
6433
|
-
if (!
|
|
6486
|
+
if (!fse7.existsSync(publicDir)) {
|
|
6434
6487
|
return;
|
|
6435
6488
|
}
|
|
6436
6489
|
try {
|
|
6437
|
-
await
|
|
6490
|
+
await fse7.copy(publicDir, api.context.distPath, {
|
|
6438
6491
|
// dereference symlinks
|
|
6439
6492
|
dereference: true
|
|
6440
6493
|
});
|
|
@@ -6549,7 +6602,6 @@ var init_manifest = __esm({
|
|
|
6549
6602
|
name: "rsbuild:manifest",
|
|
6550
6603
|
setup(api) {
|
|
6551
6604
|
api.modifyBundlerChain(async (chain, { CHAIN_ID: CHAIN_ID3 }) => {
|
|
6552
|
-
const htmlPaths = api.getHTMLPaths();
|
|
6553
6605
|
const {
|
|
6554
6606
|
output: { manifest }
|
|
6555
6607
|
} = api.getNormalizedConfig();
|
|
@@ -6558,6 +6610,7 @@ var init_manifest = __esm({
|
|
|
6558
6610
|
}
|
|
6559
6611
|
const fileName = typeof manifest === "string" ? manifest : "manifest.json";
|
|
6560
6612
|
const { RspackManifestPlugin } = await import("../compiled/rspack-manifest-plugin/index.js");
|
|
6613
|
+
const htmlPaths = api.getHTMLPaths();
|
|
6561
6614
|
chain.plugin(CHAIN_ID3.PLUGIN.MANIFEST).use(RspackManifestPlugin, [
|
|
6562
6615
|
{
|
|
6563
6616
|
fileName,
|
|
@@ -6686,7 +6739,7 @@ __export(rspackProfile_exports, {
|
|
|
6686
6739
|
});
|
|
6687
6740
|
import inspector from "inspector";
|
|
6688
6741
|
import path13 from "path";
|
|
6689
|
-
import { fse as
|
|
6742
|
+
import { fse as fse8 } from "@rsbuild/shared";
|
|
6690
6743
|
import { logger as logger15 } from "@rsbuild/shared";
|
|
6691
6744
|
import { rspack as rspack9 } from "@rspack/core";
|
|
6692
6745
|
var stopProfiler, pluginRspackProfile;
|
|
@@ -6703,7 +6756,7 @@ var init_rspackProfile = __esm({
|
|
|
6703
6756
|
logger15.error("Failed to generate JS CPU profile:", error);
|
|
6704
6757
|
return;
|
|
6705
6758
|
}
|
|
6706
|
-
|
|
6759
|
+
fse8.writeFileSync(output, JSON.stringify(param.profile));
|
|
6707
6760
|
});
|
|
6708
6761
|
};
|
|
6709
6762
|
pluginRspackProfile = () => ({
|
|
@@ -6729,7 +6782,7 @@ var init_rspackProfile = __esm({
|
|
|
6729
6782
|
const cpuProfilePath = path13.join(profileDir, "jscpuprofile.json");
|
|
6730
6783
|
const loggingFilePath = path13.join(profileDir, "logging.json");
|
|
6731
6784
|
const onStart = () => {
|
|
6732
|
-
|
|
6785
|
+
fse8.ensureDirSync(profileDir);
|
|
6733
6786
|
if (enableProfileTrace) {
|
|
6734
6787
|
rspack9.experimental_registerGlobalTrace(
|
|
6735
6788
|
"trace",
|
|
@@ -6753,7 +6806,7 @@ var init_rspackProfile = __esm({
|
|
|
6753
6806
|
logging: "verbose",
|
|
6754
6807
|
loggingTrace: true
|
|
6755
6808
|
});
|
|
6756
|
-
|
|
6809
|
+
fse8.writeFileSync(loggingFilePath, JSON.stringify(logging));
|
|
6757
6810
|
}
|
|
6758
6811
|
});
|
|
6759
6812
|
api.onExit(() => {
|
|
@@ -6782,8 +6835,8 @@ var init_lazyCompilation = __esm({
|
|
|
6782
6835
|
pluginLazyCompilation = () => ({
|
|
6783
6836
|
name: "rsbuild:lazy-compilation",
|
|
6784
6837
|
setup(api) {
|
|
6785
|
-
api.modifyBundlerChain((chain, { isProd:
|
|
6786
|
-
if (
|
|
6838
|
+
api.modifyBundlerChain((chain, { isProd: isProd5, target }) => {
|
|
6839
|
+
if (isProd5 || target !== "web") {
|
|
6787
6840
|
return;
|
|
6788
6841
|
}
|
|
6789
6842
|
const config = api.getNormalizedConfig();
|
|
@@ -6791,12 +6844,10 @@ var init_lazyCompilation = __esm({
|
|
|
6791
6844
|
if (!options) {
|
|
6792
6845
|
return;
|
|
6793
6846
|
}
|
|
6794
|
-
const clientRegExp = /[\\/]core[\\/]dist[\\/]client[\\/]/;
|
|
6795
6847
|
const cssRegExp = /\.(?:css|less|sass|scss|styl|stylus)$/;
|
|
6796
6848
|
const isExcludedModule = (name) => {
|
|
6797
6849
|
return (
|
|
6798
|
-
//
|
|
6799
|
-
clientRegExp.test(name) || // exclude CSS files because Rspack does not support it yet
|
|
6850
|
+
// exclude CSS files because Rspack does not support it yet
|
|
6800
6851
|
// TODO: remove this after Rspack supporting it
|
|
6801
6852
|
cssRegExp.test(name)
|
|
6802
6853
|
);
|
|
@@ -6843,6 +6894,229 @@ var init_lazyCompilation = __esm({
|
|
|
6843
6894
|
}
|
|
6844
6895
|
});
|
|
6845
6896
|
|
|
6897
|
+
// src/plugins/sri.ts
|
|
6898
|
+
var sri_exports = {};
|
|
6899
|
+
__export(sri_exports, {
|
|
6900
|
+
pluginSri: () => pluginSri
|
|
6901
|
+
});
|
|
6902
|
+
import crypto2 from "crypto";
|
|
6903
|
+
import {
|
|
6904
|
+
isHtmlDisabled as isHtmlDisabled4,
|
|
6905
|
+
isProd as isProd4,
|
|
6906
|
+
logger as logger16,
|
|
6907
|
+
removeLeadingSlash as removeLeadingSlash2
|
|
6908
|
+
} from "@rsbuild/shared";
|
|
6909
|
+
var getAssetName, pluginSri;
|
|
6910
|
+
var init_sri = __esm({
|
|
6911
|
+
"src/plugins/sri.ts"() {
|
|
6912
|
+
"use strict";
|
|
6913
|
+
init_esm();
|
|
6914
|
+
init_constants();
|
|
6915
|
+
getAssetName = (url2, assetPrefix) => {
|
|
6916
|
+
if (url2.startsWith(assetPrefix)) {
|
|
6917
|
+
return removeLeadingSlash2(url2.replace(assetPrefix, ""));
|
|
6918
|
+
}
|
|
6919
|
+
return removeLeadingSlash2(url2);
|
|
6920
|
+
};
|
|
6921
|
+
pluginSri = () => ({
|
|
6922
|
+
name: "rsbuild:sri",
|
|
6923
|
+
setup(api) {
|
|
6924
|
+
const placeholder = "RSBUILD_INTEGRITY_PLACEHOLDER:";
|
|
6925
|
+
const getAlgorithm = () => {
|
|
6926
|
+
const config = api.getNormalizedConfig();
|
|
6927
|
+
const { sri } = config.security;
|
|
6928
|
+
const enable = sri.enable === "auto" ? isProd4() : sri.enable;
|
|
6929
|
+
if (!enable) {
|
|
6930
|
+
return null;
|
|
6931
|
+
}
|
|
6932
|
+
const { algorithm = "sha384" } = sri;
|
|
6933
|
+
return algorithm;
|
|
6934
|
+
};
|
|
6935
|
+
api.modifyHTMLTags({
|
|
6936
|
+
// ensure `sri` can be applied to all tags
|
|
6937
|
+
order: "post",
|
|
6938
|
+
handler(tags, { assetPrefix }) {
|
|
6939
|
+
const algorithm = getAlgorithm();
|
|
6940
|
+
if (!algorithm) {
|
|
6941
|
+
return tags;
|
|
6942
|
+
}
|
|
6943
|
+
const allTags = [...tags.headTags, ...tags.bodyTags];
|
|
6944
|
+
for (const tag of allTags) {
|
|
6945
|
+
let url2 = "";
|
|
6946
|
+
if (!tag.attrs) {
|
|
6947
|
+
continue;
|
|
6948
|
+
}
|
|
6949
|
+
if (tag.tag === "script" && typeof tag.attrs.src === "string") {
|
|
6950
|
+
url2 = tag.attrs.src;
|
|
6951
|
+
} else if (tag.tag === "link" && tag.attrs.rel === "stylesheet" && typeof tag.attrs.href === "string") {
|
|
6952
|
+
url2 = tag.attrs.href;
|
|
6953
|
+
}
|
|
6954
|
+
if (!url2) {
|
|
6955
|
+
continue;
|
|
6956
|
+
}
|
|
6957
|
+
const assetName = getAssetName(url2, assetPrefix);
|
|
6958
|
+
if (!assetName) {
|
|
6959
|
+
continue;
|
|
6960
|
+
}
|
|
6961
|
+
tag.attrs.integrity ??= `${placeholder}${assetName}`;
|
|
6962
|
+
}
|
|
6963
|
+
return tags;
|
|
6964
|
+
}
|
|
6965
|
+
});
|
|
6966
|
+
const replaceIntegrity = (htmlContent, assets, algorithm, integrityCache) => {
|
|
6967
|
+
const regex = /integrity="RSBUILD_INTEGRITY_PLACEHOLDER:([^"]+)"/g;
|
|
6968
|
+
const matches = htmlContent.matchAll(regex);
|
|
6969
|
+
let replacedHtml = htmlContent;
|
|
6970
|
+
const calcIntegrity = (algorithm2, assetName, data) => {
|
|
6971
|
+
if (integrityCache.has(assetName)) {
|
|
6972
|
+
return integrityCache.get(assetName);
|
|
6973
|
+
}
|
|
6974
|
+
const hash = crypto2.createHash(algorithm2).update(data).digest().toString("base64");
|
|
6975
|
+
const integrity = `${algorithm2}-${hash}`;
|
|
6976
|
+
integrityCache.set(assetName, integrity);
|
|
6977
|
+
return integrity;
|
|
6978
|
+
};
|
|
6979
|
+
for (const match of matches) {
|
|
6980
|
+
const assetName = match[1];
|
|
6981
|
+
if (!assetName) {
|
|
6982
|
+
continue;
|
|
6983
|
+
}
|
|
6984
|
+
if (assets[assetName]) {
|
|
6985
|
+
const integrity = calcIntegrity(
|
|
6986
|
+
algorithm,
|
|
6987
|
+
assetName,
|
|
6988
|
+
assets[assetName].buffer()
|
|
6989
|
+
);
|
|
6990
|
+
replacedHtml = replacedHtml.replaceAll(
|
|
6991
|
+
`integrity="${placeholder}${assetName}"`,
|
|
6992
|
+
`integrity="${integrity}"`
|
|
6993
|
+
);
|
|
6994
|
+
} else {
|
|
6995
|
+
logger16.debug(
|
|
6996
|
+
`[rsbuild:sri] failed to generate integrity for ${assetName}.`
|
|
6997
|
+
);
|
|
6998
|
+
replacedHtml = replacedHtml.replace(
|
|
6999
|
+
`integrity="${placeholder}${assetName}"`,
|
|
7000
|
+
""
|
|
7001
|
+
);
|
|
7002
|
+
}
|
|
7003
|
+
}
|
|
7004
|
+
return replacedHtml;
|
|
7005
|
+
};
|
|
7006
|
+
class SriReplaceIntegrityPlugin {
|
|
7007
|
+
constructor(algorithm) {
|
|
7008
|
+
__publicField(this, "algorithm");
|
|
7009
|
+
this.algorithm = algorithm;
|
|
7010
|
+
}
|
|
7011
|
+
apply(compiler) {
|
|
7012
|
+
compiler.hooks.compilation.tap(
|
|
7013
|
+
"SriReplaceIntegrityPlugin",
|
|
7014
|
+
(compilation) => {
|
|
7015
|
+
compilation.hooks.processAssets.tapPromise(
|
|
7016
|
+
{
|
|
7017
|
+
name: "SriReplaceIntegrityPlugin",
|
|
7018
|
+
// use to final stage to get the final asset content
|
|
7019
|
+
stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_REPORT
|
|
7020
|
+
},
|
|
7021
|
+
async (assets) => {
|
|
7022
|
+
const integrityCache = /* @__PURE__ */ new Map();
|
|
7023
|
+
for (const asset of Object.keys(assets)) {
|
|
7024
|
+
if (!HTML_REGEX.test(asset)) {
|
|
7025
|
+
continue;
|
|
7026
|
+
}
|
|
7027
|
+
const htmlContent = assets[asset].source();
|
|
7028
|
+
if (!htmlContent.includes(placeholder)) {
|
|
7029
|
+
continue;
|
|
7030
|
+
}
|
|
7031
|
+
assets[asset] = new compiler.webpack.sources.RawSource(
|
|
7032
|
+
replaceIntegrity(
|
|
7033
|
+
htmlContent,
|
|
7034
|
+
assets,
|
|
7035
|
+
this.algorithm,
|
|
7036
|
+
integrityCache
|
|
7037
|
+
)
|
|
7038
|
+
);
|
|
7039
|
+
}
|
|
7040
|
+
}
|
|
7041
|
+
);
|
|
7042
|
+
}
|
|
7043
|
+
);
|
|
7044
|
+
}
|
|
7045
|
+
}
|
|
7046
|
+
api.modifyBundlerChain((chain, { target }) => {
|
|
7047
|
+
const config = api.getNormalizedConfig();
|
|
7048
|
+
if (isHtmlDisabled4(config, target)) {
|
|
7049
|
+
return;
|
|
7050
|
+
}
|
|
7051
|
+
const algorithm = getAlgorithm();
|
|
7052
|
+
if (!algorithm) {
|
|
7053
|
+
return;
|
|
7054
|
+
}
|
|
7055
|
+
chain.plugin("rsbuild-sri-replace").use(SriReplaceIntegrityPlugin, [algorithm]);
|
|
7056
|
+
});
|
|
7057
|
+
}
|
|
7058
|
+
});
|
|
7059
|
+
}
|
|
7060
|
+
});
|
|
7061
|
+
|
|
7062
|
+
// src/plugins/nonce.ts
|
|
7063
|
+
var nonce_exports = {};
|
|
7064
|
+
__export(nonce_exports, {
|
|
7065
|
+
pluginNonce: () => pluginNonce
|
|
7066
|
+
});
|
|
7067
|
+
import { applyToCompiler as applyToCompiler2, createVirtualModule as createVirtualModule2 } from "@rsbuild/shared";
|
|
7068
|
+
var pluginNonce;
|
|
7069
|
+
var init_nonce = __esm({
|
|
7070
|
+
"src/plugins/nonce.ts"() {
|
|
7071
|
+
"use strict";
|
|
7072
|
+
init_esm();
|
|
7073
|
+
pluginNonce = () => ({
|
|
7074
|
+
name: "rsbuild:nonce",
|
|
7075
|
+
setup(api) {
|
|
7076
|
+
api.onAfterCreateCompiler(({ compiler }) => {
|
|
7077
|
+
const { nonce } = api.getNormalizedConfig().security;
|
|
7078
|
+
if (!nonce) {
|
|
7079
|
+
return;
|
|
7080
|
+
}
|
|
7081
|
+
applyToCompiler2(compiler, (compiler2) => {
|
|
7082
|
+
const { plugins } = compiler2.options;
|
|
7083
|
+
const hasHTML = plugins.some(
|
|
7084
|
+
(plugin) => plugin && plugin.constructor.name === "HtmlBasicPlugin"
|
|
7085
|
+
);
|
|
7086
|
+
if (!hasHTML) {
|
|
7087
|
+
return;
|
|
7088
|
+
}
|
|
7089
|
+
const injectCode = createVirtualModule2(
|
|
7090
|
+
`__webpack_nonce__ = "${nonce}";`
|
|
7091
|
+
);
|
|
7092
|
+
new compiler2.webpack.EntryPlugin(compiler2.context, injectCode, {
|
|
7093
|
+
name: void 0
|
|
7094
|
+
}).apply(compiler2);
|
|
7095
|
+
});
|
|
7096
|
+
});
|
|
7097
|
+
api.modifyHTMLTags({
|
|
7098
|
+
// ensure `nonce` can be applied to all tags
|
|
7099
|
+
order: "post",
|
|
7100
|
+
handler: ({ headTags, bodyTags }) => {
|
|
7101
|
+
const config = api.getNormalizedConfig();
|
|
7102
|
+
const { nonce } = config.security;
|
|
7103
|
+
const allTags = [...headTags, ...bodyTags];
|
|
7104
|
+
if (nonce) {
|
|
7105
|
+
for (const tag of allTags) {
|
|
7106
|
+
if (tag.tag === "script" || tag.tag === "style") {
|
|
7107
|
+
tag.attrs ??= {};
|
|
7108
|
+
tag.attrs.nonce = nonce;
|
|
7109
|
+
}
|
|
7110
|
+
}
|
|
7111
|
+
}
|
|
7112
|
+
return { headTags, bodyTags };
|
|
7113
|
+
}
|
|
7114
|
+
});
|
|
7115
|
+
}
|
|
7116
|
+
});
|
|
7117
|
+
}
|
|
7118
|
+
});
|
|
7119
|
+
|
|
6846
7120
|
// src/createRsbuild.ts
|
|
6847
7121
|
var createRsbuild_exports = {};
|
|
6848
7122
|
__export(createRsbuild_exports, {
|
|
@@ -6871,7 +7145,7 @@ async function applyDefaultPlugins(pluginManager, context) {
|
|
|
6871
7145
|
const { pluginSwc: pluginSwc2 } = await Promise.resolve().then(() => (init_swc(), swc_exports));
|
|
6872
7146
|
const { pluginExternals: pluginExternals2 } = await Promise.resolve().then(() => (init_externals(), externals_exports));
|
|
6873
7147
|
const { pluginSplitChunks: pluginSplitChunks2 } = await Promise.resolve().then(() => (init_splitChunks(), splitChunks_exports));
|
|
6874
|
-
const {
|
|
7148
|
+
const { pluginOpen: pluginOpen2 } = await Promise.resolve().then(() => (init_open(), open_exports));
|
|
6875
7149
|
const { pluginInlineChunk: pluginInlineChunk2 } = await Promise.resolve().then(() => (init_inlineChunk(), inlineChunk_exports));
|
|
6876
7150
|
const { pluginBundleAnalyzer: pluginBundleAnalyzer2 } = await Promise.resolve().then(() => (init_bundleAnalyzer(), bundleAnalyzer_exports));
|
|
6877
7151
|
const { pluginRsdoctor: pluginRsdoctor2 } = await Promise.resolve().then(() => (init_rsdoctor(), rsdoctor_exports));
|
|
@@ -6882,6 +7156,8 @@ async function applyDefaultPlugins(pluginManager, context) {
|
|
|
6882
7156
|
const { pluginModuleFederation: pluginModuleFederation2 } = await Promise.resolve().then(() => (init_moduleFederation(), moduleFederation_exports));
|
|
6883
7157
|
const { pluginRspackProfile: pluginRspackProfile2 } = await Promise.resolve().then(() => (init_rspackProfile(), rspackProfile_exports));
|
|
6884
7158
|
const { pluginLazyCompilation: pluginLazyCompilation2 } = await Promise.resolve().then(() => (init_lazyCompilation(), lazyCompilation_exports));
|
|
7159
|
+
const { pluginSri: pluginSri2 } = await Promise.resolve().then(() => (init_sri(), sri_exports));
|
|
7160
|
+
const { pluginNonce: pluginNonce2 } = await Promise.resolve().then(() => (init_nonce(), nonce_exports));
|
|
6885
7161
|
pluginManager.addPlugins([
|
|
6886
7162
|
pluginBasic2(),
|
|
6887
7163
|
pluginEntry2(),
|
|
@@ -6893,8 +7169,8 @@ async function applyDefaultPlugins(pluginManager, context) {
|
|
|
6893
7169
|
// cleanOutput plugin should before the html plugin
|
|
6894
7170
|
pluginCleanOutput2(),
|
|
6895
7171
|
pluginAsset2(),
|
|
6896
|
-
pluginHtml2(async (
|
|
6897
|
-
const result = await context.hooks.modifyHTMLTags.call(
|
|
7172
|
+
pluginHtml2(async (...args) => {
|
|
7173
|
+
const result = await context.hooks.modifyHTMLTags.call(...args);
|
|
6898
7174
|
return result[0];
|
|
6899
7175
|
}),
|
|
6900
7176
|
pluginWasm2(),
|
|
@@ -6907,7 +7183,7 @@ async function applyDefaultPlugins(pluginManager, context) {
|
|
|
6907
7183
|
pluginSwc2(),
|
|
6908
7184
|
pluginExternals2(),
|
|
6909
7185
|
pluginSplitChunks2(),
|
|
6910
|
-
|
|
7186
|
+
pluginOpen2(),
|
|
6911
7187
|
pluginInlineChunk2(),
|
|
6912
7188
|
pluginBundleAnalyzer2(),
|
|
6913
7189
|
pluginRsdoctor2(),
|
|
@@ -6917,7 +7193,9 @@ async function applyDefaultPlugins(pluginManager, context) {
|
|
|
6917
7193
|
pluginManifest2(),
|
|
6918
7194
|
pluginModuleFederation2(),
|
|
6919
7195
|
pluginRspackProfile2(),
|
|
6920
|
-
pluginLazyCompilation2()
|
|
7196
|
+
pluginLazyCompilation2(),
|
|
7197
|
+
pluginSri2(),
|
|
7198
|
+
pluginNonce2()
|
|
6921
7199
|
]);
|
|
6922
7200
|
}
|
|
6923
7201
|
async function createRsbuild(options = {}) {
|
|
@@ -7017,7 +7295,7 @@ var init_createRsbuild = __esm({
|
|
|
7017
7295
|
});
|
|
7018
7296
|
|
|
7019
7297
|
// src/cli/init.ts
|
|
7020
|
-
import { isDev as isDev2, logger as
|
|
7298
|
+
import { isDev as isDev2, logger as logger17 } from "@rsbuild/shared";
|
|
7021
7299
|
async function init({
|
|
7022
7300
|
cliOptions,
|
|
7023
7301
|
isRestart
|
|
@@ -7053,9 +7331,9 @@ async function init({
|
|
|
7053
7331
|
...envs.publicVars,
|
|
7054
7332
|
...config.source.define
|
|
7055
7333
|
};
|
|
7056
|
-
if (commonOpts.open && !config.
|
|
7057
|
-
config.
|
|
7058
|
-
config.
|
|
7334
|
+
if (commonOpts.open && !config.server?.open) {
|
|
7335
|
+
config.server ||= {};
|
|
7336
|
+
config.server.open = commonOpts.open;
|
|
7059
7337
|
}
|
|
7060
7338
|
if (commonOpts.host) {
|
|
7061
7339
|
config.server ||= {};
|
|
@@ -7071,7 +7349,7 @@ async function init({
|
|
|
7071
7349
|
});
|
|
7072
7350
|
} catch (err) {
|
|
7073
7351
|
if (isRestart) {
|
|
7074
|
-
|
|
7352
|
+
logger17.error(err);
|
|
7075
7353
|
} else {
|
|
7076
7354
|
throw err;
|
|
7077
7355
|
}
|
|
@@ -7108,10 +7386,12 @@ __export(internal_exports, {
|
|
|
7108
7386
|
initHooks: () => initHooks,
|
|
7109
7387
|
initPlugins: () => initPlugins,
|
|
7110
7388
|
initRsbuildConfig: () => initRsbuildConfig,
|
|
7389
|
+
outputInspectConfigFiles: () => outputInspectConfigFiles,
|
|
7111
7390
|
prepareCli: () => prepareCli,
|
|
7112
7391
|
runCli: () => runCli,
|
|
7113
7392
|
setHTMLPlugin: () => setHTMLPlugin,
|
|
7114
|
-
startProdServer: () => startProdServer
|
|
7393
|
+
startProdServer: () => startProdServer,
|
|
7394
|
+
stringifyConfig: () => stringifyConfig
|
|
7115
7395
|
});
|
|
7116
7396
|
init_esm();
|
|
7117
7397
|
|
|
@@ -7121,7 +7401,7 @@ init_helpers();
|
|
|
7121
7401
|
init_init();
|
|
7122
7402
|
import { existsSync } from "fs";
|
|
7123
7403
|
import { join as join12 } from "path";
|
|
7124
|
-
import { color as color13, logger as
|
|
7404
|
+
import { color as color13, logger as logger18 } from "@rsbuild/shared";
|
|
7125
7405
|
import { program } from "../compiled/commander/index.js";
|
|
7126
7406
|
var applyCommonOptions = (command) => {
|
|
7127
7407
|
command.option(
|
|
@@ -7136,7 +7416,7 @@ var applyServerOptions = (command) => {
|
|
|
7136
7416
|
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");
|
|
7137
7417
|
};
|
|
7138
7418
|
function runCli() {
|
|
7139
|
-
program.name("rsbuild").usage("<command> [options]").version("0.7.
|
|
7419
|
+
program.name("rsbuild").usage("<command> [options]").version("0.7.4");
|
|
7140
7420
|
const devCommand = program.command("dev");
|
|
7141
7421
|
const buildCommand = program.command("build");
|
|
7142
7422
|
const previewCommand = program.command("preview");
|
|
@@ -7150,8 +7430,8 @@ function runCli() {
|
|
|
7150
7430
|
const rsbuild = await init({ cliOptions: options });
|
|
7151
7431
|
await rsbuild?.startDevServer();
|
|
7152
7432
|
} catch (err) {
|
|
7153
|
-
|
|
7154
|
-
|
|
7433
|
+
logger18.error("Failed to start dev server.");
|
|
7434
|
+
logger18.error(err);
|
|
7155
7435
|
process.exit(1);
|
|
7156
7436
|
}
|
|
7157
7437
|
});
|
|
@@ -7162,8 +7442,8 @@ function runCli() {
|
|
|
7162
7442
|
watch: options.watch
|
|
7163
7443
|
});
|
|
7164
7444
|
} catch (err) {
|
|
7165
|
-
|
|
7166
|
-
|
|
7445
|
+
logger18.error("Failed to build.");
|
|
7446
|
+
logger18.error(err);
|
|
7167
7447
|
process.exit(1);
|
|
7168
7448
|
}
|
|
7169
7449
|
});
|
|
@@ -7189,8 +7469,8 @@ function runCli() {
|
|
|
7189
7469
|
}
|
|
7190
7470
|
await rsbuild?.preview();
|
|
7191
7471
|
} catch (err) {
|
|
7192
|
-
|
|
7193
|
-
|
|
7472
|
+
logger18.error("Failed to start preview server.");
|
|
7473
|
+
logger18.error(err);
|
|
7194
7474
|
process.exit(1);
|
|
7195
7475
|
}
|
|
7196
7476
|
});
|
|
@@ -7204,8 +7484,8 @@ function runCli() {
|
|
|
7204
7484
|
writeToDisk: true
|
|
7205
7485
|
});
|
|
7206
7486
|
} catch (err) {
|
|
7207
|
-
|
|
7208
|
-
|
|
7487
|
+
logger18.error("Failed to inspect config.");
|
|
7488
|
+
logger18.error(err);
|
|
7209
7489
|
process.exit(1);
|
|
7210
7490
|
}
|
|
7211
7491
|
});
|
|
@@ -7214,7 +7494,7 @@ function runCli() {
|
|
|
7214
7494
|
|
|
7215
7495
|
// src/cli/prepare.ts
|
|
7216
7496
|
init_esm();
|
|
7217
|
-
import { logger as
|
|
7497
|
+
import { logger as logger19 } from "@rsbuild/shared";
|
|
7218
7498
|
function initNodeEnv() {
|
|
7219
7499
|
if (!process.env.NODE_ENV) {
|
|
7220
7500
|
const command = process.argv[2];
|
|
@@ -7227,7 +7507,7 @@ function prepareCli() {
|
|
|
7227
7507
|
if (!npm_execpath || npm_execpath.includes("npx-cli.js") || npm_execpath.includes(".bun")) {
|
|
7228
7508
|
console.log();
|
|
7229
7509
|
}
|
|
7230
|
-
|
|
7510
|
+
logger19.greet(` ${`Rsbuild v${"0.7.4"}`}
|
|
7231
7511
|
`);
|
|
7232
7512
|
}
|
|
7233
7513
|
|
|
@@ -7235,6 +7515,7 @@ function prepareCli() {
|
|
|
7235
7515
|
init_pluginManager();
|
|
7236
7516
|
init_initHooks();
|
|
7237
7517
|
init_initConfigs();
|
|
7518
|
+
init_config();
|
|
7238
7519
|
init_pluginHelper();
|
|
7239
7520
|
init_helpers();
|
|
7240
7521
|
init_rspackConfig();
|
|
@@ -7253,8 +7534,8 @@ init_createRsbuild();
|
|
|
7253
7534
|
init_config();
|
|
7254
7535
|
init_mergeConfig();
|
|
7255
7536
|
init_constants();
|
|
7256
|
-
import { logger as
|
|
7257
|
-
var version = "0.7.
|
|
7537
|
+
import { logger as logger20 } from "@rsbuild/shared";
|
|
7538
|
+
var version = "0.7.4";
|
|
7258
7539
|
export {
|
|
7259
7540
|
PLUGIN_CSS_NAME,
|
|
7260
7541
|
PLUGIN_SWC_NAME,
|
|
@@ -7263,7 +7544,7 @@ export {
|
|
|
7263
7544
|
defineConfig,
|
|
7264
7545
|
loadConfig,
|
|
7265
7546
|
loadEnv,
|
|
7266
|
-
|
|
7547
|
+
logger20 as logger,
|
|
7267
7548
|
mergeRsbuildConfig,
|
|
7268
7549
|
rspack10 as rspack,
|
|
7269
7550
|
version
|