@rsbuild/core 1.7.0-beta.0 → 1.7.0-beta.2
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 +18 -20
- package/compiled/html-rspack-plugin/index.js +14 -14
- package/compiled/postcss-loader/index.js +6 -6
- package/compiled/rspack-manifest-plugin/index.js +4 -4
- package/compiled/sirv/index.js +5 -450
- package/compiled/style-loader/index.js +10 -10
- package/dist/131.js +397 -351
- package/dist/2~open.cjs +1 -1
- package/dist/2~range-parser.cjs +1 -1
- package/dist/client/hmr.js +18 -4
- package/dist/client/overlay.js +138 -4
- package/dist/ignoreCssLoader.mjs +1 -1
- package/dist/index.cjs +403 -352
- package/dist/rslib-runtime.js +1 -1
- package/dist/transformRawLoader.mjs +1 -1
- package/dist-types/client/hmr.d.ts +2 -10
- package/dist-types/constants.d.ts +1 -0
- package/dist-types/helpers/index.d.ts +1 -0
- package/dist-types/helpers/vendors.d.ts +0 -1
- package/dist-types/logger.d.ts +1 -2
- package/dist-types/server/browserLogs.d.ts +4 -2
- package/dist-types/server/devServer.d.ts +2 -1
- package/dist-types/server/overlay.d.ts +1 -1
- package/dist-types/server/socketServer.d.ts +9 -1
- package/dist-types/types/config.d.ts +7 -1
- package/dist-types/types/context.d.ts +1 -1
- package/package.json +4 -4
- package/compiled/rslog/index.js +0 -300
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*! For license information please see index.cjs.LICENSE.txt */
|
|
2
|
-
const __rslib_import_meta_url__ =
|
|
2
|
+
const __rslib_import_meta_url__ = "u" < typeof document ? new (require('url'.replace('', ''))).URL('file:' + __filename).href : document.currentScript && document.currentScript.src || new URL('main.js', document.baseURI).href;
|
|
3
3
|
var __webpack_modules__ = {
|
|
4
4
|
"../../node_modules/.pnpm/deepmerge@4.3.1/node_modules/deepmerge/dist/cjs.js" (module) {
|
|
5
5
|
"use strict";
|
|
@@ -1002,7 +1002,7 @@ __webpack_require__.m = __webpack_modules__, __webpack_require__.n = (module)=>{
|
|
|
1002
1002
|
603: "range-parser",
|
|
1003
1003
|
664: "open"
|
|
1004
1004
|
})[chunkId] + ".cjs", __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop), __webpack_require__.r = (exports1)=>{
|
|
1005
|
-
|
|
1005
|
+
"u" > typeof Symbol && Symbol.toStringTag && Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
1006
1006
|
value: 'Module'
|
|
1007
1007
|
}), Object.defineProperty(exports1, '__esModule', {
|
|
1008
1008
|
value: !0
|
|
@@ -1023,13 +1023,13 @@ __webpack_require__.m = __webpack_modules__, __webpack_require__.n = (module)=>{
|
|
|
1023
1023
|
var __webpack_exports__ = {};
|
|
1024
1024
|
for(var __rspack_i in (()=>{
|
|
1025
1025
|
"use strict";
|
|
1026
|
-
let swcHelpersPath, pluginHelper_htmlPlugin, cssExtractPlugin;
|
|
1026
|
+
let flagForceColor, swcHelpersPath, pluginHelper_htmlPlugin, cssExtractPlugin;
|
|
1027
1027
|
__webpack_require__.r(__webpack_exports__), __webpack_require__.d(__webpack_exports__, {
|
|
1028
1028
|
PLUGIN_SWC_NAME: ()=>PLUGIN_SWC_NAME,
|
|
1029
1029
|
ensureAssetPrefix: ()=>ensureAssetPrefix,
|
|
1030
1030
|
loadConfig: ()=>loadConfig_loadConfig,
|
|
1031
1031
|
createRsbuild: ()=>createRsbuild,
|
|
1032
|
-
logger: ()=>
|
|
1032
|
+
logger: ()=>src_logger,
|
|
1033
1033
|
version: ()=>src_version,
|
|
1034
1034
|
loadEnv: ()=>loadEnv,
|
|
1035
1035
|
PLUGIN_CSS_NAME: ()=>PLUGIN_CSS_NAME,
|
|
@@ -1058,8 +1058,185 @@ for(var __rspack_i in (()=>{
|
|
|
1058
1058
|
});
|
|
1059
1059
|
var external_node_module_ = __webpack_require__("node:module");
|
|
1060
1060
|
let rspack_rspack = (0, external_node_module_.createRequire)(__rslib_import_meta_url__)('@rspack/core');
|
|
1061
|
+
var external_node_process_ = __webpack_require__("node:process"), external_node_process_default = __webpack_require__.n(external_node_process_), external_node_os_ = __webpack_require__("node:os"), external_node_os_default = __webpack_require__.n(external_node_os_);
|
|
1062
|
+
let external_node_tty_namespaceObject = require("node:tty");
|
|
1063
|
+
function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : external_node_process_.argv) {
|
|
1064
|
+
let prefix = flag.startsWith('-') ? '' : 1 === flag.length ? '-' : '--', position = argv.indexOf(prefix + flag), terminatorPosition = argv.indexOf('--');
|
|
1065
|
+
return -1 !== position && (-1 === terminatorPosition || position < terminatorPosition);
|
|
1066
|
+
}
|
|
1067
|
+
let { env: dist_env } = external_node_process_;
|
|
1068
|
+
function envForceColor() {
|
|
1069
|
+
if (!('FORCE_COLOR' in dist_env)) return;
|
|
1070
|
+
if ('true' === dist_env.FORCE_COLOR) return 1;
|
|
1071
|
+
if ('false' === dist_env.FORCE_COLOR) return 0;
|
|
1072
|
+
if (0 === dist_env.FORCE_COLOR.length) return 1;
|
|
1073
|
+
let level = Math.min(Number.parseInt(dist_env.FORCE_COLOR, 10), 3);
|
|
1074
|
+
if ([
|
|
1075
|
+
0,
|
|
1076
|
+
1,
|
|
1077
|
+
2,
|
|
1078
|
+
3
|
|
1079
|
+
].includes(level)) return level;
|
|
1080
|
+
}
|
|
1081
|
+
function translateLevel(level) {
|
|
1082
|
+
return 0 !== level && {
|
|
1083
|
+
level,
|
|
1084
|
+
hasBasic: !0,
|
|
1085
|
+
has256: level >= 2,
|
|
1086
|
+
has16m: level >= 3
|
|
1087
|
+
};
|
|
1088
|
+
}
|
|
1089
|
+
function _supportsColor(haveStream, { streamIsTTY, sniffFlags = !0 } = {}) {
|
|
1090
|
+
let noFlagForceColor = envForceColor();
|
|
1091
|
+
void 0 !== noFlagForceColor && (flagForceColor = noFlagForceColor);
|
|
1092
|
+
let forceColor = sniffFlags ? flagForceColor : noFlagForceColor;
|
|
1093
|
+
if (0 === forceColor) return 0;
|
|
1094
|
+
if (sniffFlags) {
|
|
1095
|
+
if (hasFlag('color=16m') || hasFlag('color=full') || hasFlag('color=truecolor')) return 3;
|
|
1096
|
+
if (hasFlag('color=256')) return 2;
|
|
1097
|
+
}
|
|
1098
|
+
if ('TF_BUILD' in dist_env && 'AGENT_NAME' in dist_env) return 1;
|
|
1099
|
+
if (haveStream && !streamIsTTY && void 0 === forceColor) return 0;
|
|
1100
|
+
let min = forceColor || 0;
|
|
1101
|
+
if ('dumb' === dist_env.TERM) return min;
|
|
1102
|
+
if ('win32' === external_node_process_.platform) {
|
|
1103
|
+
let osRelease = external_node_os_.release().split('.');
|
|
1104
|
+
return Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586 ? Number(osRelease[2]) >= 14931 ? 3 : 2 : 1;
|
|
1105
|
+
}
|
|
1106
|
+
if ('CI' in dist_env) return [
|
|
1107
|
+
'GITHUB_ACTIONS',
|
|
1108
|
+
'GITEA_ACTIONS',
|
|
1109
|
+
'CIRCLECI'
|
|
1110
|
+
].some((key)=>key in dist_env) ? 3 : [
|
|
1111
|
+
'TRAVIS',
|
|
1112
|
+
'APPVEYOR',
|
|
1113
|
+
'GITLAB_CI',
|
|
1114
|
+
'BUILDKITE',
|
|
1115
|
+
'DRONE'
|
|
1116
|
+
].some((sign)=>sign in dist_env) || 'codeship' === dist_env.CI_NAME ? 1 : min;
|
|
1117
|
+
if ('TEAMCITY_VERSION' in dist_env) return +!!/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(dist_env.TEAMCITY_VERSION);
|
|
1118
|
+
if ('truecolor' === dist_env.COLORTERM || 'xterm-kitty' === dist_env.TERM || 'xterm-ghostty' === dist_env.TERM || 'wezterm' === dist_env.TERM) return 3;
|
|
1119
|
+
if ('TERM_PROGRAM' in dist_env) {
|
|
1120
|
+
let version = Number.parseInt((dist_env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
|
|
1121
|
+
switch(dist_env.TERM_PROGRAM){
|
|
1122
|
+
case 'iTerm.app':
|
|
1123
|
+
return version >= 3 ? 3 : 2;
|
|
1124
|
+
case 'Apple_Terminal':
|
|
1125
|
+
return 2;
|
|
1126
|
+
}
|
|
1127
|
+
}
|
|
1128
|
+
return /-256(color)?$/i.test(dist_env.TERM) ? 2 : /^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(dist_env.TERM) || 'COLORTERM' in dist_env ? 1 : min;
|
|
1129
|
+
}
|
|
1130
|
+
function createSupportsColor(stream, options = {}) {
|
|
1131
|
+
return translateLevel(_supportsColor(stream, {
|
|
1132
|
+
streamIsTTY: stream && stream.isTTY,
|
|
1133
|
+
...options
|
|
1134
|
+
}));
|
|
1135
|
+
}
|
|
1136
|
+
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);
|
|
1137
|
+
let supportsColor = {
|
|
1138
|
+
stdout: createSupportsColor({
|
|
1139
|
+
isTTY: external_node_tty_namespaceObject.isatty(1)
|
|
1140
|
+
}),
|
|
1141
|
+
stderr: createSupportsColor({
|
|
1142
|
+
isTTY: external_node_tty_namespaceObject.isatty(2)
|
|
1143
|
+
})
|
|
1144
|
+
}, 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+\)$/, formatter = (open, close, replace = open)=>colorLevel >= 2 ? (input)=>{
|
|
1145
|
+
let string = '' + input, index = string.indexOf(close, open.length);
|
|
1146
|
+
return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
|
|
1147
|
+
} : String, replaceClose = (string, close, replace, index)=>{
|
|
1148
|
+
let start = string.substring(0, index) + replace, end = string.substring(index + close.length), nextIndex = end.indexOf(close);
|
|
1149
|
+
return ~nextIndex ? start + replaceClose(end, close, replace, nextIndex) : start + end;
|
|
1150
|
+
}, 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 = {
|
|
1151
|
+
silent: -1,
|
|
1152
|
+
error: 0,
|
|
1153
|
+
warn: 1,
|
|
1154
|
+
info: 2,
|
|
1155
|
+
log: 2,
|
|
1156
|
+
verbose: 3
|
|
1157
|
+
}, LOG_TYPES = {
|
|
1158
|
+
error: {
|
|
1159
|
+
label: 'error',
|
|
1160
|
+
level: 'error',
|
|
1161
|
+
color: red
|
|
1162
|
+
},
|
|
1163
|
+
warn: {
|
|
1164
|
+
label: 'warn',
|
|
1165
|
+
level: 'warn',
|
|
1166
|
+
color: yellow
|
|
1167
|
+
},
|
|
1168
|
+
info: {
|
|
1169
|
+
label: 'info',
|
|
1170
|
+
level: 'info',
|
|
1171
|
+
color: cyan
|
|
1172
|
+
},
|
|
1173
|
+
start: {
|
|
1174
|
+
label: 'start',
|
|
1175
|
+
level: 'info',
|
|
1176
|
+
color: cyan
|
|
1177
|
+
},
|
|
1178
|
+
ready: {
|
|
1179
|
+
label: 'ready',
|
|
1180
|
+
level: 'info',
|
|
1181
|
+
color: green
|
|
1182
|
+
},
|
|
1183
|
+
success: {
|
|
1184
|
+
label: 'success',
|
|
1185
|
+
level: 'info',
|
|
1186
|
+
color: green
|
|
1187
|
+
},
|
|
1188
|
+
log: {
|
|
1189
|
+
level: 'info'
|
|
1190
|
+
},
|
|
1191
|
+
debug: {
|
|
1192
|
+
label: 'debug',
|
|
1193
|
+
level: 'verbose',
|
|
1194
|
+
color: magenta
|
|
1195
|
+
}
|
|
1196
|
+
}, normalizeErrorMessage = (err)=>{
|
|
1197
|
+
if (err.stack) {
|
|
1198
|
+
let [name, ...rest] = err.stack.split('\n');
|
|
1199
|
+
return name.startsWith('Error: ') && (name = name.slice(7)), `${name}\n${gray(rest.join('\n'))}`;
|
|
1200
|
+
}
|
|
1201
|
+
return err.message;
|
|
1202
|
+
}, src_logger = ((options = {})=>{
|
|
1203
|
+
let maxLevel = options.level || 'info', log = (type, message, ...args)=>{
|
|
1204
|
+
let logType = LOG_TYPES[type], { level } = logType;
|
|
1205
|
+
if (LOG_LEVEL[level] > LOG_LEVEL[maxLevel]) return;
|
|
1206
|
+
if (null == message) return console.log();
|
|
1207
|
+
let label = '', text = '';
|
|
1208
|
+
if ('label' in logType && (label = (logType.label || '').padEnd(7), label = bold(logType.color ? logType.color(label) : label)), message instanceof Error) {
|
|
1209
|
+
text += normalizeErrorMessage(message);
|
|
1210
|
+
let { cause } = message;
|
|
1211
|
+
cause && (text += yellow('\n [cause]: '), text += cause instanceof Error ? normalizeErrorMessage(cause) : String(cause));
|
|
1212
|
+
} else text = 'error' === level && 'string' == typeof message ? message.split('\n').map((line)=>{
|
|
1213
|
+
let message;
|
|
1214
|
+
return (message = line, errorStackRegExp.test(message) || anonymousErrorStackRegExp.test(message) || indexErrorStackRegExp.test(message)) ? gray(line) : line;
|
|
1215
|
+
}).join('\n') : `${message}`;
|
|
1216
|
+
console['error' === level || 'warn' === level ? level : 'log'](label.length ? `${label} ${text}` : text, ...args);
|
|
1217
|
+
}, logger = {
|
|
1218
|
+
greet: (message)=>log('log', ((message)=>{
|
|
1219
|
+
if (colorLevel < 3) return 2 === colorLevel ? bold(cyan(message)) : message;
|
|
1220
|
+
let chars = [
|
|
1221
|
+
...message
|
|
1222
|
+
], steps = chars.filter(isWord).length, r = 189, g = 255, b = 243, rStep = -115 / steps, gStep = -61 / steps, bStep = -89 / steps, output = '';
|
|
1223
|
+
for (let char of chars)isWord(char) && (r += rStep, g += gStep, b += bStep), output += `\x1b[38;2;${Math.round(r)};${Math.round(g)};${Math.round(b)}m${char}\x1b[39m`;
|
|
1224
|
+
return bold(output);
|
|
1225
|
+
})(message))
|
|
1226
|
+
};
|
|
1227
|
+
return Object.keys(LOG_TYPES).forEach((key)=>{
|
|
1228
|
+
logger[key] = (...args)=>log(key, ...args);
|
|
1229
|
+
}), Object.defineProperty(logger, 'level', {
|
|
1230
|
+
get: ()=>maxLevel,
|
|
1231
|
+
set (val) {
|
|
1232
|
+
maxLevel = val;
|
|
1233
|
+
}
|
|
1234
|
+
}), logger.override = (customLogger)=>{
|
|
1235
|
+
Object.assign(logger, customLogger);
|
|
1236
|
+
}, logger;
|
|
1237
|
+
})();
|
|
1061
1238
|
var external_node_path_ = __webpack_require__("node:path"), external_node_path_default = __webpack_require__.n(external_node_path_), external_node_url_ = __webpack_require__("node:url");
|
|
1062
|
-
let constants_filename = (0, external_node_url_.fileURLToPath)(__rslib_import_meta_url__), constants_dirname = (0, external_node_path_.dirname)(constants_filename), isDeno =
|
|
1239
|
+
let constants_filename = (0, external_node_url_.fileURLToPath)(__rslib_import_meta_url__), constants_dirname = (0, external_node_path_.dirname)(constants_filename), isDeno = "u" > typeof Deno, isWindows = 'win32' === process.platform, ROOT_DIST_DIR = 'dist', LOADER_PATH = (0, external_node_path_.join)(constants_dirname), STATIC_PATH = (0, external_node_path_.join)(constants_dirname, '../static'), CLIENT_PATH = (0, external_node_path_.join)(constants_dirname, 'client'), COMPILED_PATH = (0, external_node_path_.join)(constants_dirname, '../compiled'), RSBUILD_OUTPUTS_PATH = '.rsbuild', DEFAULT_DEV_HOST = '0.0.0.0', DEFAULT_ASSET_PREFIX = '/', DEFAULT_STACK_TRACE = 'summary', DEFAULT_WEB_BROWSERSLIST = [
|
|
1063
1240
|
'chrome >= 87',
|
|
1064
1241
|
'edge >= 88',
|
|
1065
1242
|
'firefox >= 78',
|
|
@@ -1105,7 +1282,7 @@ for(var __rspack_i in (()=>{
|
|
|
1105
1282
|
'aac',
|
|
1106
1283
|
'm4a',
|
|
1107
1284
|
'opus'
|
|
1108
|
-
], LAZY_COMPILATION_IDENTIFIER = 'lazy-compilation-proxy', vendors_require = (0, external_node_module_.createRequire)(__rslib_import_meta_url__), requireCompiledPackage = (name)=>vendors_require(`${COMPILED_PATH}/${name}/index.js`), color = requireCompiledPackage('picocolors'),
|
|
1285
|
+
], LAZY_COMPILATION_IDENTIFIER = 'lazy-compilation-proxy', vendors_require = (0, external_node_module_.createRequire)(__rslib_import_meta_url__), requireCompiledPackage = (name)=>vendors_require(`${COMPILED_PATH}/${name}/index.js`), color = requireCompiledPackage('picocolors'), isDebug = ()=>{
|
|
1109
1286
|
if (!process.env.DEBUG) return !1;
|
|
1110
1287
|
let values = process.env.DEBUG.toLocaleLowerCase().split(',');
|
|
1111
1288
|
return [
|
|
@@ -1113,14 +1290,14 @@ for(var __rspack_i in (()=>{
|
|
|
1113
1290
|
'builder',
|
|
1114
1291
|
'*'
|
|
1115
1292
|
].some((key)=>values.includes(key));
|
|
1116
|
-
};
|
|
1293
|
+
}, isVerbose = ()=>'verbose' === src_logger.level;
|
|
1117
1294
|
function getTime() {
|
|
1118
1295
|
let now = new Date(), hours = String(now.getHours()).padStart(2, '0'), minutes = String(now.getMinutes()).padStart(2, '0'), seconds = String(now.getSeconds()).padStart(2, '0');
|
|
1119
1296
|
return `${hours}:${minutes}:${seconds}`;
|
|
1120
1297
|
}
|
|
1121
|
-
isDebug() && (
|
|
1298
|
+
isDebug() && (src_logger.level = 'verbose'), src_logger.override({
|
|
1122
1299
|
debug: (message, ...args)=>{
|
|
1123
|
-
if ('verbose' !==
|
|
1300
|
+
if ('verbose' !== src_logger.level) return;
|
|
1124
1301
|
let time = color.gray(getTime());
|
|
1125
1302
|
console.log(` ${color.magenta('rsbuild')} ${time} ${message}`, ...args);
|
|
1126
1303
|
}
|
|
@@ -2511,7 +2688,7 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
2511
2688
|
moduleNames[0] !== formatted && moduleNames.unshift(formatted);
|
|
2512
2689
|
}
|
|
2513
2690
|
let trace = moduleNames.slice().reverse();
|
|
2514
|
-
return trace.length > 4 &&
|
|
2691
|
+
return trace.length > 4 && !isVerbose() && (trace = [
|
|
2515
2692
|
...trace.slice(0, 2),
|
|
2516
2693
|
`… (${trace.length - 2 - 2} hidden)`,
|
|
2517
2694
|
...trace.slice(trace.length - 2)
|
|
@@ -2567,8 +2744,8 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
2567
2744
|
}
|
|
2568
2745
|
let prefix = root + external_node_path_.sep;
|
|
2569
2746
|
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`;
|
|
2570
|
-
})(fileName, stats, root)}${stats.message}`, verbose =
|
|
2571
|
-
if (verbose && (stats.details && (message += `\nDetails: ${stats.details}\n`), stats.stack && (message += `\n${stats.stack}`)), 'error' === level ||
|
|
2747
|
+
})(fileName, stats, root)}${stats.message}`, verbose = isVerbose();
|
|
2748
|
+
if (verbose && (stats.details && (message += `\nDetails: ${stats.details}\n`), stats.stack && (message += `\n${stats.stack}`)), 'error' === level || isVerbose()) {
|
|
2572
2749
|
let moduleTrace = formatModuleTrace(stats, fileName, level);
|
|
2573
2750
|
moduleTrace && (message += moduleTrace);
|
|
2574
2751
|
}
|
|
@@ -2657,7 +2834,7 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
2657
2834
|
errors: !0,
|
|
2658
2835
|
warnings: !0,
|
|
2659
2836
|
moduleTrace: !0,
|
|
2660
|
-
errorStack:
|
|
2837
|
+
errorStack: isVerbose()
|
|
2661
2838
|
};
|
|
2662
2839
|
if ('dev' === action && (defaultOptions = {
|
|
2663
2840
|
...defaultOptions,
|
|
@@ -2695,7 +2872,7 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
2695
2872
|
}
|
|
2696
2873
|
return {};
|
|
2697
2874
|
}
|
|
2698
|
-
let removeLoaderChainDelimiter = (moduleId)=>
|
|
2875
|
+
let removeLoaderChainDelimiter = (moduleId)=>isVerbose() ? moduleId : moduleId.split('!=!')[0];
|
|
2699
2876
|
var external_node_fs_ = __webpack_require__("node:fs"), external_node_fs_default = __webpack_require__.n(external_node_fs_);
|
|
2700
2877
|
function _define_property(obj, key, value) {
|
|
2701
2878
|
return key in obj ? Object.defineProperty(obj, key, {
|
|
@@ -2862,7 +3039,7 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
2862
3039
|
!keep.some((reg)=>reg.test(toPosixPath(fullPath))) && (entry.isDirectory() ? (await emptyDir(fullPath, keep, !1), keep.length || await external_node_fs_default().promises.rmdir(fullPath)) : await external_node_fs_default().promises.unlink(fullPath));
|
|
2863
3040
|
}));
|
|
2864
3041
|
} catch (err) {
|
|
2865
|
-
|
|
3042
|
+
src_logger.debug(`failed to empty dir: ${dir}`), src_logger.debug(err);
|
|
2866
3043
|
}
|
|
2867
3044
|
}
|
|
2868
3045
|
let OVERRIDE_PATHS = new Set([
|
|
@@ -3119,9 +3296,7 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
3119
3296
|
return Array.isArray(publicDir) ? publicDir.map((options)=>mergeWithDefault(options)) : [
|
|
3120
3297
|
mergeWithDefault(publicDir)
|
|
3121
3298
|
];
|
|
3122
|
-
};
|
|
3123
|
-
var external_node_os_ = __webpack_require__("node:os"), external_node_os_default = __webpack_require__.n(external_node_os_), external_node_process_ = __webpack_require__("node:process"), external_node_process_default = __webpack_require__.n(external_node_process_);
|
|
3124
|
-
let exitHook_callbacks = new Set(), isCalled = !1, isRegistered = !1;
|
|
3299
|
+
}, exitHook_callbacks = new Set(), isCalled = !1, isRegistered = !1;
|
|
3125
3300
|
function exit(exitCode, type) {
|
|
3126
3301
|
if (!isCalled) {
|
|
3127
3302
|
for (let callback of (isCalled = !0, exitHook_callbacks))callback(exitCode);
|
|
@@ -3188,7 +3363,7 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
3188
3363
|
let { before, environment } = options || {};
|
|
3189
3364
|
for (let newPlugin of newPlugins)if (newPlugin) if (validatePlugin(newPlugin), before) {
|
|
3190
3365
|
let index = plugins.findIndex((item)=>item.instance.name === before);
|
|
3191
|
-
-1 === index ? (
|
|
3366
|
+
-1 === index ? (src_logger.warn(`Plugin "${before}" does not exist.`), plugins.push({
|
|
3192
3367
|
environment,
|
|
3193
3368
|
instance: newPlugin
|
|
3194
3369
|
})) : plugins.splice(index, 0, {
|
|
@@ -3207,7 +3382,7 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
3207
3382
|
};
|
|
3208
3383
|
}
|
|
3209
3384
|
async function initPlugins({ context, pluginManager }) {
|
|
3210
|
-
|
|
3385
|
+
src_logger.debug('initializing plugins');
|
|
3211
3386
|
let plugins = pluginManager.getAllPluginsWithMeta();
|
|
3212
3387
|
plugins = ((plugins)=>{
|
|
3213
3388
|
let allLines = [];
|
|
@@ -3270,11 +3445,11 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
3270
3445
|
await setup(context.getPluginAPI(environment));
|
|
3271
3446
|
}
|
|
3272
3447
|
}
|
|
3273
|
-
|
|
3448
|
+
src_logger.debug('plugins initialized');
|
|
3274
3449
|
}
|
|
3275
3450
|
function getHTMLPathByEntry(entryName, config) {
|
|
3276
3451
|
let filename = getFilename(config, 'html').replace('[name]', entryName), prefix = config.output.distPath.html;
|
|
3277
|
-
return prefix.startsWith('/') &&
|
|
3452
|
+
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(/^\/+/, '');
|
|
3278
3453
|
}
|
|
3279
3454
|
let mapProcessAssetsStage = (compiler, stage)=>{
|
|
3280
3455
|
let { Compilation } = compiler.webpack;
|
|
@@ -3391,7 +3566,7 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
3391
3566
|
return {
|
|
3392
3567
|
context: publicContext,
|
|
3393
3568
|
expose,
|
|
3394
|
-
logger:
|
|
3569
|
+
logger: src_logger,
|
|
3395
3570
|
transform: (environment1 = environment, (descriptor, handler)=>{
|
|
3396
3571
|
let id = `rsbuild-transform-${transformId++}`;
|
|
3397
3572
|
transformer[id] = handler, hooks.modifyBundlerChain.tapEnvironment({
|
|
@@ -3537,7 +3712,7 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
3537
3712
|
webSocketToken
|
|
3538
3713
|
}, readonlyEnvironmentContext = new Proxy(environmentContext, {
|
|
3539
3714
|
get: (target, prop)=>target[prop],
|
|
3540
|
-
set: (target, prop, newValue)=>('manifest' === prop ? target[prop] = newValue :
|
|
3715
|
+
set: (target, prop, newValue)=>('manifest' === prop ? target[prop] = newValue : src_logger.error(`EnvironmentContext is readonly, you can not assign to the "environment.${prop}" prop.`), !0)
|
|
3541
3716
|
});
|
|
3542
3717
|
context.environmentList[index] = readonlyEnvironmentContext, context.environments[name] = readonlyEnvironmentContext;
|
|
3543
3718
|
}
|
|
@@ -3561,13 +3736,13 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
3561
3736
|
get (target, prop) {
|
|
3562
3737
|
if (exposedKeys.includes(prop)) return target[prop];
|
|
3563
3738
|
},
|
|
3564
|
-
set: (_, prop)=>(
|
|
3739
|
+
set: (_, prop)=>(src_logger.error(`Context is readonly, you can not assign to the "context.${prop}" prop.`), !0)
|
|
3565
3740
|
});
|
|
3566
3741
|
}
|
|
3567
3742
|
async function createContext(options, userConfig) {
|
|
3568
3743
|
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, bundlerType = userConfig.provider ? 'webpack' : 'rspack';
|
|
3569
3744
|
return {
|
|
3570
|
-
version: "1.7.0-beta.
|
|
3745
|
+
version: "1.7.0-beta.2",
|
|
3571
3746
|
rootPath,
|
|
3572
3747
|
distPath: '',
|
|
3573
3748
|
cachePath,
|
|
@@ -3630,7 +3805,7 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
3630
3805
|
recursive: !0
|
|
3631
3806
|
}), await Promise.all(files.map(async (item)=>external_node_fs_default().promises.writeFile(item.path, `export default ${item.content}`)));
|
|
3632
3807
|
let fileInfos = files.map((item)=>` - ${color.bold(color.yellow(item.label))}: ${color.underline(item.path)}`).join('\n');
|
|
3633
|
-
|
|
3808
|
+
src_logger.success(`config inspection completed, generated files: \n\n${fileInfos}\n`);
|
|
3634
3809
|
}
|
|
3635
3810
|
function stringifyConfig(config, verbose) {
|
|
3636
3811
|
return src_class.toString(config, {
|
|
@@ -3733,7 +3908,7 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
3733
3908
|
}), initial) : config ?? initial;
|
|
3734
3909
|
}
|
|
3735
3910
|
async function modifyBundlerChain(context, utils) {
|
|
3736
|
-
|
|
3911
|
+
src_logger.debug('applying modifyBundlerChain hook');
|
|
3737
3912
|
let bundlerChain = new src_class(), [modifiedBundlerChain] = await context.hooks.modifyBundlerChain.callChain({
|
|
3738
3913
|
environment: utils.environment.name,
|
|
3739
3914
|
args: [
|
|
@@ -3742,7 +3917,7 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
3742
3917
|
]
|
|
3743
3918
|
});
|
|
3744
3919
|
if (utils.environment.config.tools?.bundlerChain) for (let item of helpers_castArray(utils.environment.config.tools.bundlerChain))await item(modifiedBundlerChain, utils);
|
|
3745
|
-
return
|
|
3920
|
+
return src_logger.debug('applied modifyBundlerChain hook'), modifiedBundlerChain;
|
|
3746
3921
|
}
|
|
3747
3922
|
let configChain_CHAIN_ID = {
|
|
3748
3923
|
RULE: {
|
|
@@ -3831,7 +4006,7 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
3831
4006
|
cssExtractPlugin = plugin;
|
|
3832
4007
|
}, getCssExtractPlugin = ()=>cssExtractPlugin || rspack_rspack.CssExtractRspackPlugin;
|
|
3833
4008
|
async function modifyRspackConfig(context, rspackConfig, chainUtils) {
|
|
3834
|
-
|
|
4009
|
+
src_logger.debug('applying modifyRspackConfig hook');
|
|
3835
4010
|
let currentConfig = rspackConfig, utils = getConfigUtils(()=>currentConfig, chainUtils);
|
|
3836
4011
|
if ([currentConfig] = await context.hooks.modifyRspackConfig.callChain({
|
|
3837
4012
|
environment: utils.environment.name,
|
|
@@ -3851,7 +4026,7 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
3851
4026
|
mergeFn: (...args)=>currentConfig = utils.mergeConfig.call(utils, args)
|
|
3852
4027
|
});
|
|
3853
4028
|
}
|
|
3854
|
-
return
|
|
4029
|
+
return src_logger.debug('applied modifyRspackConfig hook'), currentConfig;
|
|
3855
4030
|
}
|
|
3856
4031
|
function getConfigUtils(getCurrentConfig, chainUtils) {
|
|
3857
4032
|
return {
|
|
@@ -3904,7 +4079,7 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
3904
4079
|
throw Error(`${color.dim('[rsbuild:plugin]')} "${color.yellow(name)}" appears to be an Rsbuild plugin. It cannot be used as an Rspack plugin.`);
|
|
3905
4080
|
}
|
|
3906
4081
|
}
|
|
3907
|
-
config.devServer &&
|
|
4082
|
+
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.`);
|
|
3908
4083
|
}
|
|
3909
4084
|
async function generateRspackConfig({ target, context, environmentName }) {
|
|
3910
4085
|
let chainUtils = getChainUtils(target, context.environments[environmentName], context.environments), { BannerPlugin, DefinePlugin, IgnorePlugin, ProvidePlugin, SourceMapDevToolPlugin, HotModuleReplacementPlugin } = rspack_rspack, rspackConfig = (await modifyBundlerChain(context, {
|
|
@@ -3931,14 +4106,14 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
3931
4106
|
'lazyCompilation'
|
|
3932
4107
|
];
|
|
3933
4108
|
async function modifyRsbuildConfig(context) {
|
|
3934
|
-
|
|
4109
|
+
src_logger.debug('applying modifyRsbuildConfig hook');
|
|
3935
4110
|
let pluginsCount = context.config.plugins?.length ?? 0, [modified] = await context.hooks.modifyRsbuildConfig.callChain(context.config, {
|
|
3936
4111
|
mergeRsbuildConfig: mergeRsbuildConfig
|
|
3937
4112
|
});
|
|
3938
|
-
context.config = modified, (modified.plugins?.length ?? 0) !== pluginsCount &&
|
|
4113
|
+
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');
|
|
3939
4114
|
}
|
|
3940
4115
|
async function modifyEnvironmentConfig(context, config, name) {
|
|
3941
|
-
|
|
4116
|
+
src_logger.debug(`applying modifyEnvironmentConfig hook (${name})`);
|
|
3942
4117
|
let [modified] = await context.hooks.modifyEnvironmentConfig.callChain({
|
|
3943
4118
|
environment: name,
|
|
3944
4119
|
args: [
|
|
@@ -3949,7 +4124,7 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
3949
4124
|
}
|
|
3950
4125
|
]
|
|
3951
4126
|
});
|
|
3952
|
-
return
|
|
4127
|
+
return src_logger.debug(`applied modifyEnvironmentConfig hook (${name})`), modified;
|
|
3953
4128
|
}
|
|
3954
4129
|
let createEnvironmentNotFoundError = (environments = [])=>{
|
|
3955
4130
|
let envList = color.yellow(environments.join(','));
|
|
@@ -4025,7 +4200,7 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
4025
4200
|
'web-worker'
|
|
4026
4201
|
];
|
|
4027
4202
|
for (let name of environmentNames){
|
|
4028
|
-
environmentNameRegexp.test(name) ||
|
|
4203
|
+
environmentNameRegexp.test(name) || src_logger.warn(`${color.dim('[rsbuild:config]')} Environment name "${color.yellow(name)}" contains invalid characters. Only letters, numbers, "-", "_", and "$" are allowed.`);
|
|
4029
4204
|
let outputConfig = config.environments[name].output;
|
|
4030
4205
|
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(', '))}`);
|
|
4031
4206
|
}
|
|
@@ -4083,20 +4258,20 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
4083
4258
|
let { modifiedFiles } = compiler, changedFiles = modifiedFiles?.size ? Array.from(modifiedFiles) : lazyModules.size ? Array.from(lazyModules) : null;
|
|
4084
4259
|
if (changedFiles?.length) {
|
|
4085
4260
|
let fileInfo = formatFileList(changedFiles, context.rootPath);
|
|
4086
|
-
|
|
4261
|
+
src_logger.start(`building ${color.dim(fileInfo)}`);
|
|
4087
4262
|
return;
|
|
4088
4263
|
}
|
|
4089
4264
|
let removedFiles = compiler.removedFiles ? Array.from(compiler.removedFiles) : null;
|
|
4090
4265
|
if (removedFiles?.length) {
|
|
4091
|
-
if (removedFiles.every((item)=>item.includes('virtual'))) return void
|
|
4266
|
+
if (removedFiles.every((item)=>item.includes('virtual'))) return void src_logger.start(`building ${color.dim('virtual modules')}`);
|
|
4092
4267
|
let fileInfo = formatFileList(removedFiles, context.rootPath);
|
|
4093
|
-
return void
|
|
4268
|
+
return void src_logger.start(`building ${color.dim(`removed ${fileInfo}`)}`);
|
|
4094
4269
|
}
|
|
4095
|
-
|
|
4270
|
+
src_logger.start('build started...');
|
|
4096
4271
|
}
|
|
4097
4272
|
async function createCompiler_createCompiler(options) {
|
|
4098
4273
|
let version;
|
|
4099
|
-
|
|
4274
|
+
src_logger.debug('creating compiler');
|
|
4100
4275
|
let HOOK_NAME = 'rsbuild:compiler', { context } = options, { rspackConfigs } = await initConfigs(options);
|
|
4101
4276
|
if (await context.hooks.onBeforeCreateCompiler.callBatch({
|
|
4102
4277
|
bundlerConfigs: rspackConfigs,
|
|
@@ -4113,7 +4288,7 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
4113
4288
|
let isMultiCompiler = rspackConfigs.length > 1, compiler = isMultiCompiler ? rspack_rspack(rspackConfigs) : rspack_rspack(rspackConfigs[0]);
|
|
4114
4289
|
'true' === process.env.RSPACK_UNSAFE_FAST_DROP && (compiler.unsafeFastDrop = !0);
|
|
4115
4290
|
let isVersionLogged = !1, isCompiling = !1, logRspackVersion = ()=>{
|
|
4116
|
-
isVersionLogged || (
|
|
4291
|
+
isVersionLogged || (src_logger.debug(`using Rspack v${rspack_rspack.rspackVersion}`), isVersionLogged = !0);
|
|
4117
4292
|
}, lazyModules = new Set();
|
|
4118
4293
|
compiler.hooks.infrastructureLog.tap(HOOK_NAME, (name, _, args)=>{
|
|
4119
4294
|
let log = args[0];
|
|
@@ -4135,14 +4310,14 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
4135
4310
|
}), compiler.hooks.invalid.tap(HOOK_NAME, ()=>{
|
|
4136
4311
|
context.buildState.stats = null, context.buildState.status = 'idle', context.buildState.hasErrors = !1;
|
|
4137
4312
|
}), 'build' === context.action && (isMultiCompiler ? compiler.compilers[0] : compiler).hooks.run.tap(HOOK_NAME, ()=>{
|
|
4138
|
-
|
|
4313
|
+
src_logger.info('build started...'), logRspackVersion();
|
|
4139
4314
|
});
|
|
4140
4315
|
let printTime = (index, hasErrors)=>{
|
|
4141
4316
|
if (null === startTime) return;
|
|
4142
4317
|
let { name } = context.environmentList[index], time = Date.now() - startTime;
|
|
4143
4318
|
context.buildState.time[name] = time;
|
|
4144
4319
|
let suffix = isMultiCompiler ? color.dim(` (${name})`) : '', timeStr = `${prettyTime(time / 1000)}${suffix}`;
|
|
4145
|
-
hasErrors ?
|
|
4320
|
+
hasErrors ? src_logger.error(`build failed in ${timeStr}`) : src_logger.ready(`built in ${timeStr}`);
|
|
4146
4321
|
};
|
|
4147
4322
|
return isMultiCompiler && compiler.compilers.forEach((item, index)=>{
|
|
4148
4323
|
item.hooks.done.tap(HOOK_NAME, (stats)=>{
|
|
@@ -4152,7 +4327,7 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
4152
4327
|
let stats = getRsbuildStats(statsInstance, compiler, context.action), hasErrors = statsInstance.hasErrors();
|
|
4153
4328
|
context.buildState.stats = stats, context.buildState.status = 'done', context.buildState.hasErrors = hasErrors, context.socketServer?.onBuildDone();
|
|
4154
4329
|
let { message, level } = formatStats(stats, hasErrors, options.context.rootPath);
|
|
4155
|
-
'error' === level &&
|
|
4330
|
+
'error' === level && src_logger.error(message), 'warning' === level && src_logger.warn(message), isMultiCompiler || printTime(0, hasErrors), isCompiling = !1;
|
|
4156
4331
|
}), 'dev' === context.action && registerDevHook({
|
|
4157
4332
|
context,
|
|
4158
4333
|
compiler,
|
|
@@ -4161,7 +4336,7 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
4161
4336
|
}), await context.hooks.onAfterCreateCompiler.callBatch({
|
|
4162
4337
|
compiler,
|
|
4163
4338
|
environments: context.environments
|
|
4164
|
-
}),
|
|
4339
|
+
}), src_logger.debug('compiler created'), {
|
|
4165
4340
|
compiler,
|
|
4166
4341
|
rspackConfigs
|
|
4167
4342
|
};
|
|
@@ -4182,7 +4357,7 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
4182
4357
|
}), watch) {
|
|
4183
4358
|
let watchOptions = bundlerConfigs ? bundlerConfigs.map((options)=>options.watchOptions || {}) : [];
|
|
4184
4359
|
return compiler.watch(watchOptions.length > 1 ? watchOptions : watchOptions[0] || {}, (err)=>{
|
|
4185
|
-
err &&
|
|
4360
|
+
err && src_logger.error(err);
|
|
4186
4361
|
}), {
|
|
4187
4362
|
close: ()=>new Promise((resolve)=>{
|
|
4188
4363
|
compiler.close(()=>{
|
|
@@ -4194,7 +4369,7 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
4194
4369
|
let { stats } = await new Promise((resolve, reject)=>{
|
|
4195
4370
|
compiler.run((err, stats)=>{
|
|
4196
4371
|
compiler.close((closeErr)=>{
|
|
4197
|
-
closeErr &&
|
|
4372
|
+
closeErr && src_logger.error('Failed to close compiler: ', closeErr), err ? reject(err) : context.buildState.hasErrors ? reject(Error(RSPACK_BUILD_ERROR)) : resolve({
|
|
4198
4373
|
stats
|
|
4199
4374
|
});
|
|
4200
4375
|
});
|
|
@@ -4225,7 +4400,7 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
4225
4400
|
`.env.${mode}`,
|
|
4226
4401
|
`.env.${mode}.local`
|
|
4227
4402
|
].map((filename)=>(0, external_node_path_.join)(cwd, filename)).filter(isFileSync), parsed = {};
|
|
4228
|
-
for (let envPath of filePaths)Object.assign(parsed, loadEnv_parse(external_node_fs_default().readFileSync(envPath))),
|
|
4403
|
+
for (let envPath of filePaths)Object.assign(parsed, loadEnv_parse(external_node_fs_default().readFileSync(envPath))), src_logger.debug('loaded env file:', envPath);
|
|
4229
4404
|
parsed.NODE_ENV && (processEnv.NODE_ENV = parsed.NODE_ENV), (0, main.expand)({
|
|
4230
4405
|
parsed,
|
|
4231
4406
|
processEnv
|
|
@@ -4301,7 +4476,7 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
4301
4476
|
try {
|
|
4302
4477
|
prevBuildDependencies = JSON.parse(rawConfigFile);
|
|
4303
4478
|
} catch (e) {
|
|
4304
|
-
|
|
4479
|
+
src_logger.debug('failed to parse the previous buildDependencies.json', e);
|
|
4305
4480
|
}
|
|
4306
4481
|
if (JSON.stringify(prevBuildDependencies) === JSON.stringify(buildDependencies)) return;
|
|
4307
4482
|
await external_node_fs_default().promises.rm(cacheDirectory, {
|
|
@@ -4314,7 +4489,7 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
4314
4489
|
recursive: !0
|
|
4315
4490
|
}), await external_node_fs_default().promises.writeFile(configFile, JSON.stringify(buildDependencies));
|
|
4316
4491
|
} catch (e) {
|
|
4317
|
-
|
|
4492
|
+
src_logger.debug('failed to write the buildDependencies.json', e);
|
|
4318
4493
|
}
|
|
4319
4494
|
}
|
|
4320
4495
|
function getCacheDirectory({ cacheDirectory }, context) {
|
|
@@ -4448,7 +4623,7 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
4448
4623
|
if (!value) return;
|
|
4449
4624
|
let check = (value)=>{
|
|
4450
4625
|
let pathKey = Object.keys(value).find((key)=>'path' === key.toLowerCase() && value[key] === process.env[key]);
|
|
4451
|
-
pathKey &&
|
|
4626
|
+
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.`);
|
|
4452
4627
|
};
|
|
4453
4628
|
if ('object' == typeof value) return void check(value);
|
|
4454
4629
|
if ('string' == typeof value) try {
|
|
@@ -4495,7 +4670,7 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
4495
4670
|
recursive: !0
|
|
4496
4671
|
}), await external_node_fs_default().promises.writeFile(snapshotPath, JSON.stringify(snapshots, null, 2));
|
|
4497
4672
|
} catch (err) {
|
|
4498
|
-
|
|
4673
|
+
src_logger.debug('Failed to save file size snapshots:', err);
|
|
4499
4674
|
}
|
|
4500
4675
|
}
|
|
4501
4676
|
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)=>{
|
|
@@ -4728,7 +4903,7 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
4728
4903
|
try {
|
|
4729
4904
|
if (!(buffer = await (0, external_node_util_.promisify)(compilation.inputFileSystem.readFile)(inputFilename))) throw Error('Buffer is undefined');
|
|
4730
4905
|
} catch (error) {
|
|
4731
|
-
return
|
|
4906
|
+
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;
|
|
4732
4907
|
}
|
|
4733
4908
|
let source = new compiler.webpack.sources.RawSource(buffer, !1), outputFilename = external_node_path_default().posix.join(faviconDistPath, name);
|
|
4734
4909
|
return compilation.emitAsset(outputFilename, source), outputFilename;
|
|
@@ -5036,7 +5211,7 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
5036
5211
|
}
|
|
5037
5212
|
if (0 === urls.length || 0 === routes.length && !useCustomUrl) return null;
|
|
5038
5213
|
let message = getURLMessages(urls, routes);
|
|
5039
|
-
return !trailingLineBreak && message.endsWith('\n') && (message = message.slice(0, -1)),
|
|
5214
|
+
return !trailingLineBreak && message.endsWith('\n') && (message = message.slice(0, -1)), src_logger.log(message), message;
|
|
5040
5215
|
}
|
|
5041
5216
|
let getPort = async ({ host, port, strictPort, tryLimits = 20 })=>{
|
|
5042
5217
|
'string' == typeof port && (port = Number.parseInt(port, 10)), strictPort && (tryLimits = 1);
|
|
@@ -5169,9 +5344,9 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
5169
5344
|
if (chromiumBrowser) return await execAsync(`osascript openChrome.applescript "${encodeURI(url)}" "${chromiumBrowser}"`, {
|
|
5170
5345
|
cwd: STATIC_PATH
|
|
5171
5346
|
}), !0;
|
|
5172
|
-
|
|
5347
|
+
src_logger.debug('failed to find the target browser.');
|
|
5173
5348
|
} catch (err) {
|
|
5174
|
-
|
|
5349
|
+
src_logger.debug("failed to open start URL with apple script."), src_logger.debug(err);
|
|
5175
5350
|
}
|
|
5176
5351
|
}
|
|
5177
5352
|
let { apps, default: baseOpen } = await __webpack_require__.e("664").then(__webpack_require__.bind(__webpack_require__, "../../node_modules/.pnpm/open@11.0.0/node_modules/open/index.js"));
|
|
@@ -5183,10 +5358,10 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
5183
5358
|
}
|
|
5184
5359
|
} : {};
|
|
5185
5360
|
return (await baseOpen(url, options)).on('error', (err)=>{
|
|
5186
|
-
|
|
5361
|
+
src_logger.error('Failed to launch browser in child process', err);
|
|
5187
5362
|
}), !0;
|
|
5188
5363
|
} catch (err) {
|
|
5189
|
-
return
|
|
5364
|
+
return src_logger.error('Failed to launch browser.'), src_logger.error(err), !1;
|
|
5190
5365
|
}
|
|
5191
5366
|
}
|
|
5192
5367
|
let openedURLs = [], replacePortPlaceholder = (url, port)=>url.replace(/<port>/g, String(port));
|
|
@@ -5301,13 +5476,13 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
5301
5476
|
initial: {},
|
|
5302
5477
|
config: config.resolve.alias
|
|
5303
5478
|
});
|
|
5304
|
-
if (config.source.alias && (
|
|
5479
|
+
if (config.source.alias && (src_logger.warn(`${color.dim('[rsbuild:config]')} The ${color.yellow('"source.alias"')} config is deprecated, use ${color.yellow('"resolve.alias"')} instead.`), mergedAlias = reduceConfigs({
|
|
5305
5480
|
initial: mergedAlias,
|
|
5306
5481
|
config: config.source.alias
|
|
5307
5482
|
})), config.resolve.dedupe) for (let pkgName of config.resolve.dedupe){
|
|
5308
5483
|
let pkgPath;
|
|
5309
5484
|
if (mergedAlias[pkgName]) {
|
|
5310
|
-
|
|
5485
|
+
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.`);
|
|
5311
5486
|
continue;
|
|
5312
5487
|
}
|
|
5313
5488
|
try {
|
|
@@ -5329,7 +5504,7 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
5329
5504
|
].join(external_node_path_.sep);
|
|
5330
5505
|
for(; !pkgPath.endsWith(trailing) && pkgPath.includes('node_modules');)pkgPath = (0, external_node_path_.dirname)(pkgPath);
|
|
5331
5506
|
} catch {
|
|
5332
|
-
|
|
5507
|
+
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.`);
|
|
5333
5508
|
continue;
|
|
5334
5509
|
}
|
|
5335
5510
|
mergedAlias[pkgName] = pkgPath;
|
|
@@ -5899,7 +6074,7 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
5899
6074
|
let resolved = await getFileFromUrl(req.url, outputFileSystem, context);
|
|
5900
6075
|
if (!resolved) return void await goNext();
|
|
5901
6076
|
if ('errorCode' in resolved) {
|
|
5902
|
-
403 === resolved.errorCode ?
|
|
6077
|
+
403 === resolved.errorCode ? src_logger.error(`[rsbuild:middleware] Malicious path "${req.url}".`) : 400 === resolved.errorCode && src_logger.error(`[rsbuild:middleware] Invalid pathname "${req.url}".`), sendError(res, resolved.errorCode);
|
|
5903
6078
|
return;
|
|
5904
6079
|
}
|
|
5905
6080
|
let { fsStats, filename } = resolved, { size } = fsStats, len = size, offset = 0;
|
|
@@ -5926,10 +6101,10 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
5926
6101
|
if (rangeHeader) {
|
|
5927
6102
|
let parsedRanges = await parseRangeHeaders(`${size}|${rangeHeader}`);
|
|
5928
6103
|
if (isRangeFresh() || (parsedRanges = []), -1 === parsedRanges) {
|
|
5929
|
-
|
|
6104
|
+
src_logger.error("[rsbuild:middleware] Unsatisfiable range for 'Range' header."), res.setHeader('Content-Range', getValueContentRangeHeader('bytes', size)), sendError(res, 416);
|
|
5930
6105
|
return;
|
|
5931
6106
|
}
|
|
5932
|
-
-2 === parsedRanges ?
|
|
6107
|
+
-2 === parsedRanges ? src_logger.error("[rsbuild:middleware] A malformed 'Range' header was provided. A regular response will be sent for this request.") : parsedRanges.length > 1 && src_logger.error("[rsbuild:middleware] A 'Range' header with multiple ranges was provided. Multiple ranges are not supported, so a regular response will be sent for this request."), -2 !== parsedRanges && 1 === parsedRanges.length && (res.statusCode = 206, res.setHeader('Content-Range', getValueContentRangeHeader('bytes', size, parsedRanges[0])), [offset, len] = getOffsetAndLenFromRange(parsedRanges[0]));
|
|
5933
6108
|
}
|
|
5934
6109
|
let [start, end] = calcStartAndEnd(offset, len);
|
|
5935
6110
|
try {
|
|
@@ -5978,12 +6153,12 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
5978
6153
|
recursive: !0
|
|
5979
6154
|
}, (mkdirError)=>{
|
|
5980
6155
|
if (mkdirError) {
|
|
5981
|
-
|
|
6156
|
+
src_logger.error(`[rsbuild:middleware] ${name}Unable to write "${dir}" directory to disk:\n${mkdirError.message}`), callback(mkdirError);
|
|
5982
6157
|
return;
|
|
5983
6158
|
}
|
|
5984
6159
|
external_node_fs_default().writeFile(targetPath, content, (writeFileError)=>{
|
|
5985
6160
|
if (writeFileError) {
|
|
5986
|
-
|
|
6161
|
+
src_logger.error(`[rsbuild:middleware] ${name}Unable to write "${targetPath}" asset to disk:\n${writeFileError.message}`), callback(writeFileError);
|
|
5987
6162
|
return;
|
|
5988
6163
|
}
|
|
5989
6164
|
callback();
|
|
@@ -6004,16 +6179,15 @@ ${section.body}` : section.body).join("\n\n"));
|
|
|
6004
6179
|
'<port>' === clientConfig.port && (clientConfig.port = resolvedPort);
|
|
6005
6180
|
let hmrEntry = `import { init } from '${toPosixPath((0, external_node_path_.join)(CLIENT_PATH, 'hmr.js'))}';
|
|
6006
6181
|
${config.dev.client.overlay ? `import '${toPosixPath((0, external_node_path_.join)(CLIENT_PATH, 'overlay.js'))}';` : ''}
|
|
6007
|
-
|
|
6008
|
-
|
|
6009
|
-
|
|
6010
|
-
|
|
6011
|
-
|
|
6012
|
-
|
|
6013
|
-
|
|
6014
|
-
|
|
6015
|
-
|
|
6016
|
-
});
|
|
6182
|
+
init(
|
|
6183
|
+
'${token}',
|
|
6184
|
+
${JSON.stringify(clientConfig)},
|
|
6185
|
+
${JSON.stringify(resolvedHost)},
|
|
6186
|
+
${resolvedPort},
|
|
6187
|
+
${config.dev.liveReload},
|
|
6188
|
+
${!!config.dev.browserLogs},
|
|
6189
|
+
${JSON.stringify(config.dev.client.logLevel)}
|
|
6190
|
+
)
|
|
6017
6191
|
`;
|
|
6018
6192
|
new compiler.webpack.EntryPlugin(compiler.context, createVirtualModule(hmrEntry), {
|
|
6019
6193
|
name: void 0
|
|
@@ -6097,7 +6271,7 @@ init({
|
|
|
6097
6271
|
else {
|
|
6098
6272
|
let watchOptions = compilers.length > 1 ? compilers.map(({ options })=>options.watchOptions || {}) : compilers[0].options.watchOptions || {};
|
|
6099
6273
|
watching = compiler.watch(watchOptions, (error)=>{
|
|
6100
|
-
error && (error.message?.includes('× Error:') && (error.message = error.message.replace('× Error:', '').trim()),
|
|
6274
|
+
error && (error.message?.includes('× Error:') && (error.message = error.message.replace('× Error:', '').trim()), src_logger.error(error));
|
|
6101
6275
|
});
|
|
6102
6276
|
}
|
|
6103
6277
|
}, instance.close = (callback = noop)=>{
|
|
@@ -6172,33 +6346,32 @@ init({
|
|
|
6172
6346
|
column: parts[4] ? +parts[4] : null
|
|
6173
6347
|
} : null;
|
|
6174
6348
|
}
|
|
6175
|
-
let isValidMethodName = (methodName)=>'<unknown>' !== methodName && !/[\\/]/.test(methodName)
|
|
6176
|
-
function getOriginalPosition(rawSourceMap, line, column) {
|
|
6177
|
-
let { TraceMap, originalPositionFor } = requireCompiledPackage('@jridgewell/trace-mapping');
|
|
6178
|
-
return originalPositionFor(new TraceMap(rawSourceMap), {
|
|
6179
|
-
line,
|
|
6180
|
-
column
|
|
6181
|
-
});
|
|
6182
|
-
}
|
|
6183
|
-
let parseFrame = async (frame, fs, context)=>{
|
|
6349
|
+
let isValidMethodName = (methodName)=>'<unknown>' !== methodName && !/[\\/]/.test(methodName), parseFrame = async (frame, fs, context, cachedTraceMap)=>{
|
|
6184
6350
|
let { file, column, lineNumber } = frame, sourceMapInfo = await getFileFromUrl(`${file}.map`, fs, context);
|
|
6185
6351
|
if (!sourceMapInfo || 'errorCode' in sourceMapInfo) return;
|
|
6186
|
-
let
|
|
6352
|
+
let { TraceMap, originalPositionFor } = requireCompiledPackage('@jridgewell/trace-mapping'), sourceMapPath = sourceMapInfo.filename;
|
|
6187
6353
|
try {
|
|
6188
|
-
let
|
|
6189
|
-
if (
|
|
6190
|
-
|
|
6191
|
-
|
|
6354
|
+
let tracer = cachedTraceMap.get(sourceMapPath);
|
|
6355
|
+
if (!tracer) {
|
|
6356
|
+
let readFile = (0, external_node_util_.promisify)(fs.readFile), sourceMap = await readFile(sourceMapPath);
|
|
6357
|
+
if (!sourceMap) return;
|
|
6358
|
+
tracer = new TraceMap(sourceMap.toString()), cachedTraceMap.set(sourceMapPath, tracer);
|
|
6359
|
+
}
|
|
6360
|
+
let originalPosition = originalPositionFor(tracer, {
|
|
6361
|
+
line: lineNumber ?? 0,
|
|
6362
|
+
column: column ?? 0
|
|
6363
|
+
});
|
|
6364
|
+
return {
|
|
6365
|
+
sourceMapPath,
|
|
6366
|
+
originalPosition
|
|
6192
6367
|
};
|
|
6193
6368
|
} catch (error) {
|
|
6194
|
-
error instanceof Error &&
|
|
6369
|
+
error instanceof Error && src_logger.debug(`failed to map source map position: ${error.message}`);
|
|
6195
6370
|
}
|
|
6196
|
-
}, resolveOriginalLocation = async (
|
|
6197
|
-
let
|
|
6198
|
-
if (!parsed.length) return;
|
|
6199
|
-
let frame = parsed.find((frame)=>null !== frame.file && null !== frame.column && null !== frame.lineNumber && SCRIPT_REGEX.test(frame.file));
|
|
6371
|
+
}, resolveOriginalLocation = async (stackFrames, fs, context, cachedTraceMap)=>{
|
|
6372
|
+
let frame = stackFrames.find((frame)=>null !== frame.file && null !== frame.column && null !== frame.lineNumber && SCRIPT_REGEX.test(frame.file));
|
|
6200
6373
|
if (!frame) return;
|
|
6201
|
-
let parsedFrame = await parseFrame(frame, fs, context);
|
|
6374
|
+
let parsedFrame = await parseFrame(frame, fs, context, cachedTraceMap);
|
|
6202
6375
|
if (!parsedFrame) return;
|
|
6203
6376
|
let { sourceMapPath, originalPosition } = parsedFrame;
|
|
6204
6377
|
return {
|
|
@@ -6206,41 +6379,41 @@ init({
|
|
|
6206
6379
|
location: formatOriginalLocation(sourceMapPath, originalPosition, context)
|
|
6207
6380
|
};
|
|
6208
6381
|
}, formatOriginalLocation = (sourceMapPath, originalMapping, context)=>{
|
|
6209
|
-
|
|
6210
|
-
|
|
6211
|
-
|
|
6212
|
-
|
|
6382
|
+
let { source, line, column } = originalMapping;
|
|
6383
|
+
if (!source) return;
|
|
6384
|
+
let result = ((source, sourceMapPath, context)=>{
|
|
6385
|
+
if (source.startsWith('webpack/runtime/')) return source;
|
|
6386
|
+
let absoluteSourcePath = external_node_path_default().isAbsolute(source) ? source : external_node_path_default().join(external_node_path_default().dirname(sourceMapPath), source);
|
|
6387
|
+
return external_node_path_default().relative(context.rootPath, absoluteSourcePath);
|
|
6388
|
+
})(source, sourceMapPath, context);
|
|
6213
6389
|
return null !== line && (result += null === column ? `:${line}` : `:${line}:${column}`), result;
|
|
6214
6390
|
}, formatFrameLocation = (frame)=>{
|
|
6215
6391
|
let { file, lineNumber, column } = frame;
|
|
6216
6392
|
if (file) return null !== lineNumber ? null !== column ? `${file}:${lineNumber}:${column}` : `${file}:${lineNumber}` : file;
|
|
6217
|
-
}, formatFullStack = async (
|
|
6218
|
-
let parsed = stack_trace_parser_esm_parse(stack);
|
|
6219
|
-
if (!parsed.length) return;
|
|
6393
|
+
}, formatFullStack = async (stackFrames, context, fs, cachedTraceMap)=>{
|
|
6220
6394
|
let result = '';
|
|
6221
|
-
for (let frame of
|
|
6222
|
-
let parsedFrame = await parseFrame(frame, fs, context), { methodName } = frame, parts = [];
|
|
6223
|
-
|
|
6395
|
+
for (let frame of stackFrames){
|
|
6396
|
+
let parsedFrame = await parseFrame(frame, fs, context, cachedTraceMap), { methodName } = frame, parts = [];
|
|
6397
|
+
isValidMethodName(methodName) && parts.push(methodName);
|
|
6398
|
+
let parsed = !1;
|
|
6399
|
+
if (parsedFrame) {
|
|
6224
6400
|
let { sourceMapPath, originalPosition } = parsedFrame, originalLocation = formatOriginalLocation(sourceMapPath, originalPosition, context);
|
|
6225
|
-
|
|
6226
|
-
|
|
6227
|
-
|
|
6228
|
-
frameString && parts.push(frameString);
|
|
6229
|
-
}
|
|
6230
|
-
} else {
|
|
6401
|
+
originalLocation && (parts.push(originalLocation), parsed = !0);
|
|
6402
|
+
}
|
|
6403
|
+
if (!parsed && isVerbose()) {
|
|
6231
6404
|
let frameString = formatFrameLocation(frame);
|
|
6232
6405
|
frameString && parts.push(frameString);
|
|
6233
6406
|
}
|
|
6234
6407
|
parts[0] && (result += `\n at ${parts[0]}`), parts[1] && (result += ` (${parts[1]})`);
|
|
6235
6408
|
}
|
|
6236
6409
|
return result;
|
|
6237
|
-
}, formatBrowserErrorLog = async (message, context, fs, stackTrace)=>{
|
|
6410
|
+
}, formatBrowserErrorLog = async (message, context, fs, stackTrace, stackFrames, cachedTraceMap)=>{
|
|
6238
6411
|
var log;
|
|
6239
|
-
let log1 =
|
|
6240
|
-
if (
|
|
6412
|
+
let log1 = color.red(message);
|
|
6413
|
+
if (stackFrames?.length) switch(stackTrace){
|
|
6241
6414
|
case 'summary':
|
|
6242
6415
|
{
|
|
6243
|
-
let resolved = await resolveOriginalLocation(
|
|
6416
|
+
let resolved = await resolveOriginalLocation(stackFrames, fs, context, cachedTraceMap);
|
|
6244
6417
|
if (!resolved) break;
|
|
6245
6418
|
let { frame, location } = resolved, { methodName } = frame, suffix = '';
|
|
6246
6419
|
isValidMethodName(methodName) && (suffix += ` at ${methodName}`), location && (suffix += ` (${location})`), log1 += suffix ? color.dim(suffix) : '';
|
|
@@ -6248,7 +6421,7 @@ init({
|
|
|
6248
6421
|
}
|
|
6249
6422
|
case 'full':
|
|
6250
6423
|
{
|
|
6251
|
-
let fullStack = await formatFullStack(
|
|
6424
|
+
let fullStack = await formatFullStack(stackFrames, context, fs, cachedTraceMap);
|
|
6252
6425
|
fullStack && (log1 += fullStack);
|
|
6253
6426
|
}
|
|
6254
6427
|
}
|
|
@@ -6295,9 +6468,9 @@ init({
|
|
|
6295
6468
|
return ansiCodes.length > 0 && (ret += Array(ansiCodes.length + 1).join('</span>')), ret;
|
|
6296
6469
|
}
|
|
6297
6470
|
function convertLinksInHtml(text, root) {
|
|
6298
|
-
let PATH_RE = /(?:\.\.?[/\\]|(file:\/\/\/)?[a-zA-Z]:\\|(file:\/\/)?\/|[A-Za-z0-9._-]+[/\\])[^\s:]*:\d+:\d+/g, URL_RE = /(https?:\/\/(?:[\w-]+\.)+[a-z0-9](?:[\w-.~:/?#[\]@!$&'*+,;=])*)/gi, NODE_INTERNAL_RE = /node:internal[/\\]/, FILE_URI_WINDOWS_RE = /^file:\/\/\/([A-Za-z]:)/, FILE_URI_UNIX_RE = /^file:\/\//;
|
|
6471
|
+
let PATH_RE = /(?:\.\.?[/\\]|(file:\/\/\/)?[a-zA-Z]:\\|(file:\/\/)?\/|[A-Za-z0-9._-]+[/\\])[^\s:]*:\d+:\d+/g, URL_RE = /(https?:\/\/(?:[\w-]+\.)+[a-z0-9](?:[\w-.~:/?#[\]@!$&'*+,;=])*)/gi, NODE_INTERNAL_RE = /node:internal[/\\]/, RSPACK_RUNTIME_RE = /webpack\/runtime\//, FILE_URI_WINDOWS_RE = /^file:\/\/\/([A-Za-z]:)/, FILE_URI_UNIX_RE = /^file:\/\//;
|
|
6299
6472
|
return text.split('\n').map((line)=>{
|
|
6300
|
-
if (NODE_INTERNAL_RE.test(line)) return line;
|
|
6473
|
+
if (NODE_INTERNAL_RE.test(line) || RSPACK_RUNTIME_RE.test(line)) return line;
|
|
6301
6474
|
let replacedLine = line.replace(PATH_RE, (file)=>{
|
|
6302
6475
|
let hasClosingSpan = (file = ((file)=>{
|
|
6303
6476
|
if (!file.startsWith('file://')) return file;
|
|
@@ -6309,141 +6482,6 @@ init({
|
|
|
6309
6482
|
return replacedLine = replacedLine.replace(URL_RE, (url)=>`<a class="url-link" href="${url}" target="_blank" rel="noopener noreferrer">${url}</a>`);
|
|
6310
6483
|
}).join('\n');
|
|
6311
6484
|
}
|
|
6312
|
-
function genOverlayHTML(errors, root) {
|
|
6313
|
-
let htmlItems = errors.map((item)=>convertLinksInHtml(ansiHTML(escapeHtml(item)), root));
|
|
6314
|
-
return `
|
|
6315
|
-
<style>
|
|
6316
|
-
.root {
|
|
6317
|
-
position: fixed;
|
|
6318
|
-
z-index: 9999;
|
|
6319
|
-
top: 0;
|
|
6320
|
-
left: 0;
|
|
6321
|
-
width: 100%;
|
|
6322
|
-
height: 100%;
|
|
6323
|
-
overflow-y: scroll;
|
|
6324
|
-
margin: 0;
|
|
6325
|
-
background: rgba(0, 0, 0, 0.66);
|
|
6326
|
-
cursor: pointer;
|
|
6327
|
-
}
|
|
6328
|
-
.container {
|
|
6329
|
-
font-family: Menlo, Consolas, monospace;
|
|
6330
|
-
line-height: 1.6;
|
|
6331
|
-
width: 960px;
|
|
6332
|
-
max-width: 85%;
|
|
6333
|
-
color: #d8d8d8;
|
|
6334
|
-
margin: 32px auto;
|
|
6335
|
-
padding: 32px 40px;
|
|
6336
|
-
position: relative;
|
|
6337
|
-
background: #181818;
|
|
6338
|
-
border-radius: 24px;
|
|
6339
|
-
box-shadow: 0 19px 38px rgba(0,0,0,0.30), 0 15px 12px rgba(0,0,0,0.22);
|
|
6340
|
-
overflow: hidden;
|
|
6341
|
-
direction: ltr;
|
|
6342
|
-
text-align: left;
|
|
6343
|
-
box-sizing: border-box;
|
|
6344
|
-
cursor: default;
|
|
6345
|
-
}
|
|
6346
|
-
.title {
|
|
6347
|
-
margin: 0 0 20px;
|
|
6348
|
-
padding-bottom: 12px;
|
|
6349
|
-
font-size: 17px;
|
|
6350
|
-
font-weight: 600;
|
|
6351
|
-
color: #fb6a6a;
|
|
6352
|
-
border-bottom: 2px solid rgba(252,94,94,.66);
|
|
6353
|
-
}
|
|
6354
|
-
.content {
|
|
6355
|
-
margin: 0;
|
|
6356
|
-
font-size: 14px;
|
|
6357
|
-
font-family: inherit;
|
|
6358
|
-
white-space: pre-wrap;
|
|
6359
|
-
word-break: break-all;
|
|
6360
|
-
scrollbar-width: none;
|
|
6361
|
-
}
|
|
6362
|
-
.content::-webkit-scrollbar {
|
|
6363
|
-
display: none;
|
|
6364
|
-
}
|
|
6365
|
-
.file-link,
|
|
6366
|
-
.url-link,
|
|
6367
|
-
.config-link {
|
|
6368
|
-
cursor: pointer;
|
|
6369
|
-
text-decoration: underline;
|
|
6370
|
-
text-underline-offset: 3px;
|
|
6371
|
-
&:hover {
|
|
6372
|
-
opacity: 0.8;
|
|
6373
|
-
}
|
|
6374
|
-
&:active {
|
|
6375
|
-
opacity: 0.6;
|
|
6376
|
-
}
|
|
6377
|
-
}
|
|
6378
|
-
.file-link {
|
|
6379
|
-
color: #6eecf7;
|
|
6380
|
-
}
|
|
6381
|
-
.url-link {
|
|
6382
|
-
color: #eff986;
|
|
6383
|
-
}
|
|
6384
|
-
.config-link {
|
|
6385
|
-
color: inherit;
|
|
6386
|
-
text-decoration: none;
|
|
6387
|
-
}
|
|
6388
|
-
.close {
|
|
6389
|
-
position: absolute;
|
|
6390
|
-
top: 27px;
|
|
6391
|
-
right: 32px;
|
|
6392
|
-
width: 32px;
|
|
6393
|
-
height: 32px;
|
|
6394
|
-
cursor: pointer;
|
|
6395
|
-
}
|
|
6396
|
-
.close:hover {
|
|
6397
|
-
opacity: 0.8;
|
|
6398
|
-
}
|
|
6399
|
-
.close:active {
|
|
6400
|
-
opacity: 0.6;
|
|
6401
|
-
}
|
|
6402
|
-
.close:before,
|
|
6403
|
-
.close:after {
|
|
6404
|
-
position: absolute;
|
|
6405
|
-
left: 16px;
|
|
6406
|
-
top: 8px;
|
|
6407
|
-
content: ' ';
|
|
6408
|
-
height: 18px;
|
|
6409
|
-
width: 2px;
|
|
6410
|
-
border-radius: 4px;
|
|
6411
|
-
background-color: #b8b8b8;
|
|
6412
|
-
}
|
|
6413
|
-
.close:before {
|
|
6414
|
-
transform: rotate(45deg);
|
|
6415
|
-
}
|
|
6416
|
-
.close:after {
|
|
6417
|
-
transform: rotate(-45deg);
|
|
6418
|
-
}
|
|
6419
|
-
.footer {
|
|
6420
|
-
font-size: 12px;
|
|
6421
|
-
color: #7e6a92;
|
|
6422
|
-
margin-top: 20px;
|
|
6423
|
-
padding-top: 12px;
|
|
6424
|
-
border-top: 2px solid rgba(126,106,146,.6);
|
|
6425
|
-
}
|
|
6426
|
-
.footer p {
|
|
6427
|
-
margin: 4px 0 0;
|
|
6428
|
-
}
|
|
6429
|
-
.footer span {
|
|
6430
|
-
color: #a88dc3;
|
|
6431
|
-
}
|
|
6432
|
-
</style>
|
|
6433
|
-
|
|
6434
|
-
<div class="root">
|
|
6435
|
-
<div class="container">
|
|
6436
|
-
<div class="close"></div>
|
|
6437
|
-
<p class="title">Build failed</p>
|
|
6438
|
-
<pre class="content">${htmlItems.join('\n\n').trim()}</pre>
|
|
6439
|
-
<footer class="footer">
|
|
6440
|
-
<p><span>Fix error</span>, click outside, or press Esc to close the overlay.</p>
|
|
6441
|
-
<p>Disable overlay by setting Rsbuild's <span><a class="config-link" target="_blank" rel="noopener noreferrer" href="https://rsbuild.rs/config/dev/client">dev.client.overlay</a></span> config to false.<p>
|
|
6442
|
-
</footer>
|
|
6443
|
-
</div>
|
|
6444
|
-
</div>
|
|
6445
|
-
`;
|
|
6446
|
-
}
|
|
6447
6485
|
function isEqualSet(a, b) {
|
|
6448
6486
|
return a.size === b.size && [
|
|
6449
6487
|
...a
|
|
@@ -6487,7 +6525,7 @@ init({
|
|
|
6487
6525
|
noServer: !0,
|
|
6488
6526
|
path: this.options.client?.path
|
|
6489
6527
|
}), this.wsServer.on('error', (err)=>{
|
|
6490
|
-
|
|
6528
|
+
src_logger.error(err);
|
|
6491
6529
|
}), this.heartbeatTimer = setTimeout(this.checkSockets, 30000).unref(), this.wsServer.on('connection', (socket, req)=>{
|
|
6492
6530
|
let query = parseQueryString(req);
|
|
6493
6531
|
this.onConnect(socket, query.token);
|
|
@@ -6499,12 +6537,15 @@ init({
|
|
|
6499
6537
|
});
|
|
6500
6538
|
}
|
|
6501
6539
|
sendError(errors, token) {
|
|
6502
|
-
let formattedErrors = errors.map((item)=>formatStatsError(item,
|
|
6540
|
+
let { rootPath } = this.context, formattedErrors = errors.map((item)=>formatStatsError(item, rootPath)), html = formattedErrors.map((error)=>{
|
|
6541
|
+
var error1, root;
|
|
6542
|
+
return error1 = error, root = rootPath, convertLinksInHtml(ansiHTML(escapeHtml(error1)), root);
|
|
6543
|
+
}).join('\n\n').trim();
|
|
6503
6544
|
this.sockWrite({
|
|
6504
6545
|
type: 'errors',
|
|
6505
6546
|
data: {
|
|
6506
6547
|
text: formattedErrors,
|
|
6507
|
-
html
|
|
6548
|
+
html
|
|
6508
6549
|
}
|
|
6509
6550
|
}, token);
|
|
6510
6551
|
}
|
|
@@ -6542,12 +6583,22 @@ init({
|
|
|
6542
6583
|
socket.isAlive = !0;
|
|
6543
6584
|
}), socket.on('message', async (data)=>{
|
|
6544
6585
|
try {
|
|
6545
|
-
let
|
|
6586
|
+
let payload = JSON.parse('string' == typeof data ? data : data.toString()), { context } = this, config = context.normalizedConfig;
|
|
6546
6587
|
if (!config) return;
|
|
6547
|
-
let { browserLogs } = config.dev;
|
|
6548
|
-
if ('client-error' ===
|
|
6549
|
-
let stackTrace = isObject(browserLogs) && browserLogs.stackTrace || DEFAULT_STACK_TRACE, log = await formatBrowserErrorLog(message,
|
|
6550
|
-
this.reportedBrowserLogs.has(log) || (this.reportedBrowserLogs.add(log),
|
|
6588
|
+
let { browserLogs, client } = config.dev;
|
|
6589
|
+
if ('client-error' === payload.type && 'rspack' === context.bundlerType && !context.buildState.hasErrors && browserLogs) {
|
|
6590
|
+
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);
|
|
6591
|
+
if (this.reportedBrowserLogs.has(log) || (this.reportedBrowserLogs.add(log), src_logger.error(`${color.cyan('[browser]')} ${log}`)), 'object' == typeof client.overlay && client.overlay.runtime) {
|
|
6592
|
+
var error;
|
|
6593
|
+
let resolvedLog = 'full' === stackTrace ? log : await formatBrowserErrorLog(payload.message, context, outputFs, 'full', stackFrames, cachedTraceMap);
|
|
6594
|
+
this.sockWrite({
|
|
6595
|
+
type: 'resolved-client-error',
|
|
6596
|
+
data: {
|
|
6597
|
+
id: payload.id,
|
|
6598
|
+
message: (error = resolvedLog, convertLinksInHtml(ansiHTML(escapeHtml(error)), void 0))
|
|
6599
|
+
}
|
|
6600
|
+
}, token);
|
|
6601
|
+
}
|
|
6551
6602
|
}
|
|
6552
6603
|
} catch {}
|
|
6553
6604
|
});
|
|
@@ -6684,7 +6735,7 @@ init({
|
|
|
6684
6735
|
}
|
|
6685
6736
|
].filter(Boolean);
|
|
6686
6737
|
if (customShortcuts && !Array.isArray(shortcuts = customShortcuts(shortcuts))) throw Error(`${color.dim('[rsbuild:config]')} ${color.yellow('dev.cliShortcuts')} option must return an array of shortcuts.`);
|
|
6687
|
-
help &&
|
|
6738
|
+
help && src_logger.log(!0 === help ? ` ➜ ${color.dim('press')} ${color.bold('h + enter')} ${color.dim('to show shortcuts')}\n` : ` ➜ ${help}\n`);
|
|
6688
6739
|
let { createInterface } = await import("node:readline"), rl = createInterface({
|
|
6689
6740
|
input: process.stdin
|
|
6690
6741
|
});
|
|
@@ -6692,7 +6743,7 @@ init({
|
|
|
6692
6743
|
if ('h' === input) {
|
|
6693
6744
|
let message = `\n ${color.bold(color.blue('Shortcuts:'))}\n`;
|
|
6694
6745
|
for (let shortcut of shortcuts)message += ` ${shortcut.description}\n`;
|
|
6695
|
-
|
|
6746
|
+
src_logger.log(message);
|
|
6696
6747
|
}
|
|
6697
6748
|
for (let shortcut of shortcuts)if (input === shortcut.key) return void shortcut.action();
|
|
6698
6749
|
}), ()=>{
|
|
@@ -6738,15 +6789,15 @@ init({
|
|
|
6738
6789
|
let rewriteTarget, { headers } = req;
|
|
6739
6790
|
if (!req.url) return void next();
|
|
6740
6791
|
if ('GET' !== req.method && 'HEAD' !== req.method) {
|
|
6741
|
-
|
|
6792
|
+
src_logger.debug('Not rewriting', req.method, req.url, 'because the method is not GET or HEAD.'), next();
|
|
6742
6793
|
return;
|
|
6743
6794
|
}
|
|
6744
6795
|
if (!headers || 'string' != typeof headers.accept) {
|
|
6745
|
-
|
|
6796
|
+
src_logger.debug('Not rewriting', req.method, req.url, 'because the client did not send an HTTP accept header.'), next();
|
|
6746
6797
|
return;
|
|
6747
6798
|
}
|
|
6748
6799
|
if (0 === headers.accept.indexOf('application/json')) {
|
|
6749
|
-
|
|
6800
|
+
src_logger.debug('Not rewriting', req.method, req.url, 'because the client prefers JSON.'), next();
|
|
6750
6801
|
return;
|
|
6751
6802
|
}
|
|
6752
6803
|
let rewrites = options.rewrites || [], htmlAcceptHeaders = options.htmlAcceptHeaders || [
|
|
@@ -6754,7 +6805,7 @@ init({
|
|
|
6754
6805
|
'*/*'
|
|
6755
6806
|
], { accept } = headers;
|
|
6756
6807
|
if (!htmlAcceptHeaders.some((item)=>accept.includes(item))) {
|
|
6757
|
-
|
|
6808
|
+
src_logger.debug('Not rewriting', req.method, req.url, 'because the client does not accept HTML.'), next();
|
|
6758
6809
|
return;
|
|
6759
6810
|
}
|
|
6760
6811
|
let parsedUrl = parseReqUrl(req);
|
|
@@ -6767,16 +6818,16 @@ init({
|
|
|
6767
6818
|
parsedUrl,
|
|
6768
6819
|
match,
|
|
6769
6820
|
request: req
|
|
6770
|
-
})).charAt(0) &&
|
|
6821
|
+
})).charAt(0) && src_logger.debug('We recommend using an absolute path for the rewrite target.', 'Received a non-absolute rewrite target', rewriteTarget, 'for URL', req.url), src_logger.debug('Rewriting', req.method, req.url, 'to', rewriteTarget), req.url = rewriteTarget, next();
|
|
6771
6822
|
return;
|
|
6772
6823
|
}
|
|
6773
6824
|
let { pathname } = parsedUrl;
|
|
6774
6825
|
if (pathname && pathname.lastIndexOf('.') > pathname.lastIndexOf('/') && !0 !== options.disableDotRule) {
|
|
6775
|
-
|
|
6826
|
+
src_logger.debug('Not rewriting', req.method, req.url, 'because the path includes a dot (.) character.'), next();
|
|
6776
6827
|
return;
|
|
6777
6828
|
}
|
|
6778
6829
|
let index = options.index || '/index.html';
|
|
6779
|
-
|
|
6830
|
+
src_logger.debug('Rewriting', req.method, req.url, 'to', index), req.url = index, next();
|
|
6780
6831
|
};
|
|
6781
6832
|
}
|
|
6782
6833
|
function parseReqUrl(req) {
|
|
@@ -6795,7 +6846,7 @@ init({
|
|
|
6795
6846
|
on_finished_default()(res, ()=>{
|
|
6796
6847
|
var status;
|
|
6797
6848
|
let method = req.method, url = req.originalUrl || req.url, status1 = Number(res.statusCode), statusColor = (status = status1) >= 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;
|
|
6798
|
-
|
|
6849
|
+
src_logger.debug(`${statusColor(status1)} ${method} ${url} ${color.dim(`${totalTime.toFixed(3)} ms`)}`);
|
|
6799
6850
|
}), next();
|
|
6800
6851
|
};
|
|
6801
6852
|
}, notFoundMiddleware = (_req, res, _next)=>{
|
|
@@ -6846,7 +6897,7 @@ init({
|
|
|
6846
6897
|
context,
|
|
6847
6898
|
changeOrigin: !0,
|
|
6848
6899
|
logLevel: 'warn',
|
|
6849
|
-
logProvider: ()=>
|
|
6900
|
+
logProvider: ()=>src_logger
|
|
6850
6901
|
};
|
|
6851
6902
|
'string' == typeof options ? opts.target = options : Object.assign(opts, options), ret.push(opts);
|
|
6852
6903
|
}
|
|
@@ -7209,7 +7260,7 @@ init({
|
|
|
7209
7260
|
}
|
|
7210
7261
|
async function devServer_createDevServer(options, createCompiler, config, { compiler: customCompiler, getPortSilently, runCompile = !0 } = {}) {
|
|
7211
7262
|
let lastStats, fileWatcher, devMiddlewares;
|
|
7212
|
-
|
|
7263
|
+
src_logger.debug('create dev server');
|
|
7213
7264
|
let { port, host, https, portTip } = await getServerConfig({
|
|
7214
7265
|
config
|
|
7215
7266
|
}), { middlewareMode } = config.server, { context } = options, routes = getRoutes(context), root = context.rootPath;
|
|
@@ -7282,7 +7333,7 @@ init({
|
|
|
7282
7333
|
});
|
|
7283
7334
|
context.hooks.onCloseDevServer.tap(cleanup);
|
|
7284
7335
|
}
|
|
7285
|
-
!getPortSilently && portTip &&
|
|
7336
|
+
!getPortSilently && portTip && src_logger.info(portTip);
|
|
7286
7337
|
}, cacheableLoadBundle = createCacheableFunction(loadBundle), cacheableTransformedHtml = createCacheableFunction((_stats, entryName, utils)=>((entryName, utils)=>{
|
|
7287
7338
|
let { htmlPaths, distPath } = utils.environment, htmlPath = htmlPaths[entryName];
|
|
7288
7339
|
if (!htmlPath) throw Error(`${color.dim('[rsbuild:getTransformedHtml]')} Failed to get HTML file by entryName: ${color.yellow(entryName)}`);
|
|
@@ -7327,13 +7378,13 @@ init({
|
|
|
7327
7378
|
listen: async ()=>{
|
|
7328
7379
|
if (!httpServer) throw Error(`${color.dim('[rsbuild:server]')} Can not listen dev server as ${color.yellow('server.middlewareMode')} is enabled.`);
|
|
7329
7380
|
let serverTerminator = getServerTerminator(httpServer);
|
|
7330
|
-
return
|
|
7381
|
+
return src_logger.debug('listen dev server'), context.hooks.onCloseDevServer.tap(serverTerminator), new Promise((resolve)=>{
|
|
7331
7382
|
httpServer.listen({
|
|
7332
7383
|
host,
|
|
7333
7384
|
port
|
|
7334
7385
|
}, async (err)=>{
|
|
7335
7386
|
if (err) throw err;
|
|
7336
|
-
middlewares.use(optionsFallbackMiddleware), middlewares.use(notFoundMiddleware), devMiddlewares && httpServer.on('upgrade', devMiddlewares.onUpgrade),
|
|
7387
|
+
middlewares.use(optionsFallbackMiddleware), middlewares.use(notFoundMiddleware), devMiddlewares && httpServer.on('upgrade', devMiddlewares.onUpgrade), src_logger.debug('listen dev server done'), await devServerAPI.afterListen(), onBeforeRestartServer(devServerAPI.close), resolve({
|
|
7337
7388
|
port,
|
|
7338
7389
|
urls: urls.map((item)=>item.url),
|
|
7339
7390
|
server: {
|
|
@@ -7368,7 +7419,7 @@ init({
|
|
|
7368
7419
|
root
|
|
7369
7420
|
}), (devMiddlewares = ((options)=>{
|
|
7370
7421
|
let middlewares = [], { buildManager } = options;
|
|
7371
|
-
|
|
7422
|
+
isVerbose() && middlewares.push(getRequestLoggerMiddleware());
|
|
7372
7423
|
let { before, after } = ((config, devServerAPI)=>{
|
|
7373
7424
|
let setupMiddlewares = config.dev.setupMiddlewares || [], serverOptions = pick(devServerAPI, [
|
|
7374
7425
|
'sockWrite',
|
|
@@ -7466,7 +7517,7 @@ init({
|
|
|
7466
7517
|
}
|
|
7467
7518
|
res.end('</body></html>');
|
|
7468
7519
|
} catch (err) {
|
|
7469
|
-
|
|
7520
|
+
src_logger.error(err), res.writeHead(500), res.end('Failed to list the files');
|
|
7470
7521
|
}
|
|
7471
7522
|
})({
|
|
7472
7523
|
environments: devServerAPI.environments
|
|
@@ -7505,7 +7556,7 @@ init({
|
|
|
7505
7556
|
let filePath = external_node_path_default().join(distPath, 'index.html');
|
|
7506
7557
|
if (await middlewares_isFileExists(filePath, buildManager.outputFileSystem)) {
|
|
7507
7558
|
let newUrl = '/index.html';
|
|
7508
|
-
|
|
7559
|
+
isVerbose() && src_logger.debug(` ${req.method} ${req.url} ${color.yellow('fallback to')} ${newUrl}`), req.url = newUrl, buildManager.assetsMiddleware(req, res, (...args)=>{
|
|
7509
7560
|
next(...args);
|
|
7510
7561
|
});
|
|
7511
7562
|
return;
|
|
@@ -7538,7 +7589,7 @@ init({
|
|
|
7538
7589
|
context,
|
|
7539
7590
|
postCallbacks
|
|
7540
7591
|
})).middlewares))Array.isArray(item) ? middlewares.use(...item) : middlewares.use(item);
|
|
7541
|
-
return buildManager?.watch(),
|
|
7592
|
+
return buildManager?.watch(), src_logger.debug('create dev server done'), devServerAPI;
|
|
7542
7593
|
}
|
|
7543
7594
|
let rspackProvider = ({ context, pluginManager, rsbuildOptions })=>{
|
|
7544
7595
|
let createCompiler = async ()=>(await createCompiler_createCompiler({
|
|
@@ -7617,7 +7668,7 @@ init({
|
|
|
7617
7668
|
}
|
|
7618
7669
|
async applyDefaultMiddlewares() {
|
|
7619
7670
|
let { headers, proxy, historyApiFallback, compress, base, cors } = this.options.serverConfig;
|
|
7620
|
-
if (
|
|
7671
|
+
if (isVerbose() && this.middlewares.use(getRequestLoggerMiddleware()), cors) {
|
|
7621
7672
|
let corsMiddleware = requireCompiledPackage('cors');
|
|
7622
7673
|
this.middlewares.use(corsMiddleware('boolean' == typeof cors ? {} : cors));
|
|
7623
7674
|
}
|
|
@@ -7720,7 +7771,7 @@ init({
|
|
|
7720
7771
|
customShortcuts: shortcutsOptions.custom
|
|
7721
7772
|
});
|
|
7722
7773
|
}
|
|
7723
|
-
!getPortSilently && portTip &&
|
|
7774
|
+
!getPortSilently && portTip && src_logger.info(portTip), resolve({
|
|
7724
7775
|
port,
|
|
7725
7776
|
urls: urls.map((item)=>item.url),
|
|
7726
7777
|
server: {
|
|
@@ -7736,7 +7787,7 @@ init({
|
|
|
7736
7787
|
{
|
|
7737
7788
|
name: 'rsbuild:basic',
|
|
7738
7789
|
setup (api) {
|
|
7739
|
-
api.modifyBundlerChain((chain, { isDev,
|
|
7790
|
+
api.modifyBundlerChain((chain, { isDev, target, bundler, environment, CHAIN_ID })=>{
|
|
7740
7791
|
let { config } = environment;
|
|
7741
7792
|
chain.name(environment.name), chain.context(api.context.rootPath), chain.mode(environment.config.mode), chain.infrastructureLogging({
|
|
7742
7793
|
level: 'error'
|
|
@@ -7750,7 +7801,7 @@ init({
|
|
|
7750
7801
|
javascript: {
|
|
7751
7802
|
typeReexportsPresence: 'tolerant'
|
|
7752
7803
|
}
|
|
7753
|
-
}), chain.
|
|
7804
|
+
}), chain.experiments({
|
|
7754
7805
|
...chain.get('experiments'),
|
|
7755
7806
|
rspackFuture: {
|
|
7756
7807
|
bundlerInfo: {
|
|
@@ -7791,39 +7842,20 @@ init({
|
|
|
7791
7842
|
{
|
|
7792
7843
|
name: 'rsbuild:source-map',
|
|
7793
7844
|
setup (api) {
|
|
7794
|
-
let DEFAULT_SOURCE_MAP_TEMPLATE = '[absolute-resource-path]', enableCssSourceMap = (config)=>{
|
|
7795
|
-
let { sourceMap } = config.output;
|
|
7796
|
-
return 'object' == typeof sourceMap && sourceMap.css;
|
|
7797
|
-
};
|
|
7798
7845
|
api.modifyBundlerChain((chain, { bundler, environment, isDev, target })=>{
|
|
7799
7846
|
let { config } = environment, devtool = ((config)=>{
|
|
7800
7847
|
let { sourceMap } = config.output, isProd = 'production' === config.mode;
|
|
7801
7848
|
return !1 !== sourceMap && (!0 === sourceMap ? isProd ? 'source-map' : 'cheap-module-source-map' : void 0 === sourceMap.js ? !isProd && 'cheap-module-source-map' : sourceMap.js);
|
|
7802
7849
|
})(config);
|
|
7803
|
-
chain.devtool(devtool), isDev && 'web' === target ? chain.output.devtoolModuleFilenameTemplate((info)=>toPosixPath(info.absoluteResourcePath)) : chain.output.devtoolModuleFilenameTemplate(
|
|
7850
|
+
chain.devtool(devtool), isDev && 'web' === target || 'webpack' === api.context.bundlerType ? chain.output.devtoolModuleFilenameTemplate((info)=>toPosixPath(info.absoluteResourcePath)) : chain.output.devtoolModuleFilenameTemplate('[relative-resource-path]'), !devtool && ((config)=>{
|
|
7851
|
+
let { sourceMap } = config.output;
|
|
7852
|
+
return 'object' == typeof sourceMap && sourceMap.css;
|
|
7853
|
+
})(config) && chain.plugin('source-map-css').use(bundler.SourceMapDevToolPlugin, [
|
|
7804
7854
|
{
|
|
7805
7855
|
test: /\.css$/,
|
|
7806
7856
|
filename: '[file].map[query]'
|
|
7807
7857
|
}
|
|
7808
7858
|
]);
|
|
7809
|
-
}), api.processAssets({
|
|
7810
|
-
stage: 'optimize-transfer'
|
|
7811
|
-
}, ({ assets, compilation, sources, environment })=>{
|
|
7812
|
-
if (!compilation.options.devtool && !enableCssSourceMap(environment.config) || compilation.outputOptions.devtoolModuleFilenameTemplate !== DEFAULT_SOURCE_MAP_TEMPLATE) return;
|
|
7813
|
-
let { distPath } = environment;
|
|
7814
|
-
for (let [filename, asset] of Object.entries(assets)){
|
|
7815
|
-
let map;
|
|
7816
|
-
if (!filename.endsWith('.map')) continue;
|
|
7817
|
-
let rawSource = asset.source();
|
|
7818
|
-
try {
|
|
7819
|
-
map = JSON.parse(Buffer.isBuffer(rawSource) ? rawSource.toString() : rawSource);
|
|
7820
|
-
} catch {
|
|
7821
|
-
continue;
|
|
7822
|
-
}
|
|
7823
|
-
if (!Array.isArray(map.sources)) continue;
|
|
7824
|
-
let mapDir = external_node_path_default().dirname(external_node_path_default().join(distPath, filename)), isSourcesUpdated = !1;
|
|
7825
|
-
map.sources = map.sources.map((source)=>external_node_path_default().isAbsolute(source) ? (isSourcesUpdated = !0, toPosixPath(external_node_path_default().relative(mapDir, source))) : source), isSourcesUpdated && compilation.updateAsset(filename, new sources.RawSource(JSON.stringify(map)));
|
|
7826
|
-
}
|
|
7827
7859
|
});
|
|
7828
7860
|
}
|
|
7829
7861
|
},
|
|
@@ -7856,7 +7888,7 @@ init({
|
|
|
7856
7888
|
buildDependencies
|
|
7857
7889
|
});
|
|
7858
7890
|
}), api.onAfterCreateCompiler(()=>{
|
|
7859
|
-
cacheEnabled && 'rspack' === api.context.bundlerType &&
|
|
7891
|
+
cacheEnabled && 'rspack' === api.context.bundlerType && src_logger.debug('Rspack persistent cache enabled');
|
|
7860
7892
|
});
|
|
7861
7893
|
}
|
|
7862
7894
|
},
|
|
@@ -7938,7 +7970,7 @@ init({
|
|
|
7938
7970
|
chain,
|
|
7939
7971
|
config,
|
|
7940
7972
|
rootPath: api.context.rootPath
|
|
7941
|
-
}), chain.module.rule(CHAIN_ID.RULE.MJS).test(/\.m?js/).resolve.set('fullySpecified', !1), config.source.aliasStrategy &&
|
|
7973
|
+
}), chain.module.rule(CHAIN_ID.RULE.MJS).test(/\.m?js/).resolve.set('fullySpecified', !1), config.source.aliasStrategy && src_logger.warn(`${color.dim('[rsbuild:config]')} The ${color.yellow('"source.aliasStrategy"')} config is deprecated, use ${color.yellow('"resolve.aliasStrategy"')} instead.`);
|
|
7942
7974
|
let aliasStrategy = config.source.aliasStrategy ?? config.resolve.aliasStrategy;
|
|
7943
7975
|
tsconfigPath && 'rspack' === api.context.bundlerType && 'prefer-tsconfig' === aliasStrategy && chain.resolve.tsConfig({
|
|
7944
7976
|
configFile: tsconfigPath,
|
|
@@ -7974,9 +8006,9 @@ init({
|
|
|
7974
8006
|
})(config), statsItem, api.context.rootPath, distPath, name, prevSnapshots);
|
|
7975
8007
|
return snapshot && (nextSnapshots[name] = snapshot), sizeLogs.join('\n');
|
|
7976
8008
|
})).catch((err)=>{
|
|
7977
|
-
|
|
8009
|
+
src_logger.warn('Failed to print file size.'), src_logger.warn(err);
|
|
7978
8010
|
});
|
|
7979
|
-
logs &&
|
|
8011
|
+
logs && src_logger.log(logs.join('\n')), showDiff && await saveSnapshots(snapshotPath, nextSnapshots);
|
|
7980
8012
|
});
|
|
7981
8013
|
}
|
|
7982
8014
|
}),
|
|
@@ -7990,7 +8022,7 @@ init({
|
|
|
7990
8022
|
return 'auto' === enable ? isDev && !config.dev.writeToDisk ? void 0 : isStrictSubdir(rootPath, distPath) ? {
|
|
7991
8023
|
path: distPath,
|
|
7992
8024
|
keep
|
|
7993
|
-
} : (
|
|
8025
|
+
} : (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 ? {
|
|
7994
8026
|
path: distPath,
|
|
7995
8027
|
keep
|
|
7996
8028
|
} : void 0;
|
|
@@ -8291,16 +8323,35 @@ init({
|
|
|
8291
8323
|
raw: !0
|
|
8292
8324
|
}, ({ code, emitFile, resourcePath })=>{
|
|
8293
8325
|
var resourcePath1;
|
|
8294
|
-
let name,
|
|
8295
|
-
if (null ===
|
|
8296
|
-
|
|
8326
|
+
let name, filename = (name = (resourcePath1 = resourcePath) && external_node_path_default().parse(resourcePath1).name) ? `${name}.node` : null;
|
|
8327
|
+
if (null === filename) throw Error(`${color.dim('[rsbuild:node-addons]')} Failed to load Node.js addon: ${color.yellow(resourcePath)}`);
|
|
8328
|
+
emitFile(filename, code);
|
|
8329
|
+
let config = api.getNormalizedConfig(), handleErrorSnippet = `throw new Error('Failed to load Node.js addon: "${filename}"', {
|
|
8330
|
+
cause: error,
|
|
8331
|
+
});`;
|
|
8332
|
+
return config.output.module ? `
|
|
8333
|
+
import path from "node:path";
|
|
8334
|
+
import { createRequire } from "node:module";
|
|
8335
|
+
import { fileURLToPath } from "node:url";
|
|
8336
|
+
|
|
8337
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
8338
|
+
const __dirname = path.dirname(__filename);
|
|
8339
|
+
const require = createRequire(import.meta.url);
|
|
8340
|
+
|
|
8341
|
+
let native;
|
|
8297
8342
|
try {
|
|
8298
|
-
|
|
8299
|
-
process.dlopen(module, path.join(__dirname, "${name1}"));
|
|
8343
|
+
native = require(path.join(__dirname, "${filename}"));
|
|
8300
8344
|
} catch (error) {
|
|
8301
|
-
|
|
8302
|
-
|
|
8303
|
-
|
|
8345
|
+
${handleErrorSnippet}
|
|
8346
|
+
}
|
|
8347
|
+
|
|
8348
|
+
export default native;
|
|
8349
|
+
` : `
|
|
8350
|
+
try {
|
|
8351
|
+
const path = __non_webpack_require__("node:path");
|
|
8352
|
+
module.exports = __non_webpack_require__(path.join(__dirname, "${filename}"));
|
|
8353
|
+
} catch (error) {
|
|
8354
|
+
${handleErrorSnippet}
|
|
8304
8355
|
}
|
|
8305
8356
|
`;
|
|
8306
8357
|
});
|
|
@@ -8591,7 +8642,7 @@ try {
|
|
|
8591
8642
|
...chain.output.get('library'),
|
|
8592
8643
|
type: 'module'
|
|
8593
8644
|
}), 'web-worker' === target) throw Error('[rsbuild:config] `output.module` is not supported for web-worker target.');
|
|
8594
|
-
chain.output.module(!0).chunkFormat('module').chunkLoading('import').workerChunkLoading('import'), chain.experiments({
|
|
8645
|
+
chain.node.set('__dirname', !1).set('__filename', !1), chain.output.module(!0).chunkFormat('module').chunkLoading('import').workerChunkLoading('import'), chain.experiments({
|
|
8595
8646
|
...chain.get('experiments'),
|
|
8596
8647
|
outputModule: !0
|
|
8597
8648
|
});
|
|
@@ -8719,19 +8770,19 @@ try {
|
|
|
8719
8770
|
]
|
|
8720
8771
|
});
|
|
8721
8772
|
} catch {
|
|
8722
|
-
|
|
8773
|
+
src_logger.warn(`\`process.env.RSDOCTOR\` enabled, please install ${color.bold(color.yellow(packageName))} package.`);
|
|
8723
8774
|
return;
|
|
8724
8775
|
}
|
|
8725
8776
|
try {
|
|
8726
8777
|
let moduleURL = isWindows ? (0, external_node_url_.pathToFileURL)(packagePath).href : packagePath;
|
|
8727
8778
|
module = await import(moduleURL);
|
|
8728
8779
|
} catch {
|
|
8729
|
-
|
|
8780
|
+
src_logger.error(`\`process.env.RSDOCTOR\` enabled, but failed to load ${color.bold(color.yellow(packageName))} module.`);
|
|
8730
8781
|
return;
|
|
8731
8782
|
}
|
|
8732
8783
|
if (module && module[pluginName]) {
|
|
8733
8784
|
for (let config of bundlerConfigs)config.plugins ||= [], config.plugins.push(new module[pluginName]());
|
|
8734
|
-
|
|
8785
|
+
src_logger.info(`${color.bold(color.yellow(packageName))} enabled.`);
|
|
8735
8786
|
}
|
|
8736
8787
|
});
|
|
8737
8788
|
}
|
|
@@ -8930,7 +8981,7 @@ try {
|
|
|
8930
8981
|
}), api.onAfterCreateCompiler(()=>{
|
|
8931
8982
|
if (manifestFilenames.size <= 1) return void manifestFilenames.clear();
|
|
8932
8983
|
let environmentNames = Array.from(manifestFilenames.keys()), filenames = Array.from(manifestFilenames.values());
|
|
8933
|
-
new Set(filenames).size !== filenames.length &&
|
|
8984
|
+
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();
|
|
8934
8985
|
});
|
|
8935
8986
|
}
|
|
8936
8987
|
},
|
|
@@ -8948,7 +8999,7 @@ try {
|
|
|
8948
8999
|
api.onBeforeBuild(async ({ isFirstCompile })=>{
|
|
8949
9000
|
isFirstCompile && await onStart();
|
|
8950
9001
|
}), api.onBeforeStartDevServer(onStart), api.onExit(()=>{
|
|
8951
|
-
traceOutput && (rspack_rspack.experiments.globalTrace.cleanup(),
|
|
9002
|
+
traceOutput && (rspack_rspack.experiments.globalTrace.cleanup(), src_logger.info(`profile file saved to ${color.cyan(traceOutput)}`));
|
|
8952
9003
|
});
|
|
8953
9004
|
}
|
|
8954
9005
|
},
|
|
@@ -8985,7 +9036,7 @@ try {
|
|
|
8985
9036
|
let crossorigin = chain.output.get('crossOriginLoading');
|
|
8986
9037
|
(!1 === crossorigin || void 0 === crossorigin) && chain.output.crossOriginLoading('anonymous');
|
|
8987
9038
|
let { algorithm = 'sha384' } = sri;
|
|
8988
|
-
chain.plugin(CHAIN_ID.PLUGIN.SUBRESOURCE_INTEGRITY).use(rspack.
|
|
9039
|
+
chain.plugin(CHAIN_ID.PLUGIN.SUBRESOURCE_INTEGRITY).use(rspack.SubresourceIntegrityPlugin, [
|
|
8989
9040
|
{
|
|
8990
9041
|
enabled: !0,
|
|
8991
9042
|
hashFuncNames: helpers_castArray(algorithm),
|
|
@@ -9048,7 +9099,7 @@ try {
|
|
|
9048
9099
|
cwd: options.cwd,
|
|
9049
9100
|
...'boolean' == typeof options.loadEnv ? {} : options.loadEnv
|
|
9050
9101
|
}) : null, configOrFactory = options.config ?? options.rsbuildConfig, config = isFunction(configOrFactory) ? await configOrFactory() : configOrFactory || {};
|
|
9051
|
-
config.logLevel && !isDebug() && (
|
|
9102
|
+
config.logLevel && !isDebug() && (src_logger.level = config.logLevel), applyEnvsToConfig(config, envs);
|
|
9052
9103
|
let resolvedOptions = {
|
|
9053
9104
|
cwd: process.cwd(),
|
|
9054
9105
|
callerName: 'rsbuild',
|
|
@@ -9060,7 +9111,7 @@ try {
|
|
|
9060
9111
|
});
|
|
9061
9112
|
context.getPluginAPI = getPluginAPI;
|
|
9062
9113
|
let globalPluginAPI = getPluginAPI();
|
|
9063
|
-
|
|
9114
|
+
src_logger.debug('registering default plugins'), applyDefaultPlugins(pluginManager, context), src_logger.debug('default plugins registered');
|
|
9064
9115
|
let provider = config.provider || rspackProvider, providerInstance = await provider({
|
|
9065
9116
|
context,
|
|
9066
9117
|
pluginManager,
|
|
@@ -9156,7 +9207,7 @@ try {
|
|
|
9156
9207
|
if (customConfig) {
|
|
9157
9208
|
let customConfigPath = (0, external_node_path_.isAbsolute)(customConfig) ? customConfig : (0, external_node_path_.join)(root, customConfig);
|
|
9158
9209
|
if (external_node_fs_default().existsSync(customConfigPath)) return customConfigPath;
|
|
9159
|
-
|
|
9210
|
+
throw Error(`${color.dim('[rsbuild:loadConfig]')} Cannot find config file: ${color.dim(customConfigPath)}`);
|
|
9160
9211
|
}
|
|
9161
9212
|
for (let file of [
|
|
9162
9213
|
'rsbuild.config.mjs',
|
|
@@ -9171,7 +9222,7 @@ try {
|
|
|
9171
9222
|
}
|
|
9172
9223
|
return null;
|
|
9173
9224
|
})(cwd, path);
|
|
9174
|
-
if (!configFilePath) return
|
|
9225
|
+
if (!configFilePath) return src_logger.debug('no config file found.'), {
|
|
9175
9226
|
content: {},
|
|
9176
9227
|
filePath: configFilePath
|
|
9177
9228
|
};
|
|
@@ -9183,8 +9234,8 @@ try {
|
|
|
9183
9234
|
configExport = exportModule.default ? exportModule.default : exportModule;
|
|
9184
9235
|
} catch (err) {
|
|
9185
9236
|
let errorMessage = `Failed to load file with native loader: ${color.dim(configFilePath)}`;
|
|
9186
|
-
if ('native' === loader) throw
|
|
9187
|
-
|
|
9237
|
+
if ('native' === loader) throw src_logger.error(errorMessage), err;
|
|
9238
|
+
src_logger.debug(`${errorMessage}, fallback to jiti.`), src_logger.debug(err);
|
|
9188
9239
|
}
|
|
9189
9240
|
if (void 0 === configExport) try {
|
|
9190
9241
|
let { createJiti } = await import("jiti"), jiti = createJiti(constants_filename, {
|
|
@@ -9199,7 +9250,7 @@ try {
|
|
|
9199
9250
|
default: !0
|
|
9200
9251
|
});
|
|
9201
9252
|
} catch (err) {
|
|
9202
|
-
throw
|
|
9253
|
+
throw src_logger.error(`Failed to load file with jiti: ${color.dim(configFilePath)}`), err;
|
|
9203
9254
|
}
|
|
9204
9255
|
if ('function' == typeof configExport) {
|
|
9205
9256
|
let command = process.argv[2], nodeEnv = process.env.NODE_ENV || '', result = await configExport({
|
|
@@ -9215,7 +9266,7 @@ try {
|
|
|
9215
9266
|
};
|
|
9216
9267
|
}
|
|
9217
9268
|
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)}`);
|
|
9218
|
-
return
|
|
9269
|
+
return src_logger.debug('configuration loaded from:', configFilePath), {
|
|
9219
9270
|
content: applyMetaInfo(configExport),
|
|
9220
9271
|
filePath: configFilePath
|
|
9221
9272
|
};
|
|
@@ -9268,7 +9319,7 @@ try {
|
|
|
9268
9319
|
});
|
|
9269
9320
|
}), rsbuild;
|
|
9270
9321
|
} catch (err) {
|
|
9271
|
-
if (isRestart)
|
|
9322
|
+
if (isRestart) src_logger.error(err);
|
|
9272
9323
|
else throw err;
|
|
9273
9324
|
}
|
|
9274
9325
|
}
|
|
@@ -9277,8 +9328,8 @@ try {
|
|
|
9277
9328
|
}, beforeRestart = async ({ filePath, clear = !0, id })=>{
|
|
9278
9329
|
if (clear && isTTY() && !process.env.DEBUG && process.stdout.write('\x1B[H\x1B[2J'), filePath) {
|
|
9279
9330
|
let filename = external_node_path_default().basename(filePath);
|
|
9280
|
-
|
|
9281
|
-
} else
|
|
9331
|
+
src_logger.info(`restarting ${id} as ${color.yellow(filename)} changed\n`);
|
|
9332
|
+
} else src_logger.info(`restarting ${id}...\n`);
|
|
9282
9333
|
for (let cleaner of cleaners)await cleaner();
|
|
9283
9334
|
cleaners = [];
|
|
9284
9335
|
}, restartDevServer = async ({ filePath, clear = !0 } = {})=>{
|
|
@@ -9316,7 +9367,7 @@ try {
|
|
|
9316
9367
|
filePath
|
|
9317
9368
|
}) : await restartDevServer({
|
|
9318
9369
|
filePath
|
|
9319
|
-
})) ? await watcher.close() :
|
|
9370
|
+
})) ? await watcher.close() : src_logger.error(isBuildWatch ? 'Restart build failed.' : 'Restart server failed.'), restarting = !1);
|
|
9320
9371
|
};
|
|
9321
9372
|
watcher.on('add', onChange), watcher.on('change', onChange), watcher.on('unlink', onChange);
|
|
9322
9373
|
}
|
|
@@ -9325,7 +9376,7 @@ try {
|
|
|
9325
9376
|
};
|
|
9326
9377
|
function setupCommands() {
|
|
9327
9378
|
let cli = ((name = "")=>new CAC(name))('rsbuild');
|
|
9328
|
-
cli.version("1.7.0-beta.
|
|
9379
|
+
cli.version("1.7.0-beta.2"), 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)', {
|
|
9329
9380
|
default: 'auto'
|
|
9330
9381
|
}).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', {
|
|
9331
9382
|
type: [
|
|
@@ -9341,7 +9392,7 @@ try {
|
|
|
9341
9392
|
});
|
|
9342
9393
|
await rsbuild?.startDevServer();
|
|
9343
9394
|
} catch (err) {
|
|
9344
|
-
|
|
9395
|
+
src_logger.error('Failed to start dev server.'), src_logger.error(err), process.exit(1);
|
|
9345
9396
|
}
|
|
9346
9397
|
}), buildCommand.option('-w, --watch', 'Enable watch mode to automatically rebuild on file changes').action(async (options)=>{
|
|
9347
9398
|
try {
|
|
@@ -9354,7 +9405,7 @@ try {
|
|
|
9354
9405
|
});
|
|
9355
9406
|
buildInstance && (options.watch ? onBeforeRestartServer(buildInstance.close) : await buildInstance.close());
|
|
9356
9407
|
} catch (err) {
|
|
9357
|
-
err instanceof Error && err.message === RSPACK_BUILD_ERROR ||
|
|
9408
|
+
err instanceof Error && err.message === RSPACK_BUILD_ERROR || src_logger.error('Failed to build.'), src_logger.error(err), process.exit(1);
|
|
9358
9409
|
}
|
|
9359
9410
|
}), previewCommand.action(async (options)=>{
|
|
9360
9411
|
try {
|
|
@@ -9363,7 +9414,7 @@ try {
|
|
|
9363
9414
|
});
|
|
9364
9415
|
await rsbuild?.preview();
|
|
9365
9416
|
} catch (err) {
|
|
9366
|
-
|
|
9417
|
+
src_logger.error('Failed to start preview server.'), src_logger.error(err), process.exit(1);
|
|
9367
9418
|
}
|
|
9368
9419
|
}), inspectCommand.option('--output <output>', 'Set the output path for inspection results').option('--verbose', 'Show complete function definitions in output').action(async (options)=>{
|
|
9369
9420
|
try {
|
|
@@ -9376,7 +9427,7 @@ try {
|
|
|
9376
9427
|
writeToDisk: !0
|
|
9377
9428
|
});
|
|
9378
9429
|
} catch (err) {
|
|
9379
|
-
|
|
9430
|
+
src_logger.error('Failed to inspect config.'), src_logger.error(err), process.exit(1);
|
|
9380
9431
|
}
|
|
9381
9432
|
}), cli.help((sections)=>{
|
|
9382
9433
|
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 = color.cyan(section.title);
|
|
@@ -9394,7 +9445,7 @@ try {
|
|
|
9394
9445
|
}
|
|
9395
9446
|
function showGreeting() {
|
|
9396
9447
|
let { npm_execpath, npm_lifecycle_event, NODE_RUN_SCRIPT_NAME } = process.env, isBun = npm_execpath?.includes('.bun');
|
|
9397
|
-
|
|
9448
|
+
src_logger.greet(`${'npx' === npm_lifecycle_event || isBun || NODE_RUN_SCRIPT_NAME ? '\n' : ''}Rsbuild v1.7.0-beta.2\n`);
|
|
9398
9449
|
}
|
|
9399
9450
|
function setupLogLevel() {
|
|
9400
9451
|
let logLevelIndex = process.argv.findIndex((item)=>'--log-level' === item || '--logLevel' === item);
|
|
@@ -9404,7 +9455,7 @@ try {
|
|
|
9404
9455
|
'warn',
|
|
9405
9456
|
'error',
|
|
9406
9457
|
'silent'
|
|
9407
|
-
].includes(level) && !isDebug() && (
|
|
9458
|
+
].includes(level) && !isDebug() && (src_logger.level = level);
|
|
9408
9459
|
}
|
|
9409
9460
|
}
|
|
9410
9461
|
function runCLI() {
|
|
@@ -9412,10 +9463,10 @@ try {
|
|
|
9412
9463
|
try {
|
|
9413
9464
|
setupCommands();
|
|
9414
9465
|
} catch (err) {
|
|
9415
|
-
|
|
9466
|
+
src_logger.error('Failed to start Rsbuild CLI.'), src_logger.error(err);
|
|
9416
9467
|
}
|
|
9417
9468
|
}
|
|
9418
|
-
let src_version = "1.7.0-beta.
|
|
9469
|
+
let src_version = "1.7.0-beta.2";
|
|
9419
9470
|
})(), exports.PLUGIN_CSS_NAME = __webpack_exports__.PLUGIN_CSS_NAME, exports.PLUGIN_SWC_NAME = __webpack_exports__.PLUGIN_SWC_NAME, exports.createRsbuild = __webpack_exports__.createRsbuild, exports.defaultAllowedOrigins = __webpack_exports__.defaultAllowedOrigins, exports.defineConfig = __webpack_exports__.defineConfig, exports.ensureAssetPrefix = __webpack_exports__.ensureAssetPrefix, exports.loadConfig = __webpack_exports__.loadConfig, exports.loadEnv = __webpack_exports__.loadEnv, exports.logger = __webpack_exports__.logger, exports.mergeRsbuildConfig = __webpack_exports__.mergeRsbuildConfig, exports.rspack = __webpack_exports__.rspack, exports.runCLI = __webpack_exports__.runCLI, exports.version = __webpack_exports__.version, __webpack_exports__)-1 === [
|
|
9420
9471
|
"PLUGIN_CSS_NAME",
|
|
9421
9472
|
"PLUGIN_SWC_NAME",
|