@rsbuild/core 2.0.0-beta.1 → 2.0.0-beta.3
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 +2 -2
- package/compiled/html-rspack-plugin/index.js +15 -15
- package/compiled/html-rspack-plugin/package.json +1 -1
- package/compiled/postcss-loader/index.js +6 -6
- package/compiled/rslog/index.d.ts +1 -1
- package/compiled/rslog/package.json +1 -1
- package/compiled/style-loader/index.js +10 -10
- package/dist/131.js +206 -257
- package/dist/712.js +15 -0
- package/dist/chokidar.js +2 -2
- package/dist/connect.js +12 -23
- package/dist/http-proxy-middleware.js +3480 -0
- package/dist/http-proxy-middleware.js.LICENSE.txt +69 -0
- package/dist/launch-editor-middleware.js +58 -0
- package/dist/manifest-plugin.js +5 -5
- package/dist/open.js +17 -15
- package/dist/rslib-runtime.js +1 -1
- package/dist-types/helpers/color.d.ts +4 -0
- package/dist-types/helpers/index.d.ts +1 -1
- package/dist-types/helpers/vendors.d.ts +0 -1
- package/dist-types/restart.d.ts +1 -1
- package/dist-types/server/assets-middleware/index.d.ts +3 -2
- package/dist-types/server/proxy.d.ts +2 -2
- package/dist-types/server/watchFiles.d.ts +1 -1
- package/dist-types/types/config.d.ts +17 -10
- package/dist-types/types/hooks.d.ts +4 -12
- package/dist-types/types/thirdParty.d.ts +1 -1
- package/package.json +6 -7
- package/compiled/http-proxy-middleware/index.js +0 -6132
- /package/compiled/html-rspack-plugin/{loader.js → htmlLoader.js} +0 -0
package/dist/131.js
CHANGED
|
@@ -8,23 +8,19 @@ import * as __rspack_external_events from "events";
|
|
|
8
8
|
import * as __rspack_external_fs from "fs";
|
|
9
9
|
import * as __rspack_external_node_fs_5ea92f0c from "node:fs";
|
|
10
10
|
import * as __rspack_external_node_module_ab9f2194 from "node:module";
|
|
11
|
+
import * as __rspack_external_node_os_74b4b876 from "node:os";
|
|
11
12
|
import * as __rspack_external_node_path_c5b9b54f from "node:path";
|
|
13
|
+
import * as __rspack_external_node_process_786449bf from "node:process";
|
|
14
|
+
import * as __rspack_external_node_tty_c64aab7e from "node:tty";
|
|
12
15
|
import * as __rspack_external_node_url_e96de089 from "node:url";
|
|
13
16
|
import * as __rspack_external_os from "os";
|
|
14
17
|
import * as __rspack_external_path from "path";
|
|
15
18
|
import * as __rspack_external_url from "url";
|
|
16
19
|
import { __webpack_require__ } from "./rslib-runtime.js";
|
|
17
20
|
import { rspack as core_rspack } from "@rspack/core";
|
|
18
|
-
import
|
|
19
|
-
import node_os, { constants as external_node_os_constants, type as external_node_os_type } from "node:os";
|
|
20
|
-
import node_tty from "node:tty";
|
|
21
|
-
import { promisify as external_node_util_promisify, stripVTControlCharacters } from "node:util";
|
|
21
|
+
import { promisify as external_node_util_promisify, stripVTControlCharacters, styleText } from "node:util";
|
|
22
22
|
import { isPromise, isRegExp } from "node:util/types";
|
|
23
23
|
import node_zlib from "node:zlib";
|
|
24
|
-
function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : node_process.argv) {
|
|
25
|
-
let prefix = flag.startsWith('-') ? '' : 1 === flag.length ? '-' : '--', position = argv.indexOf(prefix + flag), terminatorPosition = argv.indexOf('--');
|
|
26
|
-
return -1 !== position && (-1 === terminatorPosition || position < terminatorPosition);
|
|
27
|
-
}
|
|
28
24
|
__webpack_require__.add({
|
|
29
25
|
"../../node_modules/.pnpm/deepmerge@4.3.1/node_modules/deepmerge/dist/cjs.js" (module) {
|
|
30
26
|
var isMergeableObject = function isMergeableObject(value) {
|
|
@@ -775,64 +771,6 @@ __webpack_require__.add({
|
|
|
775
771
|
return (asyncHooks.AsyncResource && (res = new asyncHooks.AsyncResource(fn.name || 'bound-anonymous-fn')), res && res.runInAsyncScope) ? res.runInAsyncScope.bind(res, fn, null) : fn;
|
|
776
772
|
}
|
|
777
773
|
},
|
|
778
|
-
"../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js" (module) {
|
|
779
|
-
let p = process || {}, argv = p.argv || [], env = p.env || {}, isColorSupported = !(env.NO_COLOR || argv.includes("--no-color")) && (!!env.FORCE_COLOR || argv.includes("--color") || "win32" === p.platform || (p.stdout || {}).isTTY && "dumb" !== env.TERM || !!env.CI), formatter = (open, close, replace = open)=>(input)=>{
|
|
780
|
-
let string = "" + input, index = string.indexOf(close, open.length);
|
|
781
|
-
return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
|
|
782
|
-
}, replaceClose = (string, close, replace, index)=>{
|
|
783
|
-
let result = "", cursor = 0;
|
|
784
|
-
do result += string.substring(cursor, index) + replace, cursor = index + close.length, index = string.indexOf(close, cursor);
|
|
785
|
-
while (~index);
|
|
786
|
-
return result + string.substring(cursor);
|
|
787
|
-
}, createColors = (enabled = isColorSupported)=>{
|
|
788
|
-
let f = enabled ? formatter : ()=>String;
|
|
789
|
-
return {
|
|
790
|
-
isColorSupported: enabled,
|
|
791
|
-
reset: f("\x1b[0m", "\x1b[0m"),
|
|
792
|
-
bold: f("\x1b[1m", "\x1b[22m", "\x1b[22m\x1b[1m"),
|
|
793
|
-
dim: f("\x1b[2m", "\x1b[22m", "\x1b[22m\x1b[2m"),
|
|
794
|
-
italic: f("\x1b[3m", "\x1b[23m"),
|
|
795
|
-
underline: f("\x1b[4m", "\x1b[24m"),
|
|
796
|
-
inverse: f("\x1b[7m", "\x1b[27m"),
|
|
797
|
-
hidden: f("\x1b[8m", "\x1b[28m"),
|
|
798
|
-
strikethrough: f("\x1b[9m", "\x1b[29m"),
|
|
799
|
-
black: f("\x1b[30m", "\x1b[39m"),
|
|
800
|
-
red: f("\x1b[31m", "\x1b[39m"),
|
|
801
|
-
green: f("\x1b[32m", "\x1b[39m"),
|
|
802
|
-
yellow: f("\x1b[33m", "\x1b[39m"),
|
|
803
|
-
blue: f("\x1b[34m", "\x1b[39m"),
|
|
804
|
-
magenta: f("\x1b[35m", "\x1b[39m"),
|
|
805
|
-
cyan: f("\x1b[36m", "\x1b[39m"),
|
|
806
|
-
white: f("\x1b[37m", "\x1b[39m"),
|
|
807
|
-
gray: f("\x1b[90m", "\x1b[39m"),
|
|
808
|
-
bgBlack: f("\x1b[40m", "\x1b[49m"),
|
|
809
|
-
bgRed: f("\x1b[41m", "\x1b[49m"),
|
|
810
|
-
bgGreen: f("\x1b[42m", "\x1b[49m"),
|
|
811
|
-
bgYellow: f("\x1b[43m", "\x1b[49m"),
|
|
812
|
-
bgBlue: f("\x1b[44m", "\x1b[49m"),
|
|
813
|
-
bgMagenta: f("\x1b[45m", "\x1b[49m"),
|
|
814
|
-
bgCyan: f("\x1b[46m", "\x1b[49m"),
|
|
815
|
-
bgWhite: f("\x1b[47m", "\x1b[49m"),
|
|
816
|
-
blackBright: f("\x1b[90m", "\x1b[39m"),
|
|
817
|
-
redBright: f("\x1b[91m", "\x1b[39m"),
|
|
818
|
-
greenBright: f("\x1b[92m", "\x1b[39m"),
|
|
819
|
-
yellowBright: f("\x1b[93m", "\x1b[39m"),
|
|
820
|
-
blueBright: f("\x1b[94m", "\x1b[39m"),
|
|
821
|
-
magentaBright: f("\x1b[95m", "\x1b[39m"),
|
|
822
|
-
cyanBright: f("\x1b[96m", "\x1b[39m"),
|
|
823
|
-
whiteBright: f("\x1b[97m", "\x1b[39m"),
|
|
824
|
-
bgBlackBright: f("\x1b[100m", "\x1b[49m"),
|
|
825
|
-
bgRedBright: f("\x1b[101m", "\x1b[49m"),
|
|
826
|
-
bgGreenBright: f("\x1b[102m", "\x1b[49m"),
|
|
827
|
-
bgYellowBright: f("\x1b[103m", "\x1b[49m"),
|
|
828
|
-
bgBlueBright: f("\x1b[104m", "\x1b[49m"),
|
|
829
|
-
bgMagentaBright: f("\x1b[105m", "\x1b[49m"),
|
|
830
|
-
bgCyanBright: f("\x1b[106m", "\x1b[49m"),
|
|
831
|
-
bgWhiteBright: f("\x1b[107m", "\x1b[49m")
|
|
832
|
-
};
|
|
833
|
-
};
|
|
834
|
-
module.exports = createColors(), module.exports.createColors = createColors;
|
|
835
|
-
},
|
|
836
774
|
"../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.6.1_postcss@8.5.6_yaml@2.8.2/node_modules/postcss-load-config/src/index.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
837
775
|
let yaml, { resolve } = __webpack_require__("node:path"), config = __webpack_require__("../../node_modules/.pnpm/lilconfig@3.1.3/node_modules/lilconfig/src/index.js"), loadOptions = __webpack_require__("../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.6.1_postcss@8.5.6_yaml@2.8.2/node_modules/postcss-load-config/src/options.js"), loadPlugins = __webpack_require__("../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.6.1_postcss@8.5.6_yaml@2.8.2/node_modules/postcss-load-config/src/plugins.js"), req = __webpack_require__("../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.6.1_postcss@8.5.6_yaml@2.8.2/node_modules/postcss-load-config/src/req.js");
|
|
838
776
|
async function processResult(ctx, result) {
|
|
@@ -991,9 +929,18 @@ __webpack_require__.add({
|
|
|
991
929
|
"node:module" (module) {
|
|
992
930
|
module.exports = __rspack_external_node_module_ab9f2194;
|
|
993
931
|
},
|
|
932
|
+
"node:os" (module) {
|
|
933
|
+
module.exports = __rspack_external_node_os_74b4b876;
|
|
934
|
+
},
|
|
994
935
|
"node:path" (module) {
|
|
995
936
|
module.exports = __rspack_external_node_path_c5b9b54f;
|
|
996
937
|
},
|
|
938
|
+
"node:process" (module) {
|
|
939
|
+
module.exports = __rspack_external_node_process_786449bf;
|
|
940
|
+
},
|
|
941
|
+
"node:tty" (module) {
|
|
942
|
+
module.exports = __rspack_external_node_tty_c64aab7e;
|
|
943
|
+
},
|
|
997
944
|
"node:url" (module) {
|
|
998
945
|
module.exports = __rspack_external_node_url_e96de089;
|
|
999
946
|
},
|
|
@@ -1007,7 +954,12 @@ __webpack_require__.add({
|
|
|
1007
954
|
module.exports = __rspack_external_url;
|
|
1008
955
|
}
|
|
1009
956
|
});
|
|
1010
|
-
let
|
|
957
|
+
let external_node_process_ = __webpack_require__("node:process"), external_node_os_ = __webpack_require__("node:os"), external_node_tty_ = __webpack_require__("node:tty"), createStyler = (style)=>(text)=>styleText(style, String(text)), bold = createStyler('bold'), red = createStyler('red'), green = createStyler('green'), yellow = createStyler('yellow'), magenta = createStyler('magenta'), cyan = createStyler('cyan'), gray = createStyler('gray');
|
|
958
|
+
function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : external_node_process_.default.argv) {
|
|
959
|
+
let prefix = flag.startsWith('-') ? '' : 1 === flag.length ? '-' : '--', position = argv.indexOf(prefix + flag), terminatorPosition = argv.indexOf('--');
|
|
960
|
+
return -1 !== position && (-1 === terminatorPosition || position < terminatorPosition);
|
|
961
|
+
}
|
|
962
|
+
let { env: dist_env } = external_node_process_.default;
|
|
1011
963
|
function envForceColor() {
|
|
1012
964
|
if (!('FORCE_COLOR' in dist_env)) return;
|
|
1013
965
|
if ('true' === dist_env.FORCE_COLOR) return 1;
|
|
@@ -1042,8 +994,8 @@ function _supportsColor(haveStream, { streamIsTTY, sniffFlags = !0 } = {}) {
|
|
|
1042
994
|
if (haveStream && !streamIsTTY && void 0 === forceColor) return 0;
|
|
1043
995
|
let min = forceColor || 0;
|
|
1044
996
|
if ('dumb' === dist_env.TERM) return min;
|
|
1045
|
-
if ('win32' ===
|
|
1046
|
-
let osRelease =
|
|
997
|
+
if ('win32' === external_node_process_.default.platform) {
|
|
998
|
+
let osRelease = external_node_os_.default.release().split('.');
|
|
1047
999
|
return Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586 ? Number(osRelease[2]) >= 14931 ? 3 : 2 : 1;
|
|
1048
1000
|
}
|
|
1049
1001
|
if ('CI' in dist_env) return [
|
|
@@ -1079,18 +1031,12 @@ function createSupportsColor(stream, options = {}) {
|
|
|
1079
1031
|
hasFlag('no-color') || hasFlag('no-colors') || hasFlag('color=false') || hasFlag('color=never') ? flagForceColor = 0 : (hasFlag('color') || hasFlag('colors') || hasFlag('color=true') || hasFlag('color=always')) && (flagForceColor = 1);
|
|
1080
1032
|
let supportsColor = {
|
|
1081
1033
|
stdout: createSupportsColor({
|
|
1082
|
-
isTTY:
|
|
1034
|
+
isTTY: external_node_tty_.default.isatty(1)
|
|
1083
1035
|
}),
|
|
1084
1036
|
stderr: createSupportsColor({
|
|
1085
|
-
isTTY:
|
|
1037
|
+
isTTY: external_node_tty_.default.isatty(2)
|
|
1086
1038
|
})
|
|
1087
|
-
}, colorLevel = supportsColor.stdout ? supportsColor.stdout.level : 0, errorStackRegExp = /at [^\r\n]{0,200}:\d+:\d+[\s\)]*$/, anonymousErrorStackRegExp = /at [^\r\n]{0,200}\(<anonymous>\)$/, indexErrorStackRegExp = /at [^\r\n]{0,200}\(index\s\d+\)$/,
|
|
1088
|
-
let string = '' + input, index = string.indexOf(close, open.length);
|
|
1089
|
-
return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
|
|
1090
|
-
} : String, replaceClose = (string, close, replace, index)=>{
|
|
1091
|
-
let start = string.substring(0, index) + replace, end = string.substring(index + close.length), nextIndex = end.indexOf(close);
|
|
1092
|
-
return ~nextIndex ? start + replaceClose(end, close, replace, nextIndex) : start + end;
|
|
1093
|
-
}, bold = formatter('\x1b[1m', '\x1b[22m', '\x1b[22m\x1b[1m'), red = formatter('\x1b[31m', '\x1b[39m'), green = formatter('\x1b[32m', '\x1b[39m'), yellow = formatter('\x1b[33m', '\x1b[39m'), magenta = formatter('\x1b[35m', '\x1b[39m'), cyan = formatter('\x1b[36m', '\x1b[39m'), gray = formatter('\x1b[90m', '\x1b[39m'), isWord = (char)=>!/[\s\n]/.test(char), LOG_LEVEL = {
|
|
1039
|
+
}, colorLevel = supportsColor.stdout ? supportsColor.stdout.level : 0, errorStackRegExp = /at [^\r\n]{0,200}:\d+:\d+[\s\)]*$/, anonymousErrorStackRegExp = /at [^\r\n]{0,200}\(<anonymous>\)$/, indexErrorStackRegExp = /at [^\r\n]{0,200}\(index\s\d+\)$/, isWord = (char)=>!/[\s\n]/.test(char), LOG_LEVEL = {
|
|
1094
1040
|
silent: -1,
|
|
1095
1041
|
error: 0,
|
|
1096
1042
|
warn: 1,
|
|
@@ -1174,9 +1120,18 @@ let supportsColor = {
|
|
|
1174
1120
|
}), logger.override = (customLogger)=>{
|
|
1175
1121
|
Object.assign(logger, customLogger);
|
|
1176
1122
|
}, logger;
|
|
1177
|
-
})(),
|
|
1178
|
-
|
|
1179
|
-
|
|
1123
|
+
})(), color_createStyler = (style)=>(text)=>styleText(style, String(text)), color = {
|
|
1124
|
+
red: color_createStyler('red'),
|
|
1125
|
+
yellow: color_createStyler('yellow'),
|
|
1126
|
+
green: color_createStyler('green'),
|
|
1127
|
+
blue: color_createStyler('blue'),
|
|
1128
|
+
magenta: color_createStyler('magenta'),
|
|
1129
|
+
cyan: color_createStyler('cyan'),
|
|
1130
|
+
gray: color_createStyler('gray'),
|
|
1131
|
+
dim: color_createStyler('dim'),
|
|
1132
|
+
bold: color_createStyler('bold'),
|
|
1133
|
+
underline: color_createStyler('underline')
|
|
1134
|
+
}, isDebug = ()=>{
|
|
1180
1135
|
if (!process.env.DEBUG) return !1;
|
|
1181
1136
|
let values = process.env.DEBUG.toLocaleLowerCase().split(',');
|
|
1182
1137
|
return [
|
|
@@ -1192,8 +1147,8 @@ function getTime() {
|
|
|
1192
1147
|
isDebug() && (src_logger.level = 'verbose'), src_logger.override({
|
|
1193
1148
|
debug: (message, ...args)=>{
|
|
1194
1149
|
if ('verbose' !== src_logger.level) return;
|
|
1195
|
-
let time =
|
|
1196
|
-
console.log(` ${
|
|
1150
|
+
let time = color.gray(getTime());
|
|
1151
|
+
console.log(` ${color.magenta('rsbuild')} ${time} ${message}`, ...args);
|
|
1197
1152
|
}
|
|
1198
1153
|
});
|
|
1199
1154
|
let external_events_ = __webpack_require__("events");
|
|
@@ -1391,7 +1346,7 @@ class GlobalCommand extends Command {
|
|
|
1391
1346
|
super("@@global@@", "", {}, cli);
|
|
1392
1347
|
}
|
|
1393
1348
|
}
|
|
1394
|
-
var __assign = Object.assign;
|
|
1349
|
+
var superClass, superClass1, __assign = Object.assign;
|
|
1395
1350
|
class CAC extends external_events_.EventEmitter {
|
|
1396
1351
|
constructor(name = ""){
|
|
1397
1352
|
super(), this.name = name, this.commands = [], this.rawArgs = [], this.args = [], this.options = {}, this.globalCommand = new GlobalCommand(this), this.globalCommand.usage("<command> [options]");
|
|
@@ -2262,7 +2217,7 @@ let external_node_module_ = __webpack_require__("node:module"), vendors_require
|
|
|
2262
2217
|
isMergeableObject: isPlainObject
|
|
2263
2218
|
});
|
|
2264
2219
|
function getFilename(config, type, isProd, isServer) {
|
|
2265
|
-
let { filename, filenameHash } = config.output, defaultHash = '[contenthash:
|
|
2220
|
+
let { filename, filenameHash } = config.output, defaultHash = '[contenthash:10]', getHash = ()=>'string' == typeof filenameHash ? filenameHash ? `.[${filenameHash}]` : '' : filenameHash ? `.${defaultHash}` : '';
|
|
2266
2221
|
switch(type){
|
|
2267
2222
|
case 'js':
|
|
2268
2223
|
return filename.js ?? `[name]${isProd && !isServer ? getHash() : ''}.js`;
|
|
@@ -2287,7 +2242,7 @@ function getFilename(config, type, isProd, isServer) {
|
|
|
2287
2242
|
if (filename.html) return filename.html;
|
|
2288
2243
|
return 'flat' === config.html.outputStructure ? '[name].html' : '[name]/index.html';
|
|
2289
2244
|
default:
|
|
2290
|
-
throw Error(`${
|
|
2245
|
+
throw Error(`${color.dim('[rsbuild:config]')} unknown key ${color.yellow(type)} in ${color.yellow('output.filename')}`);
|
|
2291
2246
|
}
|
|
2292
2247
|
}
|
|
2293
2248
|
function partition(array, predicate) {
|
|
@@ -2346,12 +2301,12 @@ function formatModuleTrace(stats, errorFile, level) {
|
|
|
2346
2301
|
...trace.slice(0, 2),
|
|
2347
2302
|
`… (${trace.length - 2 - 2} hidden)`,
|
|
2348
2303
|
...trace.slice(trace.length - 2)
|
|
2349
|
-
]),
|
|
2304
|
+
]), color.dim(`Import traces (entry → ${level}):\n ${trace.join('\n ')} ${color.bold(color.red('×'))}`);
|
|
2350
2305
|
}
|
|
2351
2306
|
function hintUnknownFiles(message) {
|
|
2352
2307
|
let hint = 'You may need an appropriate loader to handle this file type.';
|
|
2353
2308
|
if (-1 === message.indexOf(hint)) return message;
|
|
2354
|
-
let createPluginHint = (packageName, keyword)=>`To enable support for ${keyword}, use "${
|
|
2309
|
+
let createPluginHint = (packageName, keyword)=>`To enable support for ${keyword}, use "${color.yellow(`@rsbuild/plugin-${packageName}`)}" ${color.dim(`(https://npmjs.com/package/@rsbuild/plugin-${packageName})`)}.\n`;
|
|
2355
2310
|
for (let plugin of [
|
|
2356
2311
|
{
|
|
2357
2312
|
test: /File: .+\.s(c|a)ss/,
|
|
@@ -2394,10 +2349,10 @@ function formatStatsError(stats, root, level = 'error') {
|
|
|
2394
2349
|
let DATA_URI_PREFIX = "data:text/javascript,";
|
|
2395
2350
|
if (fileName.startsWith(DATA_URI_PREFIX)) {
|
|
2396
2351
|
let snippet = fileName.replace(DATA_URI_PREFIX, '');
|
|
2397
|
-
return snippet.length > 30 && (snippet = `${snippet.slice(0, 30)}...`), `File: ${
|
|
2352
|
+
return snippet.length > 30 && (snippet = `${snippet.slice(0, 30)}...`), `File: ${color.cyan('data-uri virtual module')} ${color.dim(`(${snippet})`)}\n`;
|
|
2398
2353
|
}
|
|
2399
2354
|
let prefix = root + external_node_path_.sep;
|
|
2400
|
-
return (fileName.startsWith(prefix) && (fileName = fileName.replace(prefix, `.${external_node_path_.sep}`)), /:\d+:\d+/.test(fileName)) ? `File: ${
|
|
2355
|
+
return (fileName.startsWith(prefix) && (fileName = fileName.replace(prefix, `.${external_node_path_.sep}`)), /:\d+:\d+/.test(fileName)) ? `File: ${color.cyan(fileName)}\n` : stats.loc ? `File: ${color.cyan(`${fileName}:${stats.loc}`)}\n` : `File: ${color.cyan(`${fileName}:1:1`)}\n`;
|
|
2401
2356
|
})(fileName, stats, root)}${stats.message}`, verbose = isVerbose();
|
|
2402
2357
|
if (verbose && (stats.details && (message += `\nDetails: ${stats.details}\n`), stats.stack && (message += `\n${stats.stack}`)), 'error' === level || isVerbose()) {
|
|
2403
2358
|
let moduleTrace = formatModuleTrace(stats, fileName, level);
|
|
@@ -2407,7 +2362,7 @@ function formatStatsError(stats, root, level = 'error') {
|
|
|
2407
2362
|
!verbose && message.includes(innerError) && (message = message.split(innerError)[0]);
|
|
2408
2363
|
let lines = (message = ((message)=>{
|
|
2409
2364
|
if (-1 === message.indexOf('Multiple assets emit different content to the same filename')) return message;
|
|
2410
|
-
let extraMessage = `You may need to adjust ${
|
|
2365
|
+
let extraMessage = `You may need to adjust ${color.yellow('output.filename')} configuration to prevent name conflicts. (See ${color.yellow('https://rsbuild.rs/config/output/filename')})`;
|
|
2411
2366
|
return `${message}\n${extraMessage}`;
|
|
2412
2367
|
})(message = ((message)=>{
|
|
2413
2368
|
let getTips = (moduleName)=>{
|
|
@@ -2415,9 +2370,9 @@ function formatStatsError(stats, root, level = 'error') {
|
|
|
2415
2370
|
`Error: "${moduleName}" is a built-in Node.js module and cannot be imported in client-side code.\n`,
|
|
2416
2371
|
'Solution: Check if you need to import Node.js module.',
|
|
2417
2372
|
' - If not needed, remove the import.',
|
|
2418
|
-
` - If needed, use "${
|
|
2373
|
+
` - If needed, use "${color.yellow('@rsbuild/plugin-node-polyfill')}" to polyfill it. (See ${color.yellow('https://npmjs.com/package/@rsbuild/plugin-node-polyfill')})`
|
|
2419
2374
|
];
|
|
2420
|
-
return `${message}\n\n${
|
|
2375
|
+
return `${message}\n\n${color.red(tips.join('\n'))}`;
|
|
2421
2376
|
};
|
|
2422
2377
|
if (message.includes('need an additional plugin to handle "node:" URIs')) return getTips('node:*');
|
|
2423
2378
|
if (!message.includes("Can't resolve")) return message;
|
|
@@ -2431,7 +2386,7 @@ function formatStatsError(stats, root, level = 'error') {
|
|
|
2431
2386
|
let ensureTrailingNewline = (input)=>input.replace(/[ \t]+$/, '').endsWith('\n') ? input : `${input}\n`;
|
|
2432
2387
|
function formatErrorMessage(errors) {
|
|
2433
2388
|
if (!errors.length) return 'Build failed. No errors reported since Rspack\'s "stats.errors" is disabled.';
|
|
2434
|
-
let title =
|
|
2389
|
+
let title = color.bold(color.red(errors.length > 1 ? 'Build errors: ' : 'Build error: ')), text = ensureTrailingNewline(errors.join('\n\n'));
|
|
2435
2390
|
return `${title}\n${text}`;
|
|
2436
2391
|
}
|
|
2437
2392
|
let getStatsErrors = ({ errors, children })=>void 0 !== errors && errors.length > 0 ? errors : children ? children.reduce((errors, ret)=>ret.errors ? errors.concat(ret.errors) : errors, []) : [], getStatsWarnings = ({ warnings, children })=>void 0 !== warnings && warnings.length > 0 ? warnings : children ? children.reduce((warnings, ret)=>ret.warnings ? warnings.concat(ret.warnings) : warnings, []) : [];
|
|
@@ -2471,7 +2426,7 @@ function formatStats(stats, hasErrors, root) {
|
|
|
2471
2426
|
};
|
|
2472
2427
|
let warningMessages = getStatsWarnings(stats).map((item)=>formatStatsError(item, root, 'warning'));
|
|
2473
2428
|
if (warningMessages.length) {
|
|
2474
|
-
let title =
|
|
2429
|
+
let title = color.bold(color.yellow(warningMessages.length > 1 ? 'Build warnings: \n' : 'Build warning: \n'));
|
|
2475
2430
|
return {
|
|
2476
2431
|
message: ensureTrailingNewline(`${title}${warningMessages.join('\n\n')}`),
|
|
2477
2432
|
level: 'warning'
|
|
@@ -3030,17 +2985,17 @@ function exit(exitCode, type) {
|
|
|
3030
2985
|
if (!isCalled) {
|
|
3031
2986
|
for (let callback of (isCalled = !0, exitHook_callbacks))callback(exitCode);
|
|
3032
2987
|
if ('SIGINT' === type) {
|
|
3033
|
-
let listeners =
|
|
3034
|
-
Array.isArray(listeners) && listeners.length <= 1 &&
|
|
2988
|
+
let listeners = external_node_process_.default.listeners('SIGINT');
|
|
2989
|
+
Array.isArray(listeners) && listeners.length <= 1 && external_node_process_.default.exit(exitCode);
|
|
3035
2990
|
}
|
|
3036
2991
|
}
|
|
3037
2992
|
}
|
|
3038
2993
|
function exitHook(onExit) {
|
|
3039
|
-
return exitHook_callbacks.add(onExit), isRegistered || (isRegistered = !0,
|
|
3040
|
-
exit(
|
|
3041
|
-
}),
|
|
3042
|
-
exit(
|
|
3043
|
-
}),
|
|
2994
|
+
return exitHook_callbacks.add(onExit), isRegistered || (isRegistered = !0, external_node_process_.default.on('SIGINT', ()=>{
|
|
2995
|
+
exit(external_node_os_.constants.signals.SIGINT + 128, 'SIGINT');
|
|
2996
|
+
}), external_node_process_.default.once('SIGTERM', ()=>{
|
|
2997
|
+
exit(external_node_os_.constants.signals.SIGTERM + 128, 'SIGTERM');
|
|
2998
|
+
}), external_node_process_.default.once('exit', (exitCode)=>{
|
|
3044
2999
|
exit(exitCode, 'exit');
|
|
3045
3000
|
})), ()=>{
|
|
3046
3001
|
exitHook_callbacks.delete(onExit);
|
|
@@ -3055,13 +3010,13 @@ let external_node_url_ = __webpack_require__("node:url"), addTrailingSlash = (s)
|
|
|
3055
3010
|
};
|
|
3056
3011
|
function validatePlugin(plugin) {
|
|
3057
3012
|
let type = typeof plugin;
|
|
3058
|
-
if ('object' !== type || null === plugin) throw Error(`${
|
|
3013
|
+
if ('object' !== type || null === plugin) throw Error(`${color.dim('[rsbuild:plugin]')} Expect Rsbuild plugin instance to be an object, but got ${color.yellow(type)}.`);
|
|
3059
3014
|
if (!isFunction(plugin.setup)) {
|
|
3060
3015
|
if (isFunction(plugin.apply)) {
|
|
3061
3016
|
let { name = 'SomeWebpackPlugin' } = plugin.constructor || {};
|
|
3062
3017
|
throw Error([
|
|
3063
|
-
`${
|
|
3064
|
-
|
|
3018
|
+
`${color.yellow(name)} looks like a webpack or Rspack plugin, please use ${color.yellow('`tools.rspack`')} to register it:`,
|
|
3019
|
+
color.green(`
|
|
3065
3020
|
// rsbuild.config.ts
|
|
3066
3021
|
export default {
|
|
3067
3022
|
tools: {
|
|
@@ -3073,7 +3028,7 @@ function validatePlugin(plugin) {
|
|
|
3073
3028
|
`)
|
|
3074
3029
|
].join('\n'));
|
|
3075
3030
|
}
|
|
3076
|
-
throw Error(`${
|
|
3031
|
+
throw Error(`${color.dim('[rsbuild:plugin]')} Expect the setup function of Rsbuild plugin to be a function, but got ${color.yellow(type)}.`);
|
|
3077
3032
|
}
|
|
3078
3033
|
}
|
|
3079
3034
|
let isEnvironmentMatch = (pluginEnvironment, specifiedEnvironment)=>pluginEnvironment === specifiedEnvironment || void 0 === pluginEnvironment;
|
|
@@ -3111,7 +3066,7 @@ async function initPlugins({ context, pluginManager }) {
|
|
|
3111
3066
|
let allLines = [];
|
|
3112
3067
|
function getPlugin(name) {
|
|
3113
3068
|
let targets = plugins.filter((item)=>item.instance.name === name);
|
|
3114
|
-
if (!targets.length) throw Error(`${
|
|
3069
|
+
if (!targets.length) throw Error(`${color.dim('[rsbuild:plugin]')} Plugin "${color.yellow(name)}" not existed`);
|
|
3115
3070
|
return targets;
|
|
3116
3071
|
}
|
|
3117
3072
|
for (let plugin of plugins){
|
|
@@ -3132,7 +3087,7 @@ async function initPlugins({ context, pluginManager }) {
|
|
|
3132
3087
|
if (allLines.length) {
|
|
3133
3088
|
let restInRingPoints = {};
|
|
3134
3089
|
for (let l of allLines)restInRingPoints[l[0]] = !0, restInRingPoints[l[1]] = !0;
|
|
3135
|
-
throw Error(`${
|
|
3090
|
+
throw Error(`${color.dim('[rsbuild:plugin]')} Plugins dependencies has loop: ${color.yellow(Object.keys(restInRingPoints).join(','))}`);
|
|
3136
3091
|
}
|
|
3137
3092
|
return sortedPoint;
|
|
3138
3093
|
})(plugins = ((plugins)=>{
|
|
@@ -3172,7 +3127,7 @@ async function initPlugins({ context, pluginManager }) {
|
|
|
3172
3127
|
}
|
|
3173
3128
|
function getHTMLPathByEntry(entryName, config) {
|
|
3174
3129
|
let filename = getFilename(config, 'html').replace('[name]', entryName), prefix = config.output.distPath.html;
|
|
3175
|
-
return prefix.startsWith('/') && src_logger.warn(`${
|
|
3130
|
+
return prefix.startsWith('/') && src_logger.warn(`${color.dim('[rsbuild:config]')} Absolute path is not recommended at ${color.yellow(`output.distPath.html: "${prefix}"`)}, use relative path instead.`), external_node_path_.posix.join(prefix, filename).replace(/^\/+/, '');
|
|
3176
3131
|
}
|
|
3177
3132
|
let mapProcessAssetsStage = (stage)=>{
|
|
3178
3133
|
let { Compilation } = core_rspack;
|
|
@@ -3210,7 +3165,7 @@ let mapProcessAssetsStage = (stage)=>{
|
|
|
3210
3165
|
case 'report':
|
|
3211
3166
|
return Compilation.PROCESS_ASSETS_STAGE_REPORT;
|
|
3212
3167
|
default:
|
|
3213
|
-
throw Error(`${
|
|
3168
|
+
throw Error(`${color.dim('[rsbuild]')} Invalid process assets stage: ${stage}`);
|
|
3214
3169
|
}
|
|
3215
3170
|
};
|
|
3216
3171
|
function initPluginAPI({ context, pluginManager }) {
|
|
@@ -3219,12 +3174,12 @@ function initPluginAPI({ context, pluginManager }) {
|
|
|
3219
3174
|
if (context.normalizedConfig) {
|
|
3220
3175
|
if (options?.environment) {
|
|
3221
3176
|
let config = context.normalizedConfig.environments[options.environment];
|
|
3222
|
-
if (!config) throw Error(`${
|
|
3177
|
+
if (!config) throw Error(`${color.dim('[rsbuild]')} Cannot find normalized config by environment: ${options.environment}.`);
|
|
3223
3178
|
return config;
|
|
3224
3179
|
}
|
|
3225
3180
|
return context.normalizedConfig;
|
|
3226
3181
|
}
|
|
3227
|
-
throw Error(`${
|
|
3182
|
+
throw Error(`${color.dim('[rsbuild]')} Cannot access normalized config until ${color.yellow('modifyRsbuildConfig')} is called.`);
|
|
3228
3183
|
}
|
|
3229
3184
|
let getRsbuildConfig = (type = 'current')=>{
|
|
3230
3185
|
switch(type){
|
|
@@ -3235,7 +3190,7 @@ function initPluginAPI({ context, pluginManager }) {
|
|
|
3235
3190
|
case 'normalized':
|
|
3236
3191
|
return getNormalizedConfig();
|
|
3237
3192
|
}
|
|
3238
|
-
throw Error(`${
|
|
3193
|
+
throw Error(`${color.dim('[rsbuild]')} ${color.yellow('getRsbuildConfig')} get an invalid type param.`);
|
|
3239
3194
|
}, exposed = new Map(), expose = (id, api)=>{
|
|
3240
3195
|
exposed.set(id, api);
|
|
3241
3196
|
}, useExposed = (id)=>exposed.get(id), transformId = 0, transformer = {}, processAssetsFns = [], resolveFns = [];
|
|
@@ -3444,7 +3399,7 @@ function createPublicContext(context) {
|
|
|
3444
3399
|
async function createContext(options, userConfig) {
|
|
3445
3400
|
let { cwd } = options, rootPath = userConfig.root ? ensureAbsolutePath(cwd, userConfig.root) : cwd, rsbuildConfig = await withDefaultConfig(rootPath, userConfig), cachePath = (0, external_node_path_.join)(rootPath, 'node_modules', '.cache'), specifiedEnvironments = options.environment && options.environment.length > 0 ? options.environment : void 0;
|
|
3446
3401
|
return {
|
|
3447
|
-
version: "2.0.0-beta.
|
|
3402
|
+
version: "2.0.0-beta.3",
|
|
3448
3403
|
rootPath,
|
|
3449
3404
|
distPath: '',
|
|
3450
3405
|
cachePath,
|
|
@@ -3501,7 +3456,7 @@ async function emitConfigFiles({ bundlerConfigs, environmentConfigs, extraConfig
|
|
|
3501
3456
|
await external_node_fs_.default.promises.mkdir(outputPath, {
|
|
3502
3457
|
recursive: !0
|
|
3503
3458
|
}), await Promise.all(files.map(async (item)=>external_node_fs_.default.promises.writeFile(item.path, `export default ${item.content}`)));
|
|
3504
|
-
let fileInfos = files.map((item)=>` - ${
|
|
3459
|
+
let fileInfos = files.map((item)=>` - ${color.bold(color.yellow(item.label))}: ${color.underline(item.path)}`).join('\n');
|
|
3505
3460
|
src_logger.success(`config inspection completed, generated files: \n\n${fileInfos}\n`);
|
|
3506
3461
|
}
|
|
3507
3462
|
function stringifyConfig(config, verbose) {
|
|
@@ -3748,23 +3703,16 @@ function getChainUtils(target, environment, environments) {
|
|
|
3748
3703
|
function validateRspackConfig(config) {
|
|
3749
3704
|
if (config.plugins) {
|
|
3750
3705
|
for (let plugin of config.plugins)if (plugin && void 0 === plugin.apply && 'name' in plugin && 'setup' in plugin) {
|
|
3751
|
-
let name =
|
|
3752
|
-
throw Error(`${
|
|
3706
|
+
let name = color.bold(color.yellow(plugin.name));
|
|
3707
|
+
throw Error(`${color.dim('[rsbuild:plugin]')} "${color.yellow(name)}" appears to be an Rsbuild plugin. It cannot be used as an Rspack plugin.`);
|
|
3753
3708
|
}
|
|
3754
3709
|
}
|
|
3755
|
-
config.devServer && src_logger.warn(`${
|
|
3710
|
+
config.devServer && src_logger.warn(`${color.dim('[rsbuild:config]')} Find invalid Rspack config: "${color.yellow('devServer')}". Note that Rspack's "devServer" config is not supported by Rsbuild. You can use Rsbuild's "dev" config to configure the Rsbuild dev server.`);
|
|
3756
3711
|
}
|
|
3757
3712
|
async function generateRspackConfig({ target, context, environmentName }) {
|
|
3758
|
-
let chainUtils = getChainUtils(target, context.environments[environmentName], context.environments),
|
|
3713
|
+
let chainUtils = getChainUtils(target, context.environments[environmentName], context.environments), rspackConfig = (await modifyBundlerChain(context, {
|
|
3759
3714
|
...chainUtils,
|
|
3760
|
-
bundler:
|
|
3761
|
-
BannerPlugin,
|
|
3762
|
-
DefinePlugin,
|
|
3763
|
-
IgnorePlugin,
|
|
3764
|
-
ProvidePlugin,
|
|
3765
|
-
SourceMapDevToolPlugin,
|
|
3766
|
-
HotModuleReplacementPlugin
|
|
3767
|
-
}
|
|
3715
|
+
bundler: core_rspack
|
|
3768
3716
|
})).toConfig();
|
|
3769
3717
|
return validateRspackConfig(rspackConfig = await modifyRspackConfig(context, rspackConfig, chainUtils)), rspackConfig;
|
|
3770
3718
|
}
|
|
@@ -3783,7 +3731,7 @@ async function modifyRsbuildConfig(context) {
|
|
|
3783
3731
|
let pluginsCount = context.config.plugins?.length ?? 0, [modified] = await context.hooks.modifyRsbuildConfig.callChain(context.config, {
|
|
3784
3732
|
mergeRsbuildConfig: mergeRsbuildConfig
|
|
3785
3733
|
});
|
|
3786
|
-
context.config = modified, (modified.plugins?.length ?? 0) !== pluginsCount && src_logger.warn(`${
|
|
3734
|
+
context.config = modified, (modified.plugins?.length ?? 0) !== pluginsCount && src_logger.warn(`${color.dim('[rsbuild]')} Cannot change plugins via ${color.yellow('modifyRsbuildConfig')} as plugins are already initialized when it executes.`), src_logger.debug('applied modifyRsbuildConfig hook');
|
|
3787
3735
|
}
|
|
3788
3736
|
async function modifyEnvironmentConfig(context, config, name) {
|
|
3789
3737
|
src_logger.debug(`applying modifyEnvironmentConfig hook (${name})`);
|
|
@@ -3800,8 +3748,8 @@ async function modifyEnvironmentConfig(context, config, name) {
|
|
|
3800
3748
|
return src_logger.debug(`applied modifyEnvironmentConfig hook (${name})`), modified;
|
|
3801
3749
|
}
|
|
3802
3750
|
let createEnvironmentNotFoundError = (environments = [])=>{
|
|
3803
|
-
let envList =
|
|
3804
|
-
return Error(`${
|
|
3751
|
+
let envList = color.yellow(environments.join(','));
|
|
3752
|
+
return Error(`${color.dim('[rsbuild:config]')} The current build is specified to run only in the ${envList} environment, but the configuration of the specified environment was not found.`);
|
|
3805
3753
|
};
|
|
3806
3754
|
async function initRsbuildConfig({ context, pluginManager }) {
|
|
3807
3755
|
var config, rootPath;
|
|
@@ -3887,7 +3835,7 @@ async function initRsbuildConfig({ context, pluginManager }) {
|
|
|
3887
3835
|
...normalizedBaseConfig,
|
|
3888
3836
|
environments
|
|
3889
3837
|
}, await updateEnvironmentContext(context, environments), updateContextByNormalizedConfig(context), ((config)=>{
|
|
3890
|
-
if (config.server.base && !config.server.base.startsWith('/')) throw Error(`${
|
|
3838
|
+
if (config.server.base && !config.server.base.startsWith('/')) throw Error(`${color.dim('[rsbuild:config]')} The ${color.yellow('"server.base"')} option should start with a slash, for example: "/base"`);
|
|
3891
3839
|
if (!config.environments) return;
|
|
3892
3840
|
let environmentNames = Object.keys(config.environments), environmentNameRegexp = /^[\w$-]+$/, validTargets = [
|
|
3893
3841
|
'web',
|
|
@@ -3895,9 +3843,9 @@ async function initRsbuildConfig({ context, pluginManager }) {
|
|
|
3895
3843
|
'web-worker'
|
|
3896
3844
|
];
|
|
3897
3845
|
for (let name of environmentNames){
|
|
3898
|
-
environmentNameRegexp.test(name) || src_logger.warn(`${
|
|
3846
|
+
environmentNameRegexp.test(name) || src_logger.warn(`${color.dim('[rsbuild:config]')} Environment name "${color.yellow(name)}" contains invalid characters. Only letters, numbers, "-", "_", and "$" are allowed.`);
|
|
3899
3847
|
let outputConfig = config.environments[name].output;
|
|
3900
|
-
if (outputConfig.target && !validTargets.includes(outputConfig.target)) throw Error(`${
|
|
3848
|
+
if (outputConfig.target && !validTargets.includes(outputConfig.target)) throw Error(`${color.dim('[rsbuild:config]')} Invalid value of ${color.yellow('output.target')}: ${color.yellow(`"${outputConfig.target}"`)}, valid values are: ${color.yellow(validTargets.join(', '))}`);
|
|
3901
3849
|
}
|
|
3902
3850
|
})(context.normalizedConfig), context.normalizedConfig;
|
|
3903
3851
|
}
|
|
@@ -3953,14 +3901,14 @@ function printBuildLog(compiler, context, lazyModules) {
|
|
|
3953
3901
|
let { modifiedFiles } = compiler, changedFiles = modifiedFiles?.size ? Array.from(modifiedFiles) : lazyModules.size ? Array.from(lazyModules) : null;
|
|
3954
3902
|
if (changedFiles?.length) {
|
|
3955
3903
|
let fileInfo = formatFileList(changedFiles, context.rootPath);
|
|
3956
|
-
src_logger.start(`building ${
|
|
3904
|
+
src_logger.start(`building ${color.dim(fileInfo)}`);
|
|
3957
3905
|
return;
|
|
3958
3906
|
}
|
|
3959
3907
|
let removedFiles = compiler.removedFiles ? Array.from(compiler.removedFiles) : null;
|
|
3960
3908
|
if (removedFiles?.length) {
|
|
3961
|
-
if (removedFiles.every((item)=>item.includes('virtual'))) return void src_logger.start(`building ${
|
|
3909
|
+
if (removedFiles.every((item)=>item.includes('virtual'))) return void src_logger.start(`building ${color.dim('virtual modules')}`);
|
|
3962
3910
|
let fileInfo = formatFileList(removedFiles, context.rootPath);
|
|
3963
|
-
return void src_logger.start(`building ${
|
|
3911
|
+
return void src_logger.start(`building ${color.dim(`removed ${fileInfo}`)}`);
|
|
3964
3912
|
}
|
|
3965
3913
|
src_logger.start('build started...');
|
|
3966
3914
|
}
|
|
@@ -3979,7 +3927,7 @@ async function createCompiler_createCompiler(options) {
|
|
|
3979
3927
|
if (item1 < item2) return -1;
|
|
3980
3928
|
}
|
|
3981
3929
|
return 0;
|
|
3982
|
-
})(version, '1.5.0') >= 0)) throw Error(`${
|
|
3930
|
+
})(version, '1.5.0') >= 0)) throw Error(`${color.dim('[rsbuild]')} The current Rspack version does not meet the requirements, the minimum supported version of Rspack is ${color.green("1.5.0")}`);
|
|
3983
3931
|
let isMultiCompiler = rspackConfigs.length > 1, compiler = isMultiCompiler ? core_rspack(rspackConfigs) : core_rspack(rspackConfigs[0]);
|
|
3984
3932
|
'true' === process.env.RSPACK_UNSAFE_FAST_DROP && (compiler.unsafeFastDrop = !0);
|
|
3985
3933
|
let isVersionLogged = !1, isCompiling = !1, logRspackVersion = ()=>{
|
|
@@ -4011,19 +3959,19 @@ async function createCompiler_createCompiler(options) {
|
|
|
4011
3959
|
if (null === startTime) return;
|
|
4012
3960
|
let { name } = context.environmentList[index], time = Date.now() - startTime;
|
|
4013
3961
|
context.buildState.time[name] = time;
|
|
4014
|
-
let suffix = isMultiCompiler ?
|
|
3962
|
+
let suffix = isMultiCompiler ? color.dim(` (${name})`) : '', timeStr = `${((seconds)=>{
|
|
4015
3963
|
let time, time1;
|
|
4016
3964
|
if (seconds < 10) {
|
|
4017
3965
|
let time, digits = seconds >= 0.01 ? 2 : 3;
|
|
4018
|
-
return `${time = seconds.toFixed(digits),
|
|
3966
|
+
return `${time = seconds.toFixed(digits), color.bold(time)} s`;
|
|
4019
3967
|
}
|
|
4020
3968
|
if (seconds < 60) {
|
|
4021
3969
|
let time;
|
|
4022
|
-
return `${time = seconds.toFixed(1),
|
|
3970
|
+
return `${time = seconds.toFixed(1), color.bold(time)} s`;
|
|
4023
3971
|
}
|
|
4024
|
-
let minutes = Math.floor(seconds / 60), minutesLabel = `${(time = minutes.toFixed(0),
|
|
3972
|
+
let minutes = Math.floor(seconds / 60), minutesLabel = `${(time = minutes.toFixed(0), color.bold(time))} m`, remainingSeconds = seconds % 60;
|
|
4025
3973
|
if (0 === remainingSeconds) return minutesLabel;
|
|
4026
|
-
let secondsLabel = `${(time1 = remainingSeconds.toFixed(+(remainingSeconds % 1 != 0)),
|
|
3974
|
+
let secondsLabel = `${(time1 = remainingSeconds.toFixed(+(remainingSeconds % 1 != 0)), color.bold(time1))} s`;
|
|
4027
3975
|
return `${minutesLabel} ${secondsLabel}`;
|
|
4028
3976
|
})(time / 1000)}${suffix}`;
|
|
4029
3977
|
hasErrors ? src_logger.error(`build failed in ${timeStr}`) : src_logger.ready(`built in ${timeStr}`);
|
|
@@ -4200,7 +4148,7 @@ function loadEnv_parse(src) {
|
|
|
4200
4148
|
function loadEnv({ cwd = process.cwd(), mode = process.env.NODE_ENV || '', prefixes = [
|
|
4201
4149
|
'PUBLIC_'
|
|
4202
4150
|
], processEnv = process.env } = {}) {
|
|
4203
|
-
if ('local' === mode) throw Error(`${
|
|
4151
|
+
if ('local' === mode) throw Error(`${color.dim('[rsbuild:loadEnv]')} ${color.yellow('local')} cannot be used as a value for env mode, because ${color.yellow('.env.local')} represents a temporary local file. Please use another value.`);
|
|
4204
4152
|
let filePaths = [
|
|
4205
4153
|
'.env',
|
|
4206
4154
|
'.env.local',
|
|
@@ -4384,7 +4332,7 @@ let getPostcssLoaderOptions = async ({ config, root, postcssrcCache })=>{
|
|
|
4384
4332
|
if ('function' == typeof postcssOptions) {
|
|
4385
4333
|
let postcssOptionsWrapper = (loaderContext)=>{
|
|
4386
4334
|
let options = postcssOptions(loaderContext);
|
|
4387
|
-
if ('object' != typeof options || null === options) throw Error(`${
|
|
4335
|
+
if ('object' != typeof options || null === options) throw Error(`${color.dim('[rsbuild:css]')} \`postcssOptions\` function must return a PostCSSOptions object, got ${color.yellow(typeof options)}.`);
|
|
4388
4336
|
return updatePostcssOptions({
|
|
4389
4337
|
...userOptions,
|
|
4390
4338
|
...options,
|
|
@@ -4406,7 +4354,7 @@ function checkProcessEnvSecurity(define) {
|
|
|
4406
4354
|
if (!value) return;
|
|
4407
4355
|
let check = (value)=>{
|
|
4408
4356
|
let pathKey = Object.keys(value).find((key)=>'path' === key.toLowerCase() && value[key] === process.env[key]);
|
|
4409
|
-
pathKey && src_logger.warn(`${
|
|
4357
|
+
pathKey && src_logger.warn(`${color.dim('[rsbuild:config]')} The ${color.yellow('"source.define"')} option includes an object with the key ${color.yellow(JSON.stringify(pathKey))} under ${color.yellow('"process.env"')}, indicating potential exposure of all environment variables. This can lead to security risks and should be avoided.`);
|
|
4410
4358
|
};
|
|
4411
4359
|
if ('object' == typeof value) return void check(value);
|
|
4412
4360
|
if ('string' == typeof value) try {
|
|
@@ -4460,10 +4408,10 @@ async function saveSnapshots(snapshotPath, snapshots) {
|
|
|
4460
4408
|
let EXCLUDE_ASSET_REGEX = /\.(?:map|LICENSE\.txt|d\.ts)$/, excludeAsset = (asset)=>EXCLUDE_ASSET_REGEX.test(asset.name), isSignificantDiff = (diff)=>Math.abs(diff) >= 10, formatDiff = (diff)=>{
|
|
4461
4409
|
let label = `(${diff > 0 ? '+' : '-'}${calcFileSize(Math.abs(diff))})`;
|
|
4462
4410
|
return {
|
|
4463
|
-
label: (diff > 0 ?
|
|
4411
|
+
label: (diff > 0 ? color.red : color.green)(label),
|
|
4464
4412
|
length: label.length
|
|
4465
4413
|
};
|
|
4466
|
-
}, getAssetColor = (size)=>size > 300000 ?
|
|
4414
|
+
}, getAssetColor = (size)=>size > 300000 ? color.red : size > 100000 ? color.yellow : (input)=>input;
|
|
4467
4415
|
function getHeader(maxFileLength, maxSizeLength, fileHeader, showGzipHeader) {
|
|
4468
4416
|
let lengths = [
|
|
4469
4417
|
maxFileLength,
|
|
@@ -4477,7 +4425,7 @@ function getHeader(maxFileLength, maxSizeLength, fileHeader, showGzipHeader) {
|
|
|
4477
4425
|
let length = lengths[index], curLabel = cur;
|
|
4478
4426
|
return length && (curLabel = cur.length < length ? cur + ' '.repeat(length - cur.length) : cur), `${prev + curLabel} `;
|
|
4479
4427
|
}, '');
|
|
4480
|
-
return
|
|
4428
|
+
return color.blue(headerRow);
|
|
4481
4429
|
}
|
|
4482
4430
|
let calcFileSize = (len)=>{
|
|
4483
4431
|
let val = len / 1000;
|
|
@@ -4510,7 +4458,7 @@ async function printFileSizes(options, stats, rootPath, distPath, environmentNam
|
|
|
4510
4458
|
isSignificantDiff(gzipDiff) && (gzipSizeLabel += ` ${formatDiff(gzipDiff).label}`);
|
|
4511
4459
|
}
|
|
4512
4460
|
}
|
|
4513
|
-
let folder = external_node_path_.default.join(relativeDistPath, external_node_path_.default.dirname(filePath)), filename = external_node_path_.default.basename(filePath), filenameLabel =
|
|
4461
|
+
let folder = external_node_path_.default.join(relativeDistPath, external_node_path_.default.dirname(filePath)), filename = external_node_path_.default.basename(filePath), filenameLabel = color.dim(folder + external_node_path_.default.sep) + (JS_REGEX.test(filename) ? color.cyan(filename) : filename.endsWith('.css') ? color.yellow(filename) : filename.endsWith('.html') ? color.green(filename) : color.magenta(filename)), filenameLength = (folder + external_node_path_.default.sep + filename).length;
|
|
4514
4462
|
return {
|
|
4515
4463
|
filePath,
|
|
4516
4464
|
filename,
|
|
@@ -4600,7 +4548,7 @@ async function printFileSizes(options, stats, rootPath, distPath, environmentNam
|
|
|
4600
4548
|
if (customTotal) logs.push(customTotal);
|
|
4601
4549
|
else {
|
|
4602
4550
|
let log = '';
|
|
4603
|
-
if (log += ' '.repeat(maxFileLength - totalSizeTitle.length), log +=
|
|
4551
|
+
if (log += ' '.repeat(maxFileLength - totalSizeTitle.length), log += color.magenta(totalSizeTitle), log += ` ${totalSizeLabel}`, options.compressed) {
|
|
4604
4552
|
let colorFn = getAssetColor(totalGzipSize / assets.length);
|
|
4605
4553
|
if (log += ' '.repeat(maxSizeLength - totalSizeLabelLength), log += ` ${colorFn(calcFileSize(totalGzipSize))}`, showDiff) {
|
|
4606
4554
|
let totalGzipSizeDiff = totalGzipSize - (previousSizes[environmentName]?.totalGzipSize ?? 0);
|
|
@@ -4614,8 +4562,8 @@ async function printFileSizes(options, stats, rootPath, distPath, environmentNam
|
|
|
4614
4562
|
let customTotal = getCustomTotal();
|
|
4615
4563
|
if (customTotal) logs.push(customTotal);
|
|
4616
4564
|
else {
|
|
4617
|
-
let log = `${
|
|
4618
|
-
options.compressed && (log +=
|
|
4565
|
+
let log = `${color.magenta(totalSizeTitle)} ${totalSizeLabel}`;
|
|
4566
|
+
options.compressed && (log += color.green(` (${calcFileSize(totalGzipSize)} gzipped)`)), logs.push(log);
|
|
4619
4567
|
}
|
|
4620
4568
|
}
|
|
4621
4569
|
return logs.push(''), {
|
|
@@ -4682,12 +4630,12 @@ class RsbuildHtmlPlugin {
|
|
|
4682
4630
|
let fileContent, name = external_node_path_.default.basename(favicon);
|
|
4683
4631
|
if (compilation.assets[name]) return name;
|
|
4684
4632
|
let inputFs = compilation.inputFileSystem;
|
|
4685
|
-
if (!inputFs) return addCompilationError(compilation, `${
|
|
4633
|
+
if (!inputFs) return addCompilationError(compilation, `${color.dim('[rsbuild:html]')} Failed to read the favicon file as ${color.yellow('compilation.inputFileSystem')} is not available.`), null;
|
|
4686
4634
|
let inputFilename = external_node_path_.default.isAbsolute(favicon) ? favicon : external_node_path_.default.join(compilation.compiler.context, favicon);
|
|
4687
4635
|
try {
|
|
4688
4636
|
fileContent = await readFileAsync(inputFs, inputFilename);
|
|
4689
4637
|
} catch (error) {
|
|
4690
|
-
return src_logger.debug(`read favicon error: ${error}`), addCompilationError(compilation, `${
|
|
4638
|
+
return src_logger.debug(`read favicon error: ${error}`), addCompilationError(compilation, `${color.dim('[rsbuild:html]')} Failed to read the favicon file at ${color.yellow(inputFilename)}.`), null;
|
|
4691
4639
|
}
|
|
4692
4640
|
let source = new core_rspack.sources.RawSource(fileContent, !1), outputFilename = external_node_path_.default.posix.join(faviconDistPath, name);
|
|
4693
4641
|
return compilation.emitAsset(outputFilename, source), outputFilename;
|
|
@@ -4850,7 +4798,7 @@ async function getTemplate(entryName, config, rootPath) {
|
|
|
4850
4798
|
}
|
|
4851
4799
|
let absolutePath = (0, external_node_path_.isAbsolute)(templatePath) ? templatePath : external_node_path_.default.join(rootPath, templatePath);
|
|
4852
4800
|
if (!existTemplatePath.has(absolutePath)) {
|
|
4853
|
-
if (!await isFileExists(absolutePath)) throw Error(`${
|
|
4801
|
+
if (!await isFileExists(absolutePath)) throw Error(`${color.dim('[rsbuild:html]')} Failed to resolve HTML template, check if the file exists: ${color.yellow(absolutePath)}`);
|
|
4854
4802
|
existTemplatePath.add(absolutePath);
|
|
4855
4803
|
}
|
|
4856
4804
|
let templateContent = await external_node_fs_.default.promises.readFile(absolutePath, 'utf-8');
|
|
@@ -4961,13 +4909,13 @@ function getURLMessages(urls, routes) {
|
|
|
4961
4909
|
if (routes.length <= 1) {
|
|
4962
4910
|
let pathname = routes.length ? routes[0].pathname : '';
|
|
4963
4911
|
return urls.map(({ label, url })=>{
|
|
4964
|
-
let normalizedPathname = normalizeUrl(`${url}${pathname}`), prefix = `➜ ${
|
|
4965
|
-
return ` ${prefix}${
|
|
4912
|
+
let normalizedPathname = normalizeUrl(`${url}${pathname}`), prefix = `➜ ${color.dim(label.padEnd(10))}`;
|
|
4913
|
+
return ` ${prefix}${color.cyan(normalizedPathname)}\n`;
|
|
4966
4914
|
}).join('');
|
|
4967
4915
|
}
|
|
4968
4916
|
let message = '', prevLabel = '', maxNameLength = Math.max(...routes.map((r)=>r.entryName.length));
|
|
4969
4917
|
return urls.forEach(({ label, url }, index)=>{
|
|
4970
|
-
for (let { entryName, pathname } of (prevLabel !== label && (index > 0 && (message += '\n'), message += ` ➜ ${label}\n`, prevLabel = label), routes))message += ` ${
|
|
4918
|
+
for (let { entryName, pathname } of (prevLabel !== label && (index > 0 && (message += '\n'), message += ` ➜ ${label}\n`, prevLabel = label), routes))message += ` ${color.dim('-')} ${color.dim(entryName.padEnd(maxNameLength + 4))}${color.cyan(normalizeUrl(`${url}${pathname}`))}\n`;
|
|
4971
4919
|
}), message;
|
|
4972
4920
|
}
|
|
4973
4921
|
function printServerURLs({ urls: originalUrls, port, routes, protocol, printUrls, trailingLineBreak = !0, originalConfig }) {
|
|
@@ -4981,7 +4929,7 @@ function printServerURLs({ urls: originalUrls, port, routes, protocol, printUrls
|
|
|
4981
4929
|
protocol
|
|
4982
4930
|
});
|
|
4983
4931
|
if (!newUrls) return null;
|
|
4984
|
-
if (!Array.isArray(newUrls)) throw Error(`${
|
|
4932
|
+
if (!Array.isArray(newUrls)) throw Error(`${color.dim('[rsbuild:config]')} "server.printUrls" must return an array, but got ${typeof newUrls}.`);
|
|
4985
4933
|
urls = newUrls.map((u)=>{
|
|
4986
4934
|
let { url, label } = 'string' == typeof u ? {
|
|
4987
4935
|
url: u
|
|
@@ -4994,7 +4942,7 @@ function printServerURLs({ urls: originalUrls, port, routes, protocol, printUrls
|
|
|
4994
4942
|
}
|
|
4995
4943
|
if (0 === urls.length || 0 === routes.length && !useCustomUrl) return null;
|
|
4996
4944
|
let message = getURLMessages(urls, routes);
|
|
4997
|
-
return originalConfig && originalConfig.server?.host === void 0 && (message += ` ➜ ${
|
|
4945
|
+
return originalConfig && originalConfig.server?.host === void 0 && (message += ` ➜ ${color.dim('Network:')} ${color.dim('use')} ${color.bold('--host')} ${color.dim('to expose')}\n`), !trailingLineBreak && message.endsWith('\n') && (message = message.slice(0, -1)), src_logger.log(message), message;
|
|
4998
4946
|
}
|
|
4999
4947
|
let getPort = async ({ host, port, strictPort, tryLimits = 20 })=>{
|
|
5000
4948
|
'string' == typeof port && (port = Number.parseInt(port, 10)), strictPort && (tryLimits = 1);
|
|
@@ -5013,15 +4961,15 @@ let getPort = async ({ host, port, strictPort, tryLimits = 20 })=>{
|
|
|
5013
4961
|
if ('EADDRINUSE' !== e.code) throw e;
|
|
5014
4962
|
port++, attempts++;
|
|
5015
4963
|
}
|
|
5016
|
-
if (!found) throw Error(`${
|
|
5017
|
-
if (port !== original && strictPort) throw Error(`${
|
|
4964
|
+
if (!found) throw Error(`${color.dim('[rsbuild:server]')} Failed to find an available port after ${tryLimits + 1} attempts, starting from ${color.yellow(original)}.`);
|
|
4965
|
+
if (port !== original && strictPort) throw Error(`${color.dim('[rsbuild:server]')} Port ${color.yellow(original)} is occupied, please choose another one.`);
|
|
5018
4966
|
return port;
|
|
5019
4967
|
}, getServerConfig = async ({ config })=>{
|
|
5020
4968
|
let { host, port: originalPort, strictPort } = config.server, port = await getPort({
|
|
5021
4969
|
host,
|
|
5022
4970
|
port: originalPort,
|
|
5023
4971
|
strictPort
|
|
5024
|
-
}), https = !!config.server.https, portTip = port !== originalPort ? `port ${originalPort} is in use, ${
|
|
4972
|
+
}), https = !!config.server.https, portTip = port !== originalPort ? `port ${originalPort} is in use, ${color.yellow(`using port ${port}.`)}` : void 0;
|
|
5025
4973
|
return {
|
|
5026
4974
|
port,
|
|
5027
4975
|
host,
|
|
@@ -5059,7 +5007,7 @@ let getPort = async ({ host, port, strictPort, tryLimits = 20 })=>{
|
|
|
5059
5007
|
];
|
|
5060
5008
|
}
|
|
5061
5009
|
let ipv4Interfaces = (()=>{
|
|
5062
|
-
let interfaces =
|
|
5010
|
+
let interfaces = external_node_os_.default.networkInterfaces(), ipv4Interfaces = new Map();
|
|
5063
5011
|
for (let key of Object.keys(interfaces))for (let detail of interfaces[key]){
|
|
5064
5012
|
let familyV4Value = 'string' == typeof detail.family ? 'IPv4' : 4;
|
|
5065
5013
|
detail.family !== familyV4Value || ipv4Interfaces.has(detail.address) || ipv4Interfaces.set(detail.address, detail);
|
|
@@ -5155,7 +5103,7 @@ function resolveUrl(str, base) {
|
|
|
5155
5103
|
try {
|
|
5156
5104
|
return new external_node_url_.URL(str, base).href;
|
|
5157
5105
|
} catch {
|
|
5158
|
-
throw Error(`${
|
|
5106
|
+
throw Error(`${color.dim('[rsbuild:open]')} Invalid input: ${color.yellow(str)} is not a valid URL or pathname`);
|
|
5159
5107
|
}
|
|
5160
5108
|
}
|
|
5161
5109
|
async function open_open({ https, port, routes, config, clearCache }) {
|
|
@@ -5260,7 +5208,7 @@ function applyAlias({ chain, config, rootPath }) {
|
|
|
5260
5208
|
if (config.resolve.dedupe) for (let pkgName of config.resolve.dedupe){
|
|
5261
5209
|
let pkgPath;
|
|
5262
5210
|
if (mergedAlias[pkgName]) {
|
|
5263
|
-
src_logger.debug(`${
|
|
5211
|
+
src_logger.debug(`${color.dim('[rsbuild:resolve]')} The package ${color.yellow(pkgName)} is already in the alias config, dedupe option for ${color.yellow(pkgName)} will be ignored.`);
|
|
5264
5212
|
continue;
|
|
5265
5213
|
}
|
|
5266
5214
|
try {
|
|
@@ -5282,7 +5230,7 @@ function applyAlias({ chain, config, rootPath }) {
|
|
|
5282
5230
|
].join(external_node_path_.sep);
|
|
5283
5231
|
for(; !pkgPath.endsWith(trailing) && pkgPath.includes('node_modules');)pkgPath = (0, external_node_path_.dirname)(pkgPath);
|
|
5284
5232
|
} catch {
|
|
5285
|
-
src_logger.debug(`${
|
|
5233
|
+
src_logger.debug(`${color.dim('[rsbuild:resolve]')} The package ${color.yellow(pkgName)} is not resolved in the project, dedupe option for ${color.yellow(pkgName)} will be ignored.`);
|
|
5286
5234
|
continue;
|
|
5287
5235
|
}
|
|
5288
5236
|
mergedAlias[pkgName] = pkgPath;
|
|
@@ -5623,7 +5571,7 @@ function applyCoreJs(swcConfig, polyfillMode, rootPath) {
|
|
|
5623
5571
|
]
|
|
5624
5572
|
});
|
|
5625
5573
|
} catch {
|
|
5626
|
-
throw Error(`${
|
|
5574
|
+
throw Error(`${color.dim('[rsbuild:polyfill]')} Failed to resolve ${color.yellow('core-js')} dependency. Install ${color.yellow('core-js >= 3.0.0')} to use polyfills.`);
|
|
5627
5575
|
}
|
|
5628
5576
|
})(rootPath), version = ((corejsPkgPath)=>{
|
|
5629
5577
|
try {
|
|
@@ -5655,7 +5603,7 @@ function applySwcDecoratorConfig(swcConfig, config) {
|
|
|
5655
5603
|
swcConfig.jsc.transform.legacyDecorator = !1, swcConfig.jsc.transform.decoratorVersion = '2022-03';
|
|
5656
5604
|
break;
|
|
5657
5605
|
default:
|
|
5658
|
-
throw Error(`${
|
|
5606
|
+
throw Error(`${color.dim('[rsbuild:swc]')} Unknown decorators version: ${color.yellow(version)}`);
|
|
5659
5607
|
}
|
|
5660
5608
|
}
|
|
5661
5609
|
async function getLocalhostResolvedAddress() {
|
|
@@ -5998,13 +5946,19 @@ function setupWriteToDisk(compilers, writeToDisk) {
|
|
|
5998
5946
|
}), compiler.__hasRsbuildAssetEmittedCallback = !0);
|
|
5999
5947
|
});
|
|
6000
5948
|
}
|
|
6001
|
-
let noop = ()=>{},
|
|
5949
|
+
let noop = ()=>{}, normalizeLiveReload = (liveReload)=>'boolean' == typeof liveReload ? {
|
|
5950
|
+
enabled: liveReload,
|
|
5951
|
+
html: liveReload
|
|
5952
|
+
} : {
|
|
5953
|
+
enabled: !0,
|
|
5954
|
+
html: !1 !== liveReload.html
|
|
5955
|
+
}, isTsError = (error)=>'message' in error && error.stack?.includes('ts-checker-rspack-plugin');
|
|
6002
5956
|
function applyHMREntry({ config, compiler, token, resolvedHost, resolvedPort }) {
|
|
6003
5957
|
if (!((compiler)=>{
|
|
6004
5958
|
let { target } = compiler.options;
|
|
6005
5959
|
return !!target && (Array.isArray(target) ? target.includes('web') : 'web' === target);
|
|
6006
5960
|
})(compiler) || !config.dev.hmr && !config.dev.liveReload) return;
|
|
6007
|
-
let clientConfig = {
|
|
5961
|
+
let { enabled: liveReloadEnabled } = normalizeLiveReload(config.dev.liveReload), clientConfig = {
|
|
6008
5962
|
...config.dev.client
|
|
6009
5963
|
};
|
|
6010
5964
|
'<port>' === clientConfig.port && (clientConfig.port = resolvedPort);
|
|
@@ -6015,7 +5969,7 @@ init(
|
|
|
6015
5969
|
${JSON.stringify(clientConfig)},
|
|
6016
5970
|
${JSON.stringify(resolvedHost)},
|
|
6017
5971
|
${resolvedPort},
|
|
6018
|
-
${
|
|
5972
|
+
${liveReloadEnabled},
|
|
6019
5973
|
${!!config.dev.browserLogs},
|
|
6020
5974
|
${JSON.stringify(config.dev.client.logLevel)}
|
|
6021
5975
|
)
|
|
@@ -6037,14 +5991,14 @@ let assets_middleware_assetsMiddleware = async ({ config, compiler, context, soc
|
|
|
6037
5991
|
compiler,
|
|
6038
5992
|
resolvedHost,
|
|
6039
5993
|
resolvedPort
|
|
6040
|
-
}), (({ context, compiler, token, socketServer })=>{
|
|
5994
|
+
}), (({ context, compiler, token, socketServer, liveReload })=>{
|
|
6041
5995
|
if (((compiler)=>{
|
|
6042
5996
|
let { target } = compiler.options;
|
|
6043
5997
|
return !!target && (Array.isArray(target) ? target.includes('node') : 'node' === target);
|
|
6044
5998
|
})(compiler)) return;
|
|
6045
5999
|
let errorsCount = null, warningsCount = null;
|
|
6046
6000
|
compiler.hooks.invalid.tap('rsbuild-dev-server', (fileName)=>{
|
|
6047
|
-
errorsCount = null, warningsCount = null, 'string' == typeof fileName && fileName.endsWith('.html') && socketServer.sockWrite({
|
|
6001
|
+
errorsCount = null, warningsCount = null, 'string' == typeof fileName && fileName.endsWith('.html') && normalizeLiveReload(liveReload).html && socketServer.sockWrite({
|
|
6048
6002
|
type: 'static-changed'
|
|
6049
6003
|
}, token);
|
|
6050
6004
|
}), compiler.hooks.done.tap('rsbuild-dev-server', (stats)=>{
|
|
@@ -6076,7 +6030,8 @@ let assets_middleware_assetsMiddleware = async ({ config, compiler, context, soc
|
|
|
6076
6030
|
context,
|
|
6077
6031
|
compiler,
|
|
6078
6032
|
socketServer,
|
|
6079
|
-
token
|
|
6033
|
+
token,
|
|
6034
|
+
liveReload: environment.config.dev.liveReload
|
|
6080
6035
|
}));
|
|
6081
6036
|
});
|
|
6082
6037
|
let compilers = compiler_isMultiCompiler(compiler) ? compiler.compilers : [
|
|
@@ -6242,14 +6197,14 @@ let isValidMethodName = (methodName)=>'<unknown>' !== methodName && !/[\\/]/.tes
|
|
|
6242
6197
|
return result;
|
|
6243
6198
|
}, formatBrowserErrorLog = async (message, context, fs, stackTrace, stackFrames, cachedTraceMap)=>{
|
|
6244
6199
|
var log;
|
|
6245
|
-
let log1 =
|
|
6200
|
+
let log1 = color.red(message);
|
|
6246
6201
|
if (stackFrames?.length) switch(stackTrace){
|
|
6247
6202
|
case 'summary':
|
|
6248
6203
|
{
|
|
6249
6204
|
let resolved = await resolveOriginalLocation(stackFrames, fs, context, cachedTraceMap);
|
|
6250
6205
|
if (!resolved) break;
|
|
6251
6206
|
let { frame, location } = resolved, { methodName } = frame, suffix = '';
|
|
6252
|
-
isValidMethodName(methodName) && (suffix += ` at ${methodName}`), location && (suffix += ` (${location})`), log1 += suffix ?
|
|
6207
|
+
isValidMethodName(methodName) && (suffix += ` at ${methodName}`), location && (suffix += ` (${location})`), log1 += suffix ? color.dim(suffix) : '';
|
|
6253
6208
|
break;
|
|
6254
6209
|
}
|
|
6255
6210
|
case 'full':
|
|
@@ -6258,7 +6213,7 @@ let isValidMethodName = (methodName)=>'<unknown>' !== methodName && !/[\\/]/.tes
|
|
|
6258
6213
|
fullStack && (log1 += fullStack);
|
|
6259
6214
|
}
|
|
6260
6215
|
}
|
|
6261
|
-
return (log = log1).includes('ReferenceError: process is not defined') ? `${log}\n${
|
|
6216
|
+
return (log = log1).includes('ReferenceError: process is not defined') ? `${log}\n${color.yellow(" - `process` is a Node.js global and not available in browsers.\n - To access `process.env.*`, define them in a `.env` file with the `PUBLIC_` prefix.\n - Or configure them via `source.define`.\n - Alternatively, install `@rsbuild/plugin-node-polyfill` to polyfill Node.js globals.")}` : log;
|
|
6262
6217
|
}, styles = {
|
|
6263
6218
|
1: 'font-weight:bold',
|
|
6264
6219
|
2: 'opacity:0.5',
|
|
@@ -6425,7 +6380,7 @@ class SocketServer {
|
|
|
6425
6380
|
let { browserLogs, client } = config.dev;
|
|
6426
6381
|
if ('client-error' === payload.type && !context.buildState.hasErrors && browserLogs) {
|
|
6427
6382
|
let stackTrace = isObject(browserLogs) && browserLogs.stackTrace || DEFAULT_STACK_TRACE, outputFs = this.getOutputFileSystem(), stackFrames = payload.stack ? stack_trace_parser_esm_parse(payload.stack) : null, cachedTraceMap = new Map(), log = await formatBrowserErrorLog(payload.message, context, outputFs, stackTrace, stackFrames, cachedTraceMap);
|
|
6428
|
-
if (this.reportedBrowserLogs.has(log) || (this.reportedBrowserLogs.add(log), src_logger.error(`${
|
|
6383
|
+
if (this.reportedBrowserLogs.has(log) || (this.reportedBrowserLogs.add(log), src_logger.error(`${color.cyan('[browser]')} ${log}`)), 'object' == typeof client.overlay && client.overlay.runtime) {
|
|
6429
6384
|
let resolvedLog = 'full' === stackTrace ? log : await formatBrowserErrorLog(payload.message, context, outputFs, 'full', stackFrames, cachedTraceMap);
|
|
6430
6385
|
this.sockWrite({
|
|
6431
6386
|
type: 'resolved-client-error',
|
|
@@ -6538,19 +6493,19 @@ async function setupCliShortcuts({ help = !0, openPage, closeServer, printUrls,
|
|
|
6538
6493
|
let shortcuts = [
|
|
6539
6494
|
{
|
|
6540
6495
|
key: 'c',
|
|
6541
|
-
description: `${
|
|
6496
|
+
description: `${color.bold('c + enter')} ${color.dim('clear console')}`,
|
|
6542
6497
|
action: ()=>{
|
|
6543
6498
|
console.clear();
|
|
6544
6499
|
}
|
|
6545
6500
|
},
|
|
6546
6501
|
{
|
|
6547
6502
|
key: 'o',
|
|
6548
|
-
description: `${
|
|
6503
|
+
description: `${color.bold('o + enter')} ${color.dim('open in browser')}`,
|
|
6549
6504
|
action: openPage
|
|
6550
6505
|
},
|
|
6551
6506
|
{
|
|
6552
6507
|
key: 'q',
|
|
6553
|
-
description: `${
|
|
6508
|
+
description: `${color.bold('q + enter')} ${color.dim('quit process')}`,
|
|
6554
6509
|
action: async ()=>{
|
|
6555
6510
|
try {
|
|
6556
6511
|
await closeServer();
|
|
@@ -6561,23 +6516,23 @@ async function setupCliShortcuts({ help = !0, openPage, closeServer, printUrls,
|
|
|
6561
6516
|
},
|
|
6562
6517
|
restartServer ? {
|
|
6563
6518
|
key: 'r',
|
|
6564
|
-
description: `${
|
|
6519
|
+
description: `${color.bold('r + enter')} ${color.dim('restart server')}`,
|
|
6565
6520
|
action: restartServer
|
|
6566
6521
|
} : null,
|
|
6567
6522
|
{
|
|
6568
6523
|
key: 'u',
|
|
6569
|
-
description: `${
|
|
6524
|
+
description: `${color.bold('u + enter')} ${color.dim('show urls')}`,
|
|
6570
6525
|
action: printUrls
|
|
6571
6526
|
}
|
|
6572
6527
|
].filter(Boolean);
|
|
6573
|
-
if (customShortcuts && !Array.isArray(shortcuts = customShortcuts(shortcuts))) throw Error(`${
|
|
6574
|
-
help && src_logger.log(!0 === help ? ` ➜ ${
|
|
6528
|
+
if (customShortcuts && !Array.isArray(shortcuts = customShortcuts(shortcuts))) throw Error(`${color.dim('[rsbuild:config]')} ${color.yellow('dev.cliShortcuts')} option must return an array of shortcuts.`);
|
|
6529
|
+
help && src_logger.log(!0 === help ? ` ➜ ${color.dim('press')} ${color.bold('h + enter')} ${color.dim('to show shortcuts')}\n` : ` ➜ ${help}\n`);
|
|
6575
6530
|
let { createInterface } = await import("node:readline"), rl = createInterface({
|
|
6576
6531
|
input: process.stdin
|
|
6577
6532
|
});
|
|
6578
6533
|
return rl.on('line', (input)=>{
|
|
6579
6534
|
if ('h' === input) {
|
|
6580
|
-
let message = `\n ${
|
|
6535
|
+
let message = `\n ${color.bold(color.blue('Shortcuts:'))}\n`;
|
|
6581
6536
|
for (let shortcut of shortcuts)message += ` ${shortcut.description}\n`;
|
|
6582
6537
|
src_logger.log(message);
|
|
6583
6538
|
}
|
|
@@ -6683,8 +6638,8 @@ let faviconFallbackMiddleware = (req, res, next)=>{
|
|
|
6683
6638
|
return (req, res, next)=>{
|
|
6684
6639
|
let _startAt = process.hrtime();
|
|
6685
6640
|
on_finished_default()(res, ()=>{
|
|
6686
|
-
let method = req.method, url = req.originalUrl || req.url, status = Number(res.statusCode), statusColor = status >= 500 ?
|
|
6687
|
-
src_logger.debug(`${statusColor(status)} ${method} ${url} ${
|
|
6641
|
+
let method = req.method, url = req.originalUrl || req.url, status = Number(res.statusCode), statusColor = status >= 500 ? color.red : status >= 400 ? color.yellow : status >= 300 ? color.cyan : status >= 200 ? color.green : (res)=>res, endAt = process.hrtime(), totalTime = (endAt[0] - _startAt[0]) * 1e3 + (endAt[1] - _startAt[1]) * 1e-6;
|
|
6642
|
+
src_logger.debug(`${statusColor(status)} ${method} ${url} ${color.dim(`${totalTime.toFixed(3)} ms`)}`);
|
|
6688
6643
|
}), next();
|
|
6689
6644
|
};
|
|
6690
6645
|
}, notFoundMiddleware = (_req, res, _next)=>{
|
|
@@ -6727,7 +6682,7 @@ let faviconFallbackMiddleware = (req, res, next)=>{
|
|
|
6727
6682
|
}), res.end(`The server is configured with a base URL of ${base} - did you mean to visit ${redirectPath} instead?`);
|
|
6728
6683
|
};
|
|
6729
6684
|
function formatProxyOptions(proxyOptions) {
|
|
6730
|
-
let logPrefix =
|
|
6685
|
+
let logPrefix = color.dim('[http-proxy-middleware]: '), defaultOptions = {
|
|
6731
6686
|
changeOrigin: !0,
|
|
6732
6687
|
logger: {
|
|
6733
6688
|
info (msg) {
|
|
@@ -6752,8 +6707,8 @@ function formatProxyOptions(proxyOptions) {
|
|
|
6752
6707
|
} : value
|
|
6753
6708
|
}));
|
|
6754
6709
|
}
|
|
6755
|
-
function createProxyMiddleware(proxyOptions) {
|
|
6756
|
-
let formattedOptions = formatProxyOptions(proxyOptions), proxyMiddlewares = [], middlewares = [], { createProxyMiddleware: baseMiddleware } =
|
|
6710
|
+
async function createProxyMiddleware(proxyOptions) {
|
|
6711
|
+
let formattedOptions = formatProxyOptions(proxyOptions), proxyMiddlewares = [], middlewares = [], { createProxyMiddleware: baseMiddleware } = await import("./http-proxy-middleware.js").then(__webpack_require__.t.bind(__webpack_require__, "../../node_modules/.pnpm/http-proxy-middleware@3.0.5_supports-color@10.2.2/node_modules/http-proxy-middleware/dist/index.js", 23));
|
|
6757
6712
|
for (let opts of formattedOptions){
|
|
6758
6713
|
let proxyMiddleware = baseMiddleware(opts), middleware = async (req, res, next)=>{
|
|
6759
6714
|
let bypassUrl = 'function' == typeof opts.bypass ? await opts.bypass(req, res, opts) : null;
|
|
@@ -6779,7 +6734,7 @@ let applyDefaultMiddlewares = async ({ config, buildManager, context, devServerA
|
|
|
6779
6734
|
for (let [key, value] of Object.entries(headers))res.setHeader(key, value);
|
|
6780
6735
|
next();
|
|
6781
6736
|
}), server.proxy) {
|
|
6782
|
-
let { middlewares: proxyMiddlewares, upgrade } = createProxyMiddleware(server.proxy);
|
|
6737
|
+
let { middlewares: proxyMiddlewares, upgrade } = await createProxyMiddleware(server.proxy);
|
|
6783
6738
|
for (let middleware of (upgradeEvents.push(upgrade), proxyMiddlewares))middlewares.push(middleware);
|
|
6784
6739
|
}
|
|
6785
6740
|
let { compress } = server;
|
|
@@ -6894,7 +6849,7 @@ let applyDefaultMiddlewares = async ({ config, buildManager, context, devServerA
|
|
|
6894
6849
|
let filePath = external_node_path_.default.join(distPath, 'index.html');
|
|
6895
6850
|
if (await middlewares_isFileExists(filePath, buildManager.outputFileSystem)) {
|
|
6896
6851
|
let newUrl = '/index.html';
|
|
6897
|
-
isVerbose() && src_logger.debug(` ${req.method} ${req.url} ${
|
|
6852
|
+
isVerbose() && src_logger.debug(` ${req.method} ${req.url} ${color.yellow('fallback to')} ${newUrl}`), req.url = newUrl, buildManager.assetsMiddleware(req, res, (...args)=>{
|
|
6898
6853
|
next(...args);
|
|
6899
6854
|
});
|
|
6900
6855
|
return;
|
|
@@ -6997,7 +6952,7 @@ class BasicRunner {
|
|
|
6997
6952
|
postExecute(_m, _file) {}
|
|
6998
6953
|
createRunner() {
|
|
6999
6954
|
this.requirers.set('entry', (_currentDirectory, _modulePath, _context = {})=>{
|
|
7000
|
-
throw Error(`${
|
|
6955
|
+
throw Error(`${color.dim('[rsbuild:runner]')} Not implemented`);
|
|
7001
6956
|
});
|
|
7002
6957
|
}
|
|
7003
6958
|
}
|
|
@@ -7076,7 +7031,7 @@ class CommonJsRunner extends BasicRunner {
|
|
|
7076
7031
|
class EsmRunner extends CommonJsRunner {
|
|
7077
7032
|
createRunner() {
|
|
7078
7033
|
super.createRunner(), this.requirers.set('cjs', this.getRequire()), this.requirers.set('esm', this.createEsmRequirer());
|
|
7079
|
-
let outputModule = this._options.compilerOptions.
|
|
7034
|
+
let outputModule = this._options.compilerOptions.output.module;
|
|
7080
7035
|
this.requirers.set('entry', (currentDirectory, modulePath, context)=>{
|
|
7081
7036
|
let file = this.getFile(modulePath, currentDirectory);
|
|
7082
7037
|
return file ? outputModule && !file.path.endsWith('.cjs') ? this.requirers.get('esm')(currentDirectory, modulePath, {
|
|
@@ -7091,7 +7046,7 @@ class EsmRunner extends CommonJsRunner {
|
|
|
7091
7046
|
createEsmRequirer() {
|
|
7092
7047
|
let esmCache = new Map(), esmIdentifier = this._options.name, vm = vendors_require('node:vm');
|
|
7093
7048
|
return (currentDirectory, modulePath, context = {})=>{
|
|
7094
|
-
if (!vm.SourceTextModule) throw Error(`${
|
|
7049
|
+
if (!vm.SourceTextModule) throw Error(`${color.dim('[rsbuild:runner]')} Running ESM bundle needs add Node.js option ${color.yellow('--experimental-vm-modules')}.`);
|
|
7095
7050
|
let _require = this.getRequire(), file = context.file || this.getFile(modulePath, currentDirectory);
|
|
7096
7051
|
if (!file) return this.requirers.get('miss')(currentDirectory, modulePath);
|
|
7097
7052
|
let esm = esmCache.get(file.path);
|
|
@@ -7127,7 +7082,7 @@ class BasicRunnerFactory {
|
|
|
7127
7082
|
name: this.name,
|
|
7128
7083
|
...options
|
|
7129
7084
|
}, { compilerOptions } = options;
|
|
7130
|
-
if ('web' === compilerOptions.target || 'webworker' === compilerOptions.target) throw Error(`${
|
|
7085
|
+
if ('web' === compilerOptions.target || 'webworker' === compilerOptions.target) throw Error(`${color.dim('[rsbuild:runner]')} Not support run ${color.yellow(compilerOptions.target)} resource in Rsbuild server`);
|
|
7131
7086
|
return new EsmRunner(runnerOptions);
|
|
7132
7087
|
}
|
|
7133
7088
|
}
|
|
@@ -7141,13 +7096,13 @@ let runner_run = async ({ bundlePath, ...runnerFactoryOptions })=>{
|
|
|
7141
7096
|
entrypoints: !0,
|
|
7142
7097
|
outputPath: !0
|
|
7143
7098
|
});
|
|
7144
|
-
if (!entrypoints?.[entryName]) throw Error(`${
|
|
7099
|
+
if (!entrypoints?.[entryName]) throw Error(`${color.dim('[rsbuild:loadBundle]')} Can't find entry: ${color.yellow(entryName)}`);
|
|
7145
7100
|
let { chunks: entryChunks = [] } = entrypoints[entryName], files = entryChunks.reduce((prev, entryChunkName)=>{
|
|
7146
7101
|
let chunk = chunks?.find((chunk)=>chunk.entry && chunk.names?.includes(String(entryChunkName)));
|
|
7147
7102
|
return chunk?.files ? prev.concat(chunk.files.filter((file)=>!file.endsWith('.css'))) : prev;
|
|
7148
7103
|
}, []);
|
|
7149
|
-
if (0 === files.length) throw Error(`${
|
|
7150
|
-
if (files.length > 1) throw Error(`${
|
|
7104
|
+
if (0 === files.length) throw Error(`${color.dim('[rsbuild:loadBundle]')} Failed to get bundle by entryName: ${color.yellow(entryName)}`);
|
|
7105
|
+
if (files.length > 1) throw Error(`${color.dim('[rsbuild:loadBundle]')} Only support load single entry chunk, but got ${color.yellow(files.length)}: ${files.join(',')}`);
|
|
7151
7106
|
let allChunkFiles = chunks?.flatMap((c)=>c.files).map((file)=>(0, external_node_path_.join)(outputPath, file)) || [];
|
|
7152
7107
|
return await runner_run({
|
|
7153
7108
|
bundlePath: files[0],
|
|
@@ -7182,7 +7137,7 @@ let runner_run = async ({ bundlePath, ...runnerFactoryOptions })=>{
|
|
|
7182
7137
|
}, shutdownRefCount = 0, setupGracefulShutdown = ()=>{
|
|
7183
7138
|
shutdownRefCount++;
|
|
7184
7139
|
let onSigterm = ()=>{
|
|
7185
|
-
handleTermination(
|
|
7140
|
+
handleTermination(external_node_os_.constants.signals.SIGTERM + 128);
|
|
7186
7141
|
};
|
|
7187
7142
|
process.once('SIGTERM', onSigterm);
|
|
7188
7143
|
let isCI = 'true' === process.env.CI, onStdinEnd = ()=>{
|
|
@@ -7292,7 +7247,7 @@ async function devServer_createDevServer(options, createCompiler, config, { getP
|
|
|
7292
7247
|
});
|
|
7293
7248
|
let startCompile = async ()=>{
|
|
7294
7249
|
let compiler = await createCompiler();
|
|
7295
|
-
if (!compiler) throw Error(`${
|
|
7250
|
+
if (!compiler) throw Error(`${color.dim('[rsbuild:server]')} Failed to get compiler instance.`);
|
|
7296
7251
|
let publicPaths = compiler_isMultiCompiler(compiler) ? compiler.compilers.map(getPublicPathFromCompiler) : [
|
|
7297
7252
|
getPublicPathFromCompiler(compiler)
|
|
7298
7253
|
], { base } = config.server;
|
|
@@ -7350,10 +7305,10 @@ async function devServer_createDevServer(options, createCompiler, config, { getP
|
|
|
7350
7305
|
!getPortSilently && portTip && src_logger.info(portTip);
|
|
7351
7306
|
}, cacheableLoadBundle = createCacheableFunction(loadBundle), cacheableTransformedHtml = createCacheableFunction((_stats, entryName, utils)=>((entryName, utils)=>{
|
|
7352
7307
|
let { htmlPaths, distPath } = utils.environment, htmlPath = htmlPaths[entryName];
|
|
7353
|
-
if (!htmlPath) throw Error(`${
|
|
7308
|
+
if (!htmlPath) throw Error(`${color.dim('[rsbuild:getTransformedHtml]')} Failed to get HTML file by entryName: ${color.yellow(entryName)}`);
|
|
7354
7309
|
let fileName = (0, external_node_path_.join)(distPath, htmlPath);
|
|
7355
7310
|
return utils.readFileSync(fileName);
|
|
7356
|
-
})(entryName, utils)), environmentAPI = {}, getErrorMsg = (method)=>`${
|
|
7311
|
+
})(entryName, utils)), environmentAPI = {}, getErrorMsg = (method)=>`${color.dim('[rsbuild:server]')} Can not call ${color.yellow(method)} when ${color.yellow('runCompile')} is false`;
|
|
7357
7312
|
context.environmentList.forEach((environment, index)=>{
|
|
7358
7313
|
environmentAPI[environment.name] = {
|
|
7359
7314
|
context: environment,
|
|
@@ -7377,7 +7332,7 @@ async function devServer_createDevServer(options, createCompiler, config, { getP
|
|
|
7377
7332
|
}
|
|
7378
7333
|
};
|
|
7379
7334
|
});
|
|
7380
|
-
let { default: connect } = await import("./connect.js").then(__webpack_require__.t.bind(__webpack_require__, "../../node_modules/.pnpm/connect@3.7.
|
|
7335
|
+
let { default: connect } = await import("./connect.js").then(__webpack_require__.t.bind(__webpack_require__, "../../node_modules/.pnpm/connect@3.7.0_supports-color@10.2.2/node_modules/connect/index.js", 23)), middlewares = connect(), httpServer = middlewareMode ? null : await createHttpServer({
|
|
7381
7336
|
serverConfig: config.server,
|
|
7382
7337
|
middlewares
|
|
7383
7338
|
}), devServerAPI = {
|
|
@@ -7390,7 +7345,7 @@ async function devServer_createDevServer(options, createCompiler, config, { getP
|
|
|
7390
7345
|
data
|
|
7391
7346
|
}),
|
|
7392
7347
|
listen: async ()=>{
|
|
7393
|
-
if (!httpServer) throw Error(`${
|
|
7348
|
+
if (!httpServer) throw Error(`${color.dim('[rsbuild:server]')} Can not listen dev server as ${color.yellow('server.middlewareMode')} is enabled.`);
|
|
7394
7349
|
let serverTerminator = getServerTerminator(httpServer);
|
|
7395
7350
|
return src_logger.debug('listen dev server'), context.hooks.onCloseDevServer.tap(serverTerminator), new Promise((resolve)=>{
|
|
7396
7351
|
httpServer.listen({
|
|
@@ -7460,7 +7415,7 @@ class RsbuildProdServer {
|
|
|
7460
7415
|
for (let [key, value] of Object.entries(headers))res.setHeader(key, value);
|
|
7461
7416
|
next();
|
|
7462
7417
|
}), proxy) {
|
|
7463
|
-
let { middlewares, upgrade } = createProxyMiddleware(proxy);
|
|
7418
|
+
let { middlewares, upgrade } = await createProxyMiddleware(proxy);
|
|
7464
7419
|
for (let middleware of middlewares)this.middlewares.use(middleware);
|
|
7465
7420
|
this.app.on('upgrade', upgrade);
|
|
7466
7421
|
}
|
|
@@ -7498,7 +7453,7 @@ class RsbuildProdServer {
|
|
|
7498
7453
|
async function startProdServer(context, config, { getPortSilently } = {}) {
|
|
7499
7454
|
let { port, host, https, portTip } = await getServerConfig({
|
|
7500
7455
|
config
|
|
7501
|
-
}), { default: connect } = await import("./connect.js").then(__webpack_require__.t.bind(__webpack_require__, "../../node_modules/.pnpm/connect@3.7.
|
|
7456
|
+
}), { default: connect } = await import("./connect.js").then(__webpack_require__.t.bind(__webpack_require__, "../../node_modules/.pnpm/connect@3.7.0_supports-color@10.2.2/node_modules/connect/index.js", 23)), middlewares = connect(), serverConfig = config.server, server = new RsbuildProdServer({
|
|
7502
7457
|
pwd: context.rootPath,
|
|
7503
7458
|
output: {
|
|
7504
7459
|
path: context.distPath,
|
|
@@ -7573,7 +7528,7 @@ function applyDefaultPlugins(pluginManager, context) {
|
|
|
7573
7528
|
{
|
|
7574
7529
|
name: 'rsbuild:basic',
|
|
7575
7530
|
setup (api) {
|
|
7576
|
-
api.modifyBundlerChain((chain, { isDev, target,
|
|
7531
|
+
api.modifyBundlerChain((chain, { isDev, target, rspack, environment, CHAIN_ID })=>{
|
|
7577
7532
|
let { config } = environment;
|
|
7578
7533
|
chain.name(environment.name), chain.context(api.context.rootPath), chain.mode(environment.config.mode), chain.infrastructureLogging({
|
|
7579
7534
|
level: 'error'
|
|
@@ -7583,7 +7538,7 @@ function applyDefaultPlugins(pluginManager, context) {
|
|
|
7583
7538
|
javascript: {
|
|
7584
7539
|
exportsPresence: 'error'
|
|
7585
7540
|
}
|
|
7586
|
-
}), isDev && config.dev.hmr && 'web' === target && chain.plugin(CHAIN_ID.PLUGIN.HMR).use(
|
|
7541
|
+
}), isDev && config.dev.hmr && 'web' === target && chain.plugin(CHAIN_ID.PLUGIN.HMR).use(rspack.HotModuleReplacementPlugin), chain.module.parser.merge({
|
|
7587
7542
|
javascript: {
|
|
7588
7543
|
typeReexportsPresence: 'tolerant'
|
|
7589
7544
|
}
|
|
@@ -7613,7 +7568,7 @@ function applyDefaultPlugins(pluginManager, context) {
|
|
|
7613
7568
|
if (bundlerConfigs.some(({ plugins })=>plugins?.some(isModuleFederationPlugin))) return void bundlerConfigs.forEach((config)=>{
|
|
7614
7569
|
config.entry = {};
|
|
7615
7570
|
});
|
|
7616
|
-
throw Error(`${
|
|
7571
|
+
throw Error(`${color.dim('[rsbuild:config]')} Could not find any entry module, please make sure that ${color.yellow('src/index.(ts|js|tsx|jsx|mts|cts|mjs|cjs)')} exists, or customize entry through the ${color.yellow('source.entry')} configuration.`);
|
|
7617
7572
|
}
|
|
7618
7573
|
});
|
|
7619
7574
|
}
|
|
@@ -7621,7 +7576,7 @@ function applyDefaultPlugins(pluginManager, context) {
|
|
|
7621
7576
|
{
|
|
7622
7577
|
name: 'rsbuild:source-map',
|
|
7623
7578
|
setup (api) {
|
|
7624
|
-
api.modifyBundlerChain((chain, {
|
|
7579
|
+
api.modifyBundlerChain((chain, { rspack, environment, isDev, target })=>{
|
|
7625
7580
|
let { config } = environment, devtool = ((config)=>{
|
|
7626
7581
|
let { sourceMap } = config.output, isProd = 'production' === config.mode;
|
|
7627
7582
|
return !1 !== sourceMap && (!0 === sourceMap ? isProd ? 'source-map' : 'cheap-module-source-map' : void 0 === sourceMap.js ? !isProd && 'cheap-module-source-map' : sourceMap.js);
|
|
@@ -7629,7 +7584,7 @@ function applyDefaultPlugins(pluginManager, context) {
|
|
|
7629
7584
|
chain.devtool(devtool), isDev && 'web' === target ? chain.output.devtoolModuleFilenameTemplate((info)=>toPosixPath(info.absoluteResourcePath)) : chain.output.devtoolModuleFilenameTemplate('[relative-resource-path]'), !devtool && ((config)=>{
|
|
7630
7585
|
let { sourceMap } = config.output;
|
|
7631
7586
|
return 'object' == typeof sourceMap && sourceMap.css;
|
|
7632
|
-
})(config) && chain.plugin('source-map-css').use(
|
|
7587
|
+
})(config) && chain.plugin('source-map-css').use(rspack.SourceMapDevToolPlugin, [
|
|
7633
7588
|
{
|
|
7634
7589
|
test: /\.css$/,
|
|
7635
7590
|
filename: '[file].map[query]'
|
|
@@ -7793,7 +7748,7 @@ function applyDefaultPlugins(pluginManager, context) {
|
|
|
7793
7748
|
return 'auto' === enable ? isDev && !config.dev.writeToDisk ? void 0 : isStrictSubdir(rootPath, distPath) ? {
|
|
7794
7749
|
path: distPath,
|
|
7795
7750
|
keep
|
|
7796
|
-
} : (src_logger.warn('The dist path is not a subdir of root path, Rsbuild will not empty it.'), src_logger.warn(`Please set ${
|
|
7751
|
+
} : (src_logger.warn('The dist path is not a subdir of root path, Rsbuild will not empty it.'), src_logger.warn(`Please set ${color.yellow('`output.cleanDistPath`')} config manually.`), src_logger.warn(`Current root path: ${color.dim(rootPath)}`), void src_logger.warn(`Current dist path: ${color.dim(distPath)}`)) : !0 === enable ? {
|
|
7797
7752
|
path: distPath,
|
|
7798
7753
|
keep
|
|
7799
7754
|
} : void 0;
|
|
@@ -7992,16 +7947,16 @@ function applyDefaultPlugins(pluginManager, context) {
|
|
|
7992
7947
|
})(icon, distDir, publicPath, lookup)), tags = [];
|
|
7993
7948
|
for (let icon of icons){
|
|
7994
7949
|
if ('web-app-manifest' === icon.target && !appIcon.name) {
|
|
7995
|
-
addCompilationError(compilation, `${
|
|
7950
|
+
addCompilationError(compilation, `${color.dim('[rsbuild:app-icon]')} ${color.yellow('"appIcon.name"')} is required when ${color.yellow('"target"')} is ${color.yellow('"web-app-manifest"')}.`);
|
|
7996
7951
|
continue;
|
|
7997
7952
|
}
|
|
7998
7953
|
if (!icon.isURL) {
|
|
7999
7954
|
if (!compilation.inputFileSystem) {
|
|
8000
|
-
addCompilationError(compilation, `${
|
|
7955
|
+
addCompilationError(compilation, `${color.dim('[rsbuild:app-icon]')} Failed to read the icon file as ${color.yellow('"compilation.inputFileSystem"')} is not available.`);
|
|
8001
7956
|
continue;
|
|
8002
7957
|
}
|
|
8003
7958
|
if (!await fileExistsByCompilation(compilation, icon.absolutePath)) {
|
|
8004
|
-
addCompilationError(compilation, `${
|
|
7959
|
+
addCompilationError(compilation, `${color.dim('[rsbuild:app-icon]')} Failed to find the icon file at ${color.yellow(icon.absolutePath)}.`);
|
|
8005
7960
|
continue;
|
|
8006
7961
|
}
|
|
8007
7962
|
let source = await readFileAsync(compilation.inputFileSystem, icon.absolutePath);
|
|
@@ -8078,7 +8033,7 @@ function applyDefaultPlugins(pluginManager, context) {
|
|
|
8078
8033
|
raw: !0
|
|
8079
8034
|
}, ({ code, emitFile, resourcePath })=>{
|
|
8080
8035
|
let name, filename = (name = resourcePath && external_node_path_.default.parse(resourcePath).name) ? `${name}.node` : null;
|
|
8081
|
-
if (null === filename) throw Error(`${
|
|
8036
|
+
if (null === filename) throw Error(`${color.dim('[rsbuild:node-addons]')} Failed to load Node.js addon: ${color.yellow(resourcePath)}`);
|
|
8082
8037
|
emitFile(filename, code);
|
|
8083
8038
|
let config = api.getNormalizedConfig(), handleErrorSnippet = `throw new Error('Failed to load Node.js addon: "${filename}"', {
|
|
8084
8039
|
cause: error,
|
|
@@ -8114,7 +8069,7 @@ try {
|
|
|
8114
8069
|
{
|
|
8115
8070
|
name: 'rsbuild:define',
|
|
8116
8071
|
setup (api) {
|
|
8117
|
-
api.modifyBundlerChain((chain, { CHAIN_ID,
|
|
8072
|
+
api.modifyBundlerChain((chain, { CHAIN_ID, rspack, environment })=>{
|
|
8118
8073
|
let { config } = environment, baseUrl = JSON.stringify(config.server.base), assetPrefix = JSON.stringify(getPublicPathFromChain(chain, !1)), mergedDefine = {
|
|
8119
8074
|
...{
|
|
8120
8075
|
'import.meta.env': {
|
|
@@ -8129,7 +8084,7 @@ try {
|
|
|
8129
8084
|
},
|
|
8130
8085
|
...config.source.define
|
|
8131
8086
|
};
|
|
8132
|
-
checkProcessEnvSecurity(mergedDefine), chain.plugin(CHAIN_ID.PLUGIN.DEFINE).use(
|
|
8087
|
+
checkProcessEnvSecurity(mergedDefine), chain.plugin(CHAIN_ID.PLUGIN.DEFINE).use(rspack.DefinePlugin, [
|
|
8133
8088
|
mergedDefine
|
|
8134
8089
|
]);
|
|
8135
8090
|
});
|
|
@@ -8365,10 +8320,7 @@ try {
|
|
|
8365
8320
|
...chain.output.get('library'),
|
|
8366
8321
|
type: 'module'
|
|
8367
8322
|
}), 'web-worker' === target) throw Error('[rsbuild:config] `output.module` is not supported for web-worker target.');
|
|
8368
|
-
chain.node.set('__dirname', !1).set('__filename', !1), chain.output.module(!0).chunkFormat('module').chunkLoading('import').workerChunkLoading('import')
|
|
8369
|
-
...chain.get('experiments'),
|
|
8370
|
-
outputModule: !0
|
|
8371
|
-
});
|
|
8323
|
+
chain.node.set('__dirname', !1).set('__filename', !1), chain.output.module(!0).chunkFormat('module').chunkLoading('import').workerChunkLoading('import');
|
|
8372
8324
|
}
|
|
8373
8325
|
});
|
|
8374
8326
|
}
|
|
@@ -8501,19 +8453,19 @@ try {
|
|
|
8501
8453
|
]
|
|
8502
8454
|
});
|
|
8503
8455
|
} catch {
|
|
8504
|
-
src_logger.warn(`\`process.env.RSDOCTOR\` enabled, please install ${
|
|
8456
|
+
src_logger.warn(`\`process.env.RSDOCTOR\` enabled, please install ${color.bold(color.yellow(packageName))} package.`);
|
|
8505
8457
|
return;
|
|
8506
8458
|
}
|
|
8507
8459
|
try {
|
|
8508
8460
|
let moduleURL = isWindows ? (0, external_node_url_.pathToFileURL)(packagePath).href : packagePath;
|
|
8509
8461
|
module = await import(moduleURL);
|
|
8510
8462
|
} catch {
|
|
8511
|
-
src_logger.error(`\`process.env.RSDOCTOR\` enabled, but failed to load ${
|
|
8463
|
+
src_logger.error(`\`process.env.RSDOCTOR\` enabled, but failed to load ${color.bold(color.yellow(packageName))} module.`);
|
|
8512
8464
|
return;
|
|
8513
8465
|
}
|
|
8514
8466
|
if (module && module[pluginName]) {
|
|
8515
8467
|
for (let config of bundlerConfigs)config.plugins ||= [], config.plugins.push(new module[pluginName]());
|
|
8516
|
-
src_logger.info(`${
|
|
8468
|
+
src_logger.info(`${color.bold(color.yellow(packageName))} enabled.`);
|
|
8517
8469
|
}
|
|
8518
8470
|
});
|
|
8519
8471
|
}
|
|
@@ -8624,7 +8576,7 @@ try {
|
|
|
8624
8576
|
});
|
|
8625
8577
|
}));
|
|
8626
8578
|
} catch (err) {
|
|
8627
|
-
throw err instanceof Error && (err.message = `Failed to copy public directory '${
|
|
8579
|
+
throw err instanceof Error && (err.message = `Failed to copy public directory '${color.yellow(publicDir)}' to output directory. To disable public directory copying, set \`${color.cyan('server.publicDir: false')}\` in your config.\n${err.message}`), err;
|
|
8628
8580
|
}
|
|
8629
8581
|
}
|
|
8630
8582
|
});
|
|
@@ -8637,7 +8589,7 @@ try {
|
|
|
8637
8589
|
api.modifyBundlerChain(async (chain, { CHAIN_ID, environment, isDev })=>{
|
|
8638
8590
|
let { output: { manifest }, dev: { writeToDisk } } = environment.config;
|
|
8639
8591
|
if (!1 === manifest) return;
|
|
8640
|
-
let manifestOptions = normalizeManifestObjectConfig(manifest), { RspackManifestPlugin } = await import("./manifest-plugin.js").then(__webpack_require__.bind(__webpack_require__, "../../node_modules/.pnpm/rspack-manifest-plugin@5.2.1_@rspack+core@2.0.0-
|
|
8592
|
+
let manifestOptions = normalizeManifestObjectConfig(manifest), { RspackManifestPlugin } = await import("./manifest-plugin.js").then(__webpack_require__.bind(__webpack_require__, "../../node_modules/.pnpm/rspack-manifest-plugin@5.2.1_@rspack+core@2.0.0-beta.0_@module-federation+runtime-tools@0.24.0_@swc+helpers@0.5.18_/node_modules/rspack-manifest-plugin/dist/index.js")), { htmlPaths } = environment, filter = manifestOptions.filter ?? ((file)=>!file.name.endsWith('.LICENSE.txt'));
|
|
8641
8593
|
manifestFilenames.set(environment.name, manifestOptions.filename);
|
|
8642
8594
|
let pluginOptions = {
|
|
8643
8595
|
fileName: manifestOptions.filename,
|
|
@@ -8694,7 +8646,7 @@ try {
|
|
|
8694
8646
|
manifestData
|
|
8695
8647
|
});
|
|
8696
8648
|
if (isObject(generatedManifest)) return environment.manifest = generatedManifest, generatedManifest;
|
|
8697
|
-
throw Error(`${
|
|
8649
|
+
throw Error(`${color.dim('[rsbuild:manifest]')} \`manifest.generate\` function must return a valid manifest object.`);
|
|
8698
8650
|
}
|
|
8699
8651
|
return environment.manifest = manifestData, manifestData;
|
|
8700
8652
|
}
|
|
@@ -8705,7 +8657,7 @@ try {
|
|
|
8705
8657
|
}), api.onAfterCreateCompiler(()=>{
|
|
8706
8658
|
if (manifestFilenames.size <= 1) return void manifestFilenames.clear();
|
|
8707
8659
|
let environmentNames = Array.from(manifestFilenames.keys()), filenames = Array.from(manifestFilenames.values());
|
|
8708
|
-
new Set(filenames).size !== filenames.length && src_logger.warn(`${
|
|
8660
|
+
new Set(filenames).size !== filenames.length && src_logger.warn(`${color.dim('[rsbuild:manifest]')} The ${color.yellow('"manifest.filename"')} option must be unique when there are multiple environments (${environmentNames.join(', ')}), otherwise the manifest file will be overwritten.`), manifestFilenames.clear();
|
|
8709
8661
|
});
|
|
8710
8662
|
}
|
|
8711
8663
|
},
|
|
@@ -8721,7 +8673,7 @@ try {
|
|
|
8721
8673
|
api.onBeforeBuild(async ({ isFirstCompile })=>{
|
|
8722
8674
|
isFirstCompile && await onStart();
|
|
8723
8675
|
}), api.onBeforeStartDevServer(onStart), api.onExit(()=>{
|
|
8724
|
-
traceOutput && (core_rspack.experiments.globalTrace.cleanup(), src_logger.info(`profile file saved to ${
|
|
8676
|
+
traceOutput && (core_rspack.experiments.globalTrace.cleanup(), src_logger.info(`profile file saved to ${color.cyan(traceOutput)}`));
|
|
8725
8677
|
});
|
|
8726
8678
|
}
|
|
8727
8679
|
},
|
|
@@ -8750,19 +8702,16 @@ try {
|
|
|
8750
8702
|
name: 'rsbuild:sri',
|
|
8751
8703
|
setup (api) {
|
|
8752
8704
|
api.modifyBundlerChain((chain, { environment, CHAIN_ID, rspack })=>{
|
|
8753
|
-
let { config,
|
|
8754
|
-
if (0 === Object.keys(htmlPaths).length) return;
|
|
8755
|
-
let { sri } = config.security;
|
|
8705
|
+
let { config } = environment, { sri } = config.security;
|
|
8756
8706
|
if (!('auto' === sri.enable ? 'production' === config.mode : sri.enable)) return;
|
|
8757
8707
|
let crossorigin = chain.output.get('crossOriginLoading');
|
|
8758
8708
|
(!1 === crossorigin || void 0 === crossorigin) && chain.output.crossOriginLoading('anonymous');
|
|
8759
|
-
let { algorithm = 'sha384' } = sri
|
|
8760
|
-
|
|
8761
|
-
|
|
8762
|
-
|
|
8763
|
-
|
|
8764
|
-
|
|
8765
|
-
}
|
|
8709
|
+
let { algorithm = 'sha384' } = sri, pluginOptions = {
|
|
8710
|
+
enabled: !0,
|
|
8711
|
+
hashFuncNames: helpers_castArray(algorithm)
|
|
8712
|
+
};
|
|
8713
|
+
'js' === config.html.implementation && !1 !== config.tools.htmlPlugin && (pluginOptions.htmlPlugin = external_node_path_.default.join(COMPILED_PATH, 'html-rspack-plugin/index.js')), chain.plugin(CHAIN_ID.PLUGIN.SUBRESOURCE_INTEGRITY).use(rspack.SubresourceIntegrityPlugin, [
|
|
8714
|
+
pluginOptions
|
|
8766
8715
|
]);
|
|
8767
8716
|
});
|
|
8768
8717
|
}
|
|
@@ -8872,8 +8821,8 @@ async function createRsbuild(options = {}) {
|
|
|
8872
8821
|
pluginManager
|
|
8873
8822
|
}), { distPath } = context, { checkDistDir = !0 } = options;
|
|
8874
8823
|
if (checkDistDir) {
|
|
8875
|
-
if (!(0, external_node_fs_.existsSync)(distPath)) throw Error(`${
|
|
8876
|
-
if (isEmptyDir(distPath)) throw Error(`${
|
|
8824
|
+
if (!(0, external_node_fs_.existsSync)(distPath)) throw Error(`${color.dim('[rsbuild:preview]')} The output directory ${color.yellow(distPath)} does not exist, please build the project before previewing.`);
|
|
8825
|
+
if (isEmptyDir(distPath)) throw Error(`${color.dim('[rsbuild:preview]')} The output directory ${color.yellow(distPath)} is empty, please build the project before previewing.`);
|
|
8877
8826
|
}
|
|
8878
8827
|
return startProdServer(context, config, options);
|
|
8879
8828
|
},
|
|
@@ -8977,7 +8926,7 @@ async function loadConfig_loadConfig({ cwd = process.cwd(), path, envMode, meta,
|
|
|
8977
8926
|
if (customConfig) {
|
|
8978
8927
|
let customConfigPath = (0, external_node_path_.isAbsolute)(customConfig) ? customConfig : (0, external_node_path_.join)(root, customConfig);
|
|
8979
8928
|
if (external_node_fs_.default.existsSync(customConfigPath)) return customConfigPath;
|
|
8980
|
-
throw Error(`${
|
|
8929
|
+
throw Error(`${color.dim('[rsbuild:loadConfig]')} Cannot find config file: ${color.dim(customConfigPath)}`);
|
|
8981
8930
|
}
|
|
8982
8931
|
for (let file of [
|
|
8983
8932
|
'rsbuild.config.mjs',
|
|
@@ -9003,7 +8952,7 @@ async function loadConfig_loadConfig({ cwd = process.cwd(), path, envMode, meta,
|
|
|
9003
8952
|
let configFileURL = (0, external_node_url_.pathToFileURL)(configFilePath).href, exportModule = await import(`${configFileURL}?t=${Date.now()}`);
|
|
9004
8953
|
configExport = exportModule.default ? exportModule.default : exportModule;
|
|
9005
8954
|
} catch (err) {
|
|
9006
|
-
let errorMessage = `Failed to load file with native loader: ${
|
|
8955
|
+
let errorMessage = `Failed to load file with native loader: ${color.dim(configFilePath)}`;
|
|
9007
8956
|
if ('native' === loader) throw src_logger.error(errorMessage), err;
|
|
9008
8957
|
src_logger.debug(`${errorMessage}, fallback to jiti.`), src_logger.debug(err);
|
|
9009
8958
|
}
|
|
@@ -9019,7 +8968,7 @@ async function loadConfig_loadConfig({ cwd = process.cwd(), path, envMode, meta,
|
|
|
9019
8968
|
default: !0
|
|
9020
8969
|
});
|
|
9021
8970
|
} catch (err) {
|
|
9022
|
-
throw src_logger.error(`Failed to load file with jiti: ${
|
|
8971
|
+
throw src_logger.error(`Failed to load file with jiti: ${color.dim(configFilePath)}`), err;
|
|
9023
8972
|
}
|
|
9024
8973
|
if ('function' == typeof configExport) {
|
|
9025
8974
|
let command = process.argv[2], nodeEnv = process.env.NODE_ENV || '', result = await configExport({
|
|
@@ -9028,13 +8977,13 @@ async function loadConfig_loadConfig({ cwd = process.cwd(), path, envMode, meta,
|
|
|
9028
8977
|
envMode: envMode || nodeEnv,
|
|
9029
8978
|
meta
|
|
9030
8979
|
});
|
|
9031
|
-
if (void 0 === result) throw Error(`${
|
|
8980
|
+
if (void 0 === result) throw Error(`${color.dim('[rsbuild:loadConfig]')} The config function must return a config object.`);
|
|
9032
8981
|
return {
|
|
9033
8982
|
content: applyMetaInfo(result),
|
|
9034
8983
|
filePath: configFilePath
|
|
9035
8984
|
};
|
|
9036
8985
|
}
|
|
9037
|
-
if (!isObject(configExport)) throw Error(`${
|
|
8986
|
+
if (!isObject(configExport)) throw Error(`${color.dim('[rsbuild:loadConfig]')} The config must be an object or a function that returns an object, get ${color.yellow(configExport)}`);
|
|
9038
8987
|
return src_logger.debug('configuration loaded from:', configFilePath), {
|
|
9039
8988
|
content: applyMetaInfo(configExport),
|
|
9040
8989
|
filePath: configFilePath
|
|
@@ -9097,7 +9046,7 @@ let cleaners = [], onBeforeRestartServer = (cleaner)=>{
|
|
|
9097
9046
|
}, beforeRestart = async ({ filePath, clear = !0, id })=>{
|
|
9098
9047
|
if (clear && isTTY() && !process.env.DEBUG && process.stdout.write('\x1B[H\x1B[2J'), filePath) {
|
|
9099
9048
|
let filename = external_node_path_.default.basename(filePath);
|
|
9100
|
-
src_logger.info(`restarting ${id} as ${
|
|
9049
|
+
src_logger.info(`restarting ${id} as ${color.yellow(filename)} changed\n`);
|
|
9101
9050
|
} else src_logger.info(`restarting ${id}...\n`);
|
|
9102
9051
|
for (let cleaner of cleaners)await cleaner();
|
|
9103
9052
|
cleaners = [];
|
|
@@ -9145,7 +9094,7 @@ let applyServerOptions = (command)=>{
|
|
|
9145
9094
|
};
|
|
9146
9095
|
function setupCommands() {
|
|
9147
9096
|
let cli = ((name = "")=>new CAC(name))('rsbuild');
|
|
9148
|
-
cli.version("2.0.0-beta.
|
|
9097
|
+
cli.version("2.0.0-beta.3"), cli.option('--base <base>', 'Set the base path of the server').option('-c, --config <config>', 'Set the configuration file (relative or absolute path)').option('--config-loader <loader>', 'Set the config file loader (auto | jiti | native)', {
|
|
9149
9098
|
default: 'auto'
|
|
9150
9099
|
}).option('--env-dir <dir>', 'Set the directory for loading `.env` files').option('--env-mode <mode>', 'Set the env mode to load the `.env.[mode]` file').option('--environment <name>', 'Set the environment name(s) to build', {
|
|
9151
9100
|
type: [
|
|
@@ -9153,7 +9102,7 @@ function setupCommands() {
|
|
|
9153
9102
|
],
|
|
9154
9103
|
default: []
|
|
9155
9104
|
}).option('--log-level <level>', 'Set the log level (info | warn | error | silent)').option('-m, --mode <mode>', 'Set the build mode (development | production | none)').option('-r, --root <root>', 'Set the project root directory (absolute path or relative to cwd)').option('--no-env', 'Disable loading of `.env` files');
|
|
9156
|
-
let devDescription = `Start the dev server ${
|
|
9105
|
+
let devDescription = `Start the dev server ${color.dim('(default if no command is given)')}`, devCommand = cli.command('', devDescription).alias('dev'), buildCommand = cli.command('build', 'Build the app for production'), previewCommand = cli.command('preview', 'Preview the production build locally'), inspectCommand = cli.command('inspect', 'Inspect the Rspack and Rsbuild configs');
|
|
9157
9106
|
applyServerOptions(devCommand), applyServerOptions(previewCommand), devCommand.action(async (options)=>{
|
|
9158
9107
|
try {
|
|
9159
9108
|
let rsbuild = await init_init({
|
|
@@ -9199,7 +9148,7 @@ function setupCommands() {
|
|
|
9199
9148
|
src_logger.error('Failed to inspect config.'), src_logger.error(err), process.exit(1);
|
|
9200
9149
|
}
|
|
9201
9150
|
}), cli.help((sections)=>{
|
|
9202
|
-
for (let section of (sections.shift(), sections))'Usage' === section.title && (section.body = section.body.replace('$ rsbuild',
|
|
9151
|
+
for (let section of (sections.shift(), sections))'Usage' === section.title && (section.body = section.body.replace('$ rsbuild', color.yellow("$ rsbuild [command] [options]"))), 'Commands' === section.title && (section.body = section.body.replace(` ${devDescription}`, `dev ${devDescription}`)), section.title?.startsWith('For more info') ? (section.title = color.dim(' For details on a sub-command, run'), section.body = color.dim(' $ rsbuild <command> -h')) : section.title && (section.title = color.cyan(section.title));
|
|
9203
9152
|
}), cli.parse();
|
|
9204
9153
|
}
|
|
9205
9154
|
let { argv: cli_argv } = process;
|
|
@@ -9214,7 +9163,7 @@ function initNodeEnv() {
|
|
|
9214
9163
|
}
|
|
9215
9164
|
function showGreeting() {
|
|
9216
9165
|
let { npm_execpath, npm_lifecycle_event, NODE_RUN_SCRIPT_NAME } = process.env, isBun = npm_execpath?.includes('.bun');
|
|
9217
|
-
src_logger.greet(`${'npx' === npm_lifecycle_event || isBun || NODE_RUN_SCRIPT_NAME ? '\n' : ''}Rsbuild v2.0.0-beta.
|
|
9166
|
+
src_logger.greet(`${'npx' === npm_lifecycle_event || isBun || NODE_RUN_SCRIPT_NAME ? '\n' : ''}Rsbuild v2.0.0-beta.3\n`);
|
|
9218
9167
|
}
|
|
9219
9168
|
function setupLogLevel() {
|
|
9220
9169
|
let logLevelIndex = process.argv.findIndex((item)=>'--log-level' === item || '--logLevel' === item);
|
|
@@ -9235,5 +9184,5 @@ function runCLI() {
|
|
|
9235
9184
|
src_logger.error('Failed to start Rsbuild CLI.'), src_logger.error(err), process.exit(1);
|
|
9236
9185
|
}
|
|
9237
9186
|
}
|
|
9238
|
-
let src_version = "2.0.0-beta.
|
|
9239
|
-
export { PLUGIN_CSS_NAME, PLUGIN_SWC_NAME, core_rspack as rspack, createRsbuild, defaultAllowedOrigins, defineConfig, ensureAssetPrefix,
|
|
9187
|
+
let src_version = "2.0.0-beta.3";
|
|
9188
|
+
export { PLUGIN_CSS_NAME, PLUGIN_SWC_NAME, core_rspack as rspack, createRsbuild, defaultAllowedOrigins, defineConfig, ensureAssetPrefix, external_node_util_promisify, loadConfig_loadConfig as loadConfig, loadEnv, mergeRsbuildConfig, runCLI, src_logger as logger, src_version as version };
|