@rsbuild/core 1.7.0-beta.0 → 1.7.0-beta.1
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 +317 -292
- package/dist/2~open.cjs +1 -1
- package/dist/2~range-parser.cjs +1 -1
- package/dist/client/hmr.js +17 -3
- package/dist/client/overlay.js +138 -4
- package/dist/ignoreCssLoader.mjs +1 -1
- package/dist/index.cjs +322 -291
- package/dist/rslib-runtime.js +1 -1
- package/dist/transformRawLoader.mjs +1 -1
- package/dist-types/client/hmr.d.ts +1 -1
- package/dist-types/helpers/vendors.d.ts +0 -1
- package/dist-types/logger.d.ts +1 -2
- 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/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 [
|
|
@@ -1118,9 +1295,9 @@ for(var __rspack_i in (()=>{
|
|
|
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 && 'verbose' !==
|
|
2691
|
+
return trace.length > 4 && 'verbose' !== src_logger.level && (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 = 'verbose' ===
|
|
2571
|
-
if (verbose && (stats.details && (message += `\nDetails: ${stats.details}\n`), stats.stack && (message += `\n${stats.stack}`)), 'error' === level || 'verbose' ===
|
|
2747
|
+
})(fileName, stats, root)}${stats.message}`, verbose = 'verbose' === src_logger.level;
|
|
2748
|
+
if (verbose && (stats.details && (message += `\nDetails: ${stats.details}\n`), stats.stack && (message += `\n${stats.stack}`)), 'error' === level || 'verbose' === src_logger.level) {
|
|
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: 'verbose' ===
|
|
2837
|
+
errorStack: 'verbose' === src_logger.level
|
|
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)=>'verbose' ===
|
|
2875
|
+
let removeLoaderChainDelimiter = (moduleId)=>'verbose' === src_logger.level ? 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.1",
|
|
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();
|
|
@@ -6097,7 +6272,7 @@ init({
|
|
|
6097
6272
|
else {
|
|
6098
6273
|
let watchOptions = compilers.length > 1 ? compilers.map(({ options })=>options.watchOptions || {}) : compilers[0].options.watchOptions || {};
|
|
6099
6274
|
watching = compiler.watch(watchOptions, (error)=>{
|
|
6100
|
-
error && (error.message?.includes('× Error:') && (error.message = error.message.replace('× Error:', '').trim()),
|
|
6275
|
+
error && (error.message?.includes('× Error:') && (error.message = error.message.replace('× Error:', '').trim()), src_logger.error(error));
|
|
6101
6276
|
});
|
|
6102
6277
|
}
|
|
6103
6278
|
}, instance.close = (callback = noop)=>{
|
|
@@ -6191,7 +6366,7 @@ init({
|
|
|
6191
6366
|
originalPosition: getOriginalPosition(sourceMap.toString(), lineNumber ?? 0, column ?? 0)
|
|
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
6371
|
}, resolveOriginalLocation = async (stack, fs, context)=>{
|
|
6197
6372
|
let parsed = stack_trace_parser_esm_parse(stack);
|
|
@@ -6309,141 +6484,6 @@ init({
|
|
|
6309
6484
|
return replacedLine = replacedLine.replace(URL_RE, (url)=>`<a class="url-link" href="${url}" target="_blank" rel="noopener noreferrer">${url}</a>`);
|
|
6310
6485
|
}).join('\n');
|
|
6311
6486
|
}
|
|
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
6487
|
function isEqualSet(a, b) {
|
|
6448
6488
|
return a.size === b.size && [
|
|
6449
6489
|
...a
|
|
@@ -6487,7 +6527,7 @@ init({
|
|
|
6487
6527
|
noServer: !0,
|
|
6488
6528
|
path: this.options.client?.path
|
|
6489
6529
|
}), this.wsServer.on('error', (err)=>{
|
|
6490
|
-
|
|
6530
|
+
src_logger.error(err);
|
|
6491
6531
|
}), this.heartbeatTimer = setTimeout(this.checkSockets, 30000).unref(), this.wsServer.on('connection', (socket, req)=>{
|
|
6492
6532
|
let query = parseQueryString(req);
|
|
6493
6533
|
this.onConnect(socket, query.token);
|
|
@@ -6499,12 +6539,15 @@ init({
|
|
|
6499
6539
|
});
|
|
6500
6540
|
}
|
|
6501
6541
|
sendError(errors, token) {
|
|
6502
|
-
let formattedErrors = errors.map((item)=>formatStatsError(item,
|
|
6542
|
+
let { rootPath } = this.context, formattedErrors = errors.map((item)=>formatStatsError(item, rootPath)), html = formattedErrors.map((error)=>{
|
|
6543
|
+
var error1, root;
|
|
6544
|
+
return error1 = error, root = rootPath, convertLinksInHtml(ansiHTML(escapeHtml(error1)), root);
|
|
6545
|
+
}).join('\n\n').trim();
|
|
6503
6546
|
this.sockWrite({
|
|
6504
6547
|
type: 'errors',
|
|
6505
6548
|
data: {
|
|
6506
6549
|
text: formattedErrors,
|
|
6507
|
-
html
|
|
6550
|
+
html
|
|
6508
6551
|
}
|
|
6509
6552
|
}, token);
|
|
6510
6553
|
}
|
|
@@ -6542,12 +6585,19 @@ init({
|
|
|
6542
6585
|
socket.isAlive = !0;
|
|
6543
6586
|
}), socket.on('message', async (data)=>{
|
|
6544
6587
|
try {
|
|
6545
|
-
let message = JSON.parse('string' == typeof data ? data : data.toString()), config =
|
|
6588
|
+
let message = JSON.parse('string' == typeof data ? data : data.toString()), { context } = this, config = context.normalizedConfig;
|
|
6546
6589
|
if (!config) return;
|
|
6547
|
-
let { browserLogs } = config.dev;
|
|
6548
|
-
if ('client-error' === message.type && 'rspack' ===
|
|
6549
|
-
|
|
6550
|
-
|
|
6590
|
+
let { browserLogs, client } = config.dev;
|
|
6591
|
+
if ('client-error' === message.type && 'rspack' === context.bundlerType && !context.buildState.hasErrors && browserLogs) {
|
|
6592
|
+
var error;
|
|
6593
|
+
let stackTrace = isObject(browserLogs) && browserLogs.stackTrace || DEFAULT_STACK_TRACE, log = await formatBrowserErrorLog(message, context, this.getOutputFileSystem(), stackTrace);
|
|
6594
|
+
this.reportedBrowserLogs.has(log) || (this.reportedBrowserLogs.add(log), src_logger.error(log)), 'object' == typeof client.overlay && client.overlay.runtime && this.sockWrite({
|
|
6595
|
+
type: 'resolved-client-error',
|
|
6596
|
+
data: {
|
|
6597
|
+
id: message.id,
|
|
6598
|
+
message: (error = log, convertLinksInHtml(ansiHTML(escapeHtml(error)), void 0))
|
|
6599
|
+
}
|
|
6600
|
+
}, token);
|
|
6551
6601
|
}
|
|
6552
6602
|
} catch {}
|
|
6553
6603
|
});
|
|
@@ -6684,7 +6734,7 @@ init({
|
|
|
6684
6734
|
}
|
|
6685
6735
|
].filter(Boolean);
|
|
6686
6736
|
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 &&
|
|
6737
|
+
help && src_logger.log(!0 === help ? ` ➜ ${color.dim('press')} ${color.bold('h + enter')} ${color.dim('to show shortcuts')}\n` : ` ➜ ${help}\n`);
|
|
6688
6738
|
let { createInterface } = await import("node:readline"), rl = createInterface({
|
|
6689
6739
|
input: process.stdin
|
|
6690
6740
|
});
|
|
@@ -6692,7 +6742,7 @@ init({
|
|
|
6692
6742
|
if ('h' === input) {
|
|
6693
6743
|
let message = `\n ${color.bold(color.blue('Shortcuts:'))}\n`;
|
|
6694
6744
|
for (let shortcut of shortcuts)message += ` ${shortcut.description}\n`;
|
|
6695
|
-
|
|
6745
|
+
src_logger.log(message);
|
|
6696
6746
|
}
|
|
6697
6747
|
for (let shortcut of shortcuts)if (input === shortcut.key) return void shortcut.action();
|
|
6698
6748
|
}), ()=>{
|
|
@@ -6738,15 +6788,15 @@ init({
|
|
|
6738
6788
|
let rewriteTarget, { headers } = req;
|
|
6739
6789
|
if (!req.url) return void next();
|
|
6740
6790
|
if ('GET' !== req.method && 'HEAD' !== req.method) {
|
|
6741
|
-
|
|
6791
|
+
src_logger.debug('Not rewriting', req.method, req.url, 'because the method is not GET or HEAD.'), next();
|
|
6742
6792
|
return;
|
|
6743
6793
|
}
|
|
6744
6794
|
if (!headers || 'string' != typeof headers.accept) {
|
|
6745
|
-
|
|
6795
|
+
src_logger.debug('Not rewriting', req.method, req.url, 'because the client did not send an HTTP accept header.'), next();
|
|
6746
6796
|
return;
|
|
6747
6797
|
}
|
|
6748
6798
|
if (0 === headers.accept.indexOf('application/json')) {
|
|
6749
|
-
|
|
6799
|
+
src_logger.debug('Not rewriting', req.method, req.url, 'because the client prefers JSON.'), next();
|
|
6750
6800
|
return;
|
|
6751
6801
|
}
|
|
6752
6802
|
let rewrites = options.rewrites || [], htmlAcceptHeaders = options.htmlAcceptHeaders || [
|
|
@@ -6754,7 +6804,7 @@ init({
|
|
|
6754
6804
|
'*/*'
|
|
6755
6805
|
], { accept } = headers;
|
|
6756
6806
|
if (!htmlAcceptHeaders.some((item)=>accept.includes(item))) {
|
|
6757
|
-
|
|
6807
|
+
src_logger.debug('Not rewriting', req.method, req.url, 'because the client does not accept HTML.'), next();
|
|
6758
6808
|
return;
|
|
6759
6809
|
}
|
|
6760
6810
|
let parsedUrl = parseReqUrl(req);
|
|
@@ -6767,16 +6817,16 @@ init({
|
|
|
6767
6817
|
parsedUrl,
|
|
6768
6818
|
match,
|
|
6769
6819
|
request: req
|
|
6770
|
-
})).charAt(0) &&
|
|
6820
|
+
})).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
6821
|
return;
|
|
6772
6822
|
}
|
|
6773
6823
|
let { pathname } = parsedUrl;
|
|
6774
6824
|
if (pathname && pathname.lastIndexOf('.') > pathname.lastIndexOf('/') && !0 !== options.disableDotRule) {
|
|
6775
|
-
|
|
6825
|
+
src_logger.debug('Not rewriting', req.method, req.url, 'because the path includes a dot (.) character.'), next();
|
|
6776
6826
|
return;
|
|
6777
6827
|
}
|
|
6778
6828
|
let index = options.index || '/index.html';
|
|
6779
|
-
|
|
6829
|
+
src_logger.debug('Rewriting', req.method, req.url, 'to', index), req.url = index, next();
|
|
6780
6830
|
};
|
|
6781
6831
|
}
|
|
6782
6832
|
function parseReqUrl(req) {
|
|
@@ -6795,7 +6845,7 @@ init({
|
|
|
6795
6845
|
on_finished_default()(res, ()=>{
|
|
6796
6846
|
var status;
|
|
6797
6847
|
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
|
-
|
|
6848
|
+
src_logger.debug(`${statusColor(status1)} ${method} ${url} ${color.dim(`${totalTime.toFixed(3)} ms`)}`);
|
|
6799
6849
|
}), next();
|
|
6800
6850
|
};
|
|
6801
6851
|
}, notFoundMiddleware = (_req, res, _next)=>{
|
|
@@ -6846,7 +6896,7 @@ init({
|
|
|
6846
6896
|
context,
|
|
6847
6897
|
changeOrigin: !0,
|
|
6848
6898
|
logLevel: 'warn',
|
|
6849
|
-
logProvider: ()=>
|
|
6899
|
+
logProvider: ()=>src_logger
|
|
6850
6900
|
};
|
|
6851
6901
|
'string' == typeof options ? opts.target = options : Object.assign(opts, options), ret.push(opts);
|
|
6852
6902
|
}
|
|
@@ -7209,7 +7259,7 @@ init({
|
|
|
7209
7259
|
}
|
|
7210
7260
|
async function devServer_createDevServer(options, createCompiler, config, { compiler: customCompiler, getPortSilently, runCompile = !0 } = {}) {
|
|
7211
7261
|
let lastStats, fileWatcher, devMiddlewares;
|
|
7212
|
-
|
|
7262
|
+
src_logger.debug('create dev server');
|
|
7213
7263
|
let { port, host, https, portTip } = await getServerConfig({
|
|
7214
7264
|
config
|
|
7215
7265
|
}), { middlewareMode } = config.server, { context } = options, routes = getRoutes(context), root = context.rootPath;
|
|
@@ -7282,7 +7332,7 @@ init({
|
|
|
7282
7332
|
});
|
|
7283
7333
|
context.hooks.onCloseDevServer.tap(cleanup);
|
|
7284
7334
|
}
|
|
7285
|
-
!getPortSilently && portTip &&
|
|
7335
|
+
!getPortSilently && portTip && src_logger.info(portTip);
|
|
7286
7336
|
}, cacheableLoadBundle = createCacheableFunction(loadBundle), cacheableTransformedHtml = createCacheableFunction((_stats, entryName, utils)=>((entryName, utils)=>{
|
|
7287
7337
|
let { htmlPaths, distPath } = utils.environment, htmlPath = htmlPaths[entryName];
|
|
7288
7338
|
if (!htmlPath) throw Error(`${color.dim('[rsbuild:getTransformedHtml]')} Failed to get HTML file by entryName: ${color.yellow(entryName)}`);
|
|
@@ -7327,13 +7377,13 @@ init({
|
|
|
7327
7377
|
listen: async ()=>{
|
|
7328
7378
|
if (!httpServer) throw Error(`${color.dim('[rsbuild:server]')} Can not listen dev server as ${color.yellow('server.middlewareMode')} is enabled.`);
|
|
7329
7379
|
let serverTerminator = getServerTerminator(httpServer);
|
|
7330
|
-
return
|
|
7380
|
+
return src_logger.debug('listen dev server'), context.hooks.onCloseDevServer.tap(serverTerminator), new Promise((resolve)=>{
|
|
7331
7381
|
httpServer.listen({
|
|
7332
7382
|
host,
|
|
7333
7383
|
port
|
|
7334
7384
|
}, async (err)=>{
|
|
7335
7385
|
if (err) throw err;
|
|
7336
|
-
middlewares.use(optionsFallbackMiddleware), middlewares.use(notFoundMiddleware), devMiddlewares && httpServer.on('upgrade', devMiddlewares.onUpgrade),
|
|
7386
|
+
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
7387
|
port,
|
|
7338
7388
|
urls: urls.map((item)=>item.url),
|
|
7339
7389
|
server: {
|
|
@@ -7368,7 +7418,7 @@ init({
|
|
|
7368
7418
|
root
|
|
7369
7419
|
}), (devMiddlewares = ((options)=>{
|
|
7370
7420
|
let middlewares = [], { buildManager } = options;
|
|
7371
|
-
'verbose' ===
|
|
7421
|
+
'verbose' === src_logger.level && middlewares.push(getRequestLoggerMiddleware());
|
|
7372
7422
|
let { before, after } = ((config, devServerAPI)=>{
|
|
7373
7423
|
let setupMiddlewares = config.dev.setupMiddlewares || [], serverOptions = pick(devServerAPI, [
|
|
7374
7424
|
'sockWrite',
|
|
@@ -7466,7 +7516,7 @@ init({
|
|
|
7466
7516
|
}
|
|
7467
7517
|
res.end('</body></html>');
|
|
7468
7518
|
} catch (err) {
|
|
7469
|
-
|
|
7519
|
+
src_logger.error(err), res.writeHead(500), res.end('Failed to list the files');
|
|
7470
7520
|
}
|
|
7471
7521
|
})({
|
|
7472
7522
|
environments: devServerAPI.environments
|
|
@@ -7505,7 +7555,7 @@ init({
|
|
|
7505
7555
|
let filePath = external_node_path_default().join(distPath, 'index.html');
|
|
7506
7556
|
if (await middlewares_isFileExists(filePath, buildManager.outputFileSystem)) {
|
|
7507
7557
|
let newUrl = '/index.html';
|
|
7508
|
-
'verbose' ===
|
|
7558
|
+
'verbose' === src_logger.level && src_logger.debug(` ${req.method} ${req.url} ${color.yellow('fallback to')} ${newUrl}`), req.url = newUrl, buildManager.assetsMiddleware(req, res, (...args)=>{
|
|
7509
7559
|
next(...args);
|
|
7510
7560
|
});
|
|
7511
7561
|
return;
|
|
@@ -7538,7 +7588,7 @@ init({
|
|
|
7538
7588
|
context,
|
|
7539
7589
|
postCallbacks
|
|
7540
7590
|
})).middlewares))Array.isArray(item) ? middlewares.use(...item) : middlewares.use(item);
|
|
7541
|
-
return buildManager?.watch(),
|
|
7591
|
+
return buildManager?.watch(), src_logger.debug('create dev server done'), devServerAPI;
|
|
7542
7592
|
}
|
|
7543
7593
|
let rspackProvider = ({ context, pluginManager, rsbuildOptions })=>{
|
|
7544
7594
|
let createCompiler = async ()=>(await createCompiler_createCompiler({
|
|
@@ -7617,7 +7667,7 @@ init({
|
|
|
7617
7667
|
}
|
|
7618
7668
|
async applyDefaultMiddlewares() {
|
|
7619
7669
|
let { headers, proxy, historyApiFallback, compress, base, cors } = this.options.serverConfig;
|
|
7620
|
-
if ('verbose' ===
|
|
7670
|
+
if ('verbose' === src_logger.level && this.middlewares.use(getRequestLoggerMiddleware()), cors) {
|
|
7621
7671
|
let corsMiddleware = requireCompiledPackage('cors');
|
|
7622
7672
|
this.middlewares.use(corsMiddleware('boolean' == typeof cors ? {} : cors));
|
|
7623
7673
|
}
|
|
@@ -7720,7 +7770,7 @@ init({
|
|
|
7720
7770
|
customShortcuts: shortcutsOptions.custom
|
|
7721
7771
|
});
|
|
7722
7772
|
}
|
|
7723
|
-
!getPortSilently && portTip &&
|
|
7773
|
+
!getPortSilently && portTip && src_logger.info(portTip), resolve({
|
|
7724
7774
|
port,
|
|
7725
7775
|
urls: urls.map((item)=>item.url),
|
|
7726
7776
|
server: {
|
|
@@ -7736,7 +7786,7 @@ init({
|
|
|
7736
7786
|
{
|
|
7737
7787
|
name: 'rsbuild:basic',
|
|
7738
7788
|
setup (api) {
|
|
7739
|
-
api.modifyBundlerChain((chain, { isDev,
|
|
7789
|
+
api.modifyBundlerChain((chain, { isDev, target, bundler, environment, CHAIN_ID })=>{
|
|
7740
7790
|
let { config } = environment;
|
|
7741
7791
|
chain.name(environment.name), chain.context(api.context.rootPath), chain.mode(environment.config.mode), chain.infrastructureLogging({
|
|
7742
7792
|
level: 'error'
|
|
@@ -7750,7 +7800,7 @@ init({
|
|
|
7750
7800
|
javascript: {
|
|
7751
7801
|
typeReexportsPresence: 'tolerant'
|
|
7752
7802
|
}
|
|
7753
|
-
}), chain.
|
|
7803
|
+
}), chain.experiments({
|
|
7754
7804
|
...chain.get('experiments'),
|
|
7755
7805
|
rspackFuture: {
|
|
7756
7806
|
bundlerInfo: {
|
|
@@ -7791,39 +7841,20 @@ init({
|
|
|
7791
7841
|
{
|
|
7792
7842
|
name: 'rsbuild:source-map',
|
|
7793
7843
|
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
7844
|
api.modifyBundlerChain((chain, { bundler, environment, isDev, target })=>{
|
|
7799
7845
|
let { config } = environment, devtool = ((config)=>{
|
|
7800
7846
|
let { sourceMap } = config.output, isProd = 'production' === config.mode;
|
|
7801
7847
|
return !1 !== sourceMap && (!0 === sourceMap ? isProd ? 'source-map' : 'cheap-module-source-map' : void 0 === sourceMap.js ? !isProd && 'cheap-module-source-map' : sourceMap.js);
|
|
7802
7848
|
})(config);
|
|
7803
|
-
chain.devtool(devtool), isDev && 'web' === target ? chain.output.devtoolModuleFilenameTemplate((info)=>toPosixPath(info.absoluteResourcePath)) : chain.output.devtoolModuleFilenameTemplate(
|
|
7849
|
+
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)=>{
|
|
7850
|
+
let { sourceMap } = config.output;
|
|
7851
|
+
return 'object' == typeof sourceMap && sourceMap.css;
|
|
7852
|
+
})(config) && chain.plugin('source-map-css').use(bundler.SourceMapDevToolPlugin, [
|
|
7804
7853
|
{
|
|
7805
7854
|
test: /\.css$/,
|
|
7806
7855
|
filename: '[file].map[query]'
|
|
7807
7856
|
}
|
|
7808
7857
|
]);
|
|
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
7858
|
});
|
|
7828
7859
|
}
|
|
7829
7860
|
},
|
|
@@ -7856,7 +7887,7 @@ init({
|
|
|
7856
7887
|
buildDependencies
|
|
7857
7888
|
});
|
|
7858
7889
|
}), api.onAfterCreateCompiler(()=>{
|
|
7859
|
-
cacheEnabled && 'rspack' === api.context.bundlerType &&
|
|
7890
|
+
cacheEnabled && 'rspack' === api.context.bundlerType && src_logger.debug('Rspack persistent cache enabled');
|
|
7860
7891
|
});
|
|
7861
7892
|
}
|
|
7862
7893
|
},
|
|
@@ -7938,7 +7969,7 @@ init({
|
|
|
7938
7969
|
chain,
|
|
7939
7970
|
config,
|
|
7940
7971
|
rootPath: api.context.rootPath
|
|
7941
|
-
}), chain.module.rule(CHAIN_ID.RULE.MJS).test(/\.m?js/).resolve.set('fullySpecified', !1), config.source.aliasStrategy &&
|
|
7972
|
+
}), 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
7973
|
let aliasStrategy = config.source.aliasStrategy ?? config.resolve.aliasStrategy;
|
|
7943
7974
|
tsconfigPath && 'rspack' === api.context.bundlerType && 'prefer-tsconfig' === aliasStrategy && chain.resolve.tsConfig({
|
|
7944
7975
|
configFile: tsconfigPath,
|
|
@@ -7974,9 +8005,9 @@ init({
|
|
|
7974
8005
|
})(config), statsItem, api.context.rootPath, distPath, name, prevSnapshots);
|
|
7975
8006
|
return snapshot && (nextSnapshots[name] = snapshot), sizeLogs.join('\n');
|
|
7976
8007
|
})).catch((err)=>{
|
|
7977
|
-
|
|
8008
|
+
src_logger.warn('Failed to print file size.'), src_logger.warn(err);
|
|
7978
8009
|
});
|
|
7979
|
-
logs &&
|
|
8010
|
+
logs && src_logger.log(logs.join('\n')), showDiff && await saveSnapshots(snapshotPath, nextSnapshots);
|
|
7980
8011
|
});
|
|
7981
8012
|
}
|
|
7982
8013
|
}),
|
|
@@ -7990,7 +8021,7 @@ init({
|
|
|
7990
8021
|
return 'auto' === enable ? isDev && !config.dev.writeToDisk ? void 0 : isStrictSubdir(rootPath, distPath) ? {
|
|
7991
8022
|
path: distPath,
|
|
7992
8023
|
keep
|
|
7993
|
-
} : (
|
|
8024
|
+
} : (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
8025
|
path: distPath,
|
|
7995
8026
|
keep
|
|
7996
8027
|
} : void 0;
|
|
@@ -8591,7 +8622,7 @@ try {
|
|
|
8591
8622
|
...chain.output.get('library'),
|
|
8592
8623
|
type: 'module'
|
|
8593
8624
|
}), '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({
|
|
8625
|
+
chain.node.set('__dirname', !1).set('__filename', !1), chain.output.module(!0).chunkFormat('module').chunkLoading('import').workerChunkLoading('import'), chain.experiments({
|
|
8595
8626
|
...chain.get('experiments'),
|
|
8596
8627
|
outputModule: !0
|
|
8597
8628
|
});
|
|
@@ -8719,19 +8750,19 @@ try {
|
|
|
8719
8750
|
]
|
|
8720
8751
|
});
|
|
8721
8752
|
} catch {
|
|
8722
|
-
|
|
8753
|
+
src_logger.warn(`\`process.env.RSDOCTOR\` enabled, please install ${color.bold(color.yellow(packageName))} package.`);
|
|
8723
8754
|
return;
|
|
8724
8755
|
}
|
|
8725
8756
|
try {
|
|
8726
8757
|
let moduleURL = isWindows ? (0, external_node_url_.pathToFileURL)(packagePath).href : packagePath;
|
|
8727
8758
|
module = await import(moduleURL);
|
|
8728
8759
|
} catch {
|
|
8729
|
-
|
|
8760
|
+
src_logger.error(`\`process.env.RSDOCTOR\` enabled, but failed to load ${color.bold(color.yellow(packageName))} module.`);
|
|
8730
8761
|
return;
|
|
8731
8762
|
}
|
|
8732
8763
|
if (module && module[pluginName]) {
|
|
8733
8764
|
for (let config of bundlerConfigs)config.plugins ||= [], config.plugins.push(new module[pluginName]());
|
|
8734
|
-
|
|
8765
|
+
src_logger.info(`${color.bold(color.yellow(packageName))} enabled.`);
|
|
8735
8766
|
}
|
|
8736
8767
|
});
|
|
8737
8768
|
}
|
|
@@ -8930,7 +8961,7 @@ try {
|
|
|
8930
8961
|
}), api.onAfterCreateCompiler(()=>{
|
|
8931
8962
|
if (manifestFilenames.size <= 1) return void manifestFilenames.clear();
|
|
8932
8963
|
let environmentNames = Array.from(manifestFilenames.keys()), filenames = Array.from(manifestFilenames.values());
|
|
8933
|
-
new Set(filenames).size !== filenames.length &&
|
|
8964
|
+
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
8965
|
});
|
|
8935
8966
|
}
|
|
8936
8967
|
},
|
|
@@ -8948,7 +8979,7 @@ try {
|
|
|
8948
8979
|
api.onBeforeBuild(async ({ isFirstCompile })=>{
|
|
8949
8980
|
isFirstCompile && await onStart();
|
|
8950
8981
|
}), api.onBeforeStartDevServer(onStart), api.onExit(()=>{
|
|
8951
|
-
traceOutput && (rspack_rspack.experiments.globalTrace.cleanup(),
|
|
8982
|
+
traceOutput && (rspack_rspack.experiments.globalTrace.cleanup(), src_logger.info(`profile file saved to ${color.cyan(traceOutput)}`));
|
|
8952
8983
|
});
|
|
8953
8984
|
}
|
|
8954
8985
|
},
|
|
@@ -8985,7 +9016,7 @@ try {
|
|
|
8985
9016
|
let crossorigin = chain.output.get('crossOriginLoading');
|
|
8986
9017
|
(!1 === crossorigin || void 0 === crossorigin) && chain.output.crossOriginLoading('anonymous');
|
|
8987
9018
|
let { algorithm = 'sha384' } = sri;
|
|
8988
|
-
chain.plugin(CHAIN_ID.PLUGIN.SUBRESOURCE_INTEGRITY).use(rspack.
|
|
9019
|
+
chain.plugin(CHAIN_ID.PLUGIN.SUBRESOURCE_INTEGRITY).use(rspack.SubresourceIntegrityPlugin, [
|
|
8989
9020
|
{
|
|
8990
9021
|
enabled: !0,
|
|
8991
9022
|
hashFuncNames: helpers_castArray(algorithm),
|
|
@@ -9048,7 +9079,7 @@ try {
|
|
|
9048
9079
|
cwd: options.cwd,
|
|
9049
9080
|
...'boolean' == typeof options.loadEnv ? {} : options.loadEnv
|
|
9050
9081
|
}) : null, configOrFactory = options.config ?? options.rsbuildConfig, config = isFunction(configOrFactory) ? await configOrFactory() : configOrFactory || {};
|
|
9051
|
-
config.logLevel && !isDebug() && (
|
|
9082
|
+
config.logLevel && !isDebug() && (src_logger.level = config.logLevel), applyEnvsToConfig(config, envs);
|
|
9052
9083
|
let resolvedOptions = {
|
|
9053
9084
|
cwd: process.cwd(),
|
|
9054
9085
|
callerName: 'rsbuild',
|
|
@@ -9060,7 +9091,7 @@ try {
|
|
|
9060
9091
|
});
|
|
9061
9092
|
context.getPluginAPI = getPluginAPI;
|
|
9062
9093
|
let globalPluginAPI = getPluginAPI();
|
|
9063
|
-
|
|
9094
|
+
src_logger.debug('registering default plugins'), applyDefaultPlugins(pluginManager, context), src_logger.debug('default plugins registered');
|
|
9064
9095
|
let provider = config.provider || rspackProvider, providerInstance = await provider({
|
|
9065
9096
|
context,
|
|
9066
9097
|
pluginManager,
|
|
@@ -9156,7 +9187,7 @@ try {
|
|
|
9156
9187
|
if (customConfig) {
|
|
9157
9188
|
let customConfigPath = (0, external_node_path_.isAbsolute)(customConfig) ? customConfig : (0, external_node_path_.join)(root, customConfig);
|
|
9158
9189
|
if (external_node_fs_default().existsSync(customConfigPath)) return customConfigPath;
|
|
9159
|
-
|
|
9190
|
+
src_logger.warn(`Cannot find config file: ${color.dim(customConfigPath)}\n`);
|
|
9160
9191
|
}
|
|
9161
9192
|
for (let file of [
|
|
9162
9193
|
'rsbuild.config.mjs',
|
|
@@ -9171,7 +9202,7 @@ try {
|
|
|
9171
9202
|
}
|
|
9172
9203
|
return null;
|
|
9173
9204
|
})(cwd, path);
|
|
9174
|
-
if (!configFilePath) return
|
|
9205
|
+
if (!configFilePath) return src_logger.debug('no config file found.'), {
|
|
9175
9206
|
content: {},
|
|
9176
9207
|
filePath: configFilePath
|
|
9177
9208
|
};
|
|
@@ -9183,8 +9214,8 @@ try {
|
|
|
9183
9214
|
configExport = exportModule.default ? exportModule.default : exportModule;
|
|
9184
9215
|
} catch (err) {
|
|
9185
9216
|
let errorMessage = `Failed to load file with native loader: ${color.dim(configFilePath)}`;
|
|
9186
|
-
if ('native' === loader) throw
|
|
9187
|
-
|
|
9217
|
+
if ('native' === loader) throw src_logger.error(errorMessage), err;
|
|
9218
|
+
src_logger.debug(`${errorMessage}, fallback to jiti.`), src_logger.debug(err);
|
|
9188
9219
|
}
|
|
9189
9220
|
if (void 0 === configExport) try {
|
|
9190
9221
|
let { createJiti } = await import("jiti"), jiti = createJiti(constants_filename, {
|
|
@@ -9199,7 +9230,7 @@ try {
|
|
|
9199
9230
|
default: !0
|
|
9200
9231
|
});
|
|
9201
9232
|
} catch (err) {
|
|
9202
|
-
throw
|
|
9233
|
+
throw src_logger.error(`Failed to load file with jiti: ${color.dim(configFilePath)}`), err;
|
|
9203
9234
|
}
|
|
9204
9235
|
if ('function' == typeof configExport) {
|
|
9205
9236
|
let command = process.argv[2], nodeEnv = process.env.NODE_ENV || '', result = await configExport({
|
|
@@ -9215,7 +9246,7 @@ try {
|
|
|
9215
9246
|
};
|
|
9216
9247
|
}
|
|
9217
9248
|
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
|
|
9249
|
+
return src_logger.debug('configuration loaded from:', configFilePath), {
|
|
9219
9250
|
content: applyMetaInfo(configExport),
|
|
9220
9251
|
filePath: configFilePath
|
|
9221
9252
|
};
|
|
@@ -9268,7 +9299,7 @@ try {
|
|
|
9268
9299
|
});
|
|
9269
9300
|
}), rsbuild;
|
|
9270
9301
|
} catch (err) {
|
|
9271
|
-
if (isRestart)
|
|
9302
|
+
if (isRestart) src_logger.error(err);
|
|
9272
9303
|
else throw err;
|
|
9273
9304
|
}
|
|
9274
9305
|
}
|
|
@@ -9277,8 +9308,8 @@ try {
|
|
|
9277
9308
|
}, beforeRestart = async ({ filePath, clear = !0, id })=>{
|
|
9278
9309
|
if (clear && isTTY() && !process.env.DEBUG && process.stdout.write('\x1B[H\x1B[2J'), filePath) {
|
|
9279
9310
|
let filename = external_node_path_default().basename(filePath);
|
|
9280
|
-
|
|
9281
|
-
} else
|
|
9311
|
+
src_logger.info(`restarting ${id} as ${color.yellow(filename)} changed\n`);
|
|
9312
|
+
} else src_logger.info(`restarting ${id}...\n`);
|
|
9282
9313
|
for (let cleaner of cleaners)await cleaner();
|
|
9283
9314
|
cleaners = [];
|
|
9284
9315
|
}, restartDevServer = async ({ filePath, clear = !0 } = {})=>{
|
|
@@ -9316,7 +9347,7 @@ try {
|
|
|
9316
9347
|
filePath
|
|
9317
9348
|
}) : await restartDevServer({
|
|
9318
9349
|
filePath
|
|
9319
|
-
})) ? await watcher.close() :
|
|
9350
|
+
})) ? await watcher.close() : src_logger.error(isBuildWatch ? 'Restart build failed.' : 'Restart server failed.'), restarting = !1);
|
|
9320
9351
|
};
|
|
9321
9352
|
watcher.on('add', onChange), watcher.on('change', onChange), watcher.on('unlink', onChange);
|
|
9322
9353
|
}
|
|
@@ -9325,7 +9356,7 @@ try {
|
|
|
9325
9356
|
};
|
|
9326
9357
|
function setupCommands() {
|
|
9327
9358
|
let cli = ((name = "")=>new CAC(name))('rsbuild');
|
|
9328
|
-
cli.version("1.7.0-beta.
|
|
9359
|
+
cli.version("1.7.0-beta.1"), 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
9360
|
default: 'auto'
|
|
9330
9361
|
}).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
9362
|
type: [
|
|
@@ -9341,7 +9372,7 @@ try {
|
|
|
9341
9372
|
});
|
|
9342
9373
|
await rsbuild?.startDevServer();
|
|
9343
9374
|
} catch (err) {
|
|
9344
|
-
|
|
9375
|
+
src_logger.error('Failed to start dev server.'), src_logger.error(err), process.exit(1);
|
|
9345
9376
|
}
|
|
9346
9377
|
}), buildCommand.option('-w, --watch', 'Enable watch mode to automatically rebuild on file changes').action(async (options)=>{
|
|
9347
9378
|
try {
|
|
@@ -9354,7 +9385,7 @@ try {
|
|
|
9354
9385
|
});
|
|
9355
9386
|
buildInstance && (options.watch ? onBeforeRestartServer(buildInstance.close) : await buildInstance.close());
|
|
9356
9387
|
} catch (err) {
|
|
9357
|
-
err instanceof Error && err.message === RSPACK_BUILD_ERROR ||
|
|
9388
|
+
err instanceof Error && err.message === RSPACK_BUILD_ERROR || src_logger.error('Failed to build.'), src_logger.error(err), process.exit(1);
|
|
9358
9389
|
}
|
|
9359
9390
|
}), previewCommand.action(async (options)=>{
|
|
9360
9391
|
try {
|
|
@@ -9363,7 +9394,7 @@ try {
|
|
|
9363
9394
|
});
|
|
9364
9395
|
await rsbuild?.preview();
|
|
9365
9396
|
} catch (err) {
|
|
9366
|
-
|
|
9397
|
+
src_logger.error('Failed to start preview server.'), src_logger.error(err), process.exit(1);
|
|
9367
9398
|
}
|
|
9368
9399
|
}), inspectCommand.option('--output <output>', 'Set the output path for inspection results').option('--verbose', 'Show complete function definitions in output').action(async (options)=>{
|
|
9369
9400
|
try {
|
|
@@ -9376,7 +9407,7 @@ try {
|
|
|
9376
9407
|
writeToDisk: !0
|
|
9377
9408
|
});
|
|
9378
9409
|
} catch (err) {
|
|
9379
|
-
|
|
9410
|
+
src_logger.error('Failed to inspect config.'), src_logger.error(err), process.exit(1);
|
|
9380
9411
|
}
|
|
9381
9412
|
}), cli.help((sections)=>{
|
|
9382
9413
|
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 +9425,7 @@ try {
|
|
|
9394
9425
|
}
|
|
9395
9426
|
function showGreeting() {
|
|
9396
9427
|
let { npm_execpath, npm_lifecycle_event, NODE_RUN_SCRIPT_NAME } = process.env, isBun = npm_execpath?.includes('.bun');
|
|
9397
|
-
|
|
9428
|
+
src_logger.greet(`${'npx' === npm_lifecycle_event || isBun || NODE_RUN_SCRIPT_NAME ? '\n' : ''}Rsbuild v1.7.0-beta.1\n`);
|
|
9398
9429
|
}
|
|
9399
9430
|
function setupLogLevel() {
|
|
9400
9431
|
let logLevelIndex = process.argv.findIndex((item)=>'--log-level' === item || '--logLevel' === item);
|
|
@@ -9404,7 +9435,7 @@ try {
|
|
|
9404
9435
|
'warn',
|
|
9405
9436
|
'error',
|
|
9406
9437
|
'silent'
|
|
9407
|
-
].includes(level) && !isDebug() && (
|
|
9438
|
+
].includes(level) && !isDebug() && (src_logger.level = level);
|
|
9408
9439
|
}
|
|
9409
9440
|
}
|
|
9410
9441
|
function runCLI() {
|
|
@@ -9412,10 +9443,10 @@ try {
|
|
|
9412
9443
|
try {
|
|
9413
9444
|
setupCommands();
|
|
9414
9445
|
} catch (err) {
|
|
9415
|
-
|
|
9446
|
+
src_logger.error('Failed to start Rsbuild CLI.'), src_logger.error(err);
|
|
9416
9447
|
}
|
|
9417
9448
|
}
|
|
9418
|
-
let src_version = "1.7.0-beta.
|
|
9449
|
+
let src_version = "1.7.0-beta.1";
|
|
9419
9450
|
})(), 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
9451
|
"PLUGIN_CSS_NAME",
|
|
9421
9452
|
"PLUGIN_SWC_NAME",
|