@rsbuild/core 1.3.20 → 1.3.22

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/dist/index.js CHANGED
@@ -7,25 +7,18 @@ import * as __WEBPACK_EXTERNAL_MODULE_path__ from "path";
7
7
  import * as __WEBPACK_EXTERNAL_MODULE__rspack_core_e0096ff7__ from "@rspack/core";
8
8
  import * as __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__ from "node:fs";
9
9
  import * as __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__ from "node:path";
10
+ import * as __WEBPACK_EXTERNAL_MODULE_node_crypto_9ba42079__ from "node:crypto";
10
11
  import * as __WEBPACK_EXTERNAL_MODULE_node_url_e96de089__ from "node:url";
11
12
  import * as __WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__ from "../compiled/picocolors/index.js";
12
13
  import * as __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__ from "../compiled/rslog/index.js";
13
14
  import * as __WEBPACK_EXTERNAL_MODULE_node_util_types_ce11fc49__ from "node:util/types";
14
15
  import * as __WEBPACK_EXTERNAL_MODULE_node_module_ab9f2194__ from "node:module";
15
- import * as __WEBPACK_EXTERNAL_MODULE__compiled_rspack_chain_index_js_b67fefbd__ from "../compiled/rspack-chain/index.js";
16
16
  import * as __WEBPACK_EXTERNAL_MODULE_node_os_74b4b876__ from "node:os";
17
17
  import * as __WEBPACK_EXTERNAL_MODULE_node_process_786449bf__ from "node:process";
18
18
  import * as __WEBPACK_EXTERNAL_MODULE_node_util_1b29d436__ from "node:util";
19
19
  import * as __WEBPACK_EXTERNAL_MODULE__compiled_mrmime_index_js_86f064ca__ from "../compiled/mrmime/index.js";
20
- import * as __WEBPACK_EXTERNAL_MODULE_node_crypto_9ba42079__ from "node:crypto";
20
+ import * as __WEBPACK_EXTERNAL_MODULE__compiled_rspack_chain_index_js_b67fefbd__ from "../compiled/rspack-chain/index.js";
21
21
  import * as __WEBPACK_EXTERNAL_MODULE_node_zlib_a5bb16fc__ from "node:zlib";
22
- import * as __WEBPACK_EXTERNAL_MODULE_node_child_process_27f17141__ from "node:child_process";
23
- import * as __WEBPACK_EXTERNAL_MODULE_node_net_0373943e__ from "node:net";
24
- import * as __WEBPACK_EXTERNAL_MODULE_node_assert_3e74d44e__ from "node:assert";
25
- import * as __WEBPACK_EXTERNAL_MODULE_node_readline_91c31510__ from "node:readline";
26
- import * as __WEBPACK_EXTERNAL_MODULE_node_dns_78d346ee__ from "node:dns";
27
- import * as __WEBPACK_EXTERNAL_MODULE_node_querystring_aeb3c0b4__ from "node:querystring";
28
- import * as __WEBPACK_EXTERNAL_MODULE_node_vm_bd3d9cea__ from "node:vm";
29
22
  import * as __WEBPACK_EXTERNAL_MODULE_events__ from "events";
30
23
  var EsmMode, __webpack_modules__ = {
31
24
  "../../node_modules/.pnpm/clone-deep@4.0.1/node_modules/clone-deep/index.js": function(module, __unused_webpack_exports, __webpack_require__) {
@@ -929,17 +922,15 @@ __webpack_require__.r(provider_helpers_namespaceObject), __webpack_require__.d(p
929
922
  getChainUtils: ()=>getChainUtils,
930
923
  getConfigUtils: ()=>getConfigUtils,
931
924
  getHTMLPlugin: ()=>getHTMLPlugin,
932
- getRsbuildInspectConfig: ()=>getRsbuildInspectConfig,
933
925
  getStatsOptions: ()=>getStatsOptions,
934
926
  initRsbuildConfig: ()=>initRsbuildConfig,
927
+ inspectConfig: ()=>inspectConfig,
935
928
  modifyBundlerChain: ()=>modifyBundlerChain,
936
- outputInspectConfigFiles: ()=>outputInspectConfigFiles,
937
929
  prettyTime: ()=>prettyTime,
938
930
  registerBuildHook: ()=>registerBuildHook,
939
931
  registerDevHook: ()=>registerDevHook,
940
932
  setCssExtractPlugin: ()=>setCssExtractPlugin,
941
- setHTMLPlugin: ()=>setHTMLPlugin,
942
- stringifyConfig: ()=>stringifyConfig
933
+ setHTMLPlugin: ()=>setHTMLPlugin
943
934
  });
944
935
  var main = __webpack_require__("../../node_modules/.pnpm/dotenv@16.5.0/node_modules/dotenv/lib/main.js"), lib_main = __webpack_require__("../../node_modules/.pnpm/dotenv-expand@12.0.2/node_modules/dotenv-expand/lib/main.js"), cjs = __webpack_require__("../../node_modules/.pnpm/deepmerge@4.3.1/node_modules/deepmerge/dist/cjs.js"), cjs_default = __webpack_require__.n(cjs);
945
936
  let constants_filename = (0, __WEBPACK_EXTERNAL_MODULE_node_url_e96de089__.fileURLToPath)(import.meta.url), constants_dirname = (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.dirname)(constants_filename), ROOT_DIST_DIR = 'dist', LOADER_PATH = (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(constants_dirname), STATIC_PATH = (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(constants_dirname, '../static'), COMPILED_PATH = (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(constants_dirname, '../compiled'), RSBUILD_OUTPUTS_PATH = '.rsbuild', DEFAULT_DEV_HOST = '0.0.0.0', DEFAULT_ASSET_PREFIX = '/', DEFAULT_WEB_BROWSERSLIST = [
@@ -997,9 +988,6 @@ let constants_filename = (0, __WEBPACK_EXTERNAL_MODULE_node_url_e96de089__.fileU
997
988
  '*'
998
989
  ].some((key)=>values.includes(key));
999
990
  };
1000
- function getAbsolutePath(base, filepath) {
1001
- return (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.isAbsolute)(filepath) ? filepath : (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(base, filepath);
1002
- }
1003
991
  isDebug() && (__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.level = 'verbose'), __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.override({
1004
992
  debug: (message, ...args)=>{
1005
993
  if ('verbose' !== __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.level) return;
@@ -1010,7 +998,7 @@ isDebug() && (__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logg
1010
998
  console.log(` ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.magenta('rsbuild')} ${time} ${message}`, ...args);
1011
999
  }
1012
1000
  });
1013
- let getCompiledPath = (packageName)=>(0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(COMPILED_PATH, packageName, 'index.js'), ensureAbsolutePath = (base, filePath)=>(0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.isAbsolute)(filePath) ? filePath : (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.resolve)(base, filePath), pathnameParse = (publicPath)=>{
1001
+ let getCompiledPath = (packageName)=>(0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(COMPILED_PATH, packageName, 'index.js'), ensureAbsolutePath = (base, filePath)=>(0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.isAbsolute)(filePath) ? filePath : (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(base, filePath), getPathnameFromUrl = (publicPath)=>{
1014
1002
  try {
1015
1003
  return publicPath ? new URL(publicPath).pathname : publicPath;
1016
1004
  } catch (err) {
@@ -1227,7 +1215,7 @@ function formatStats(statsData, hasErrors) {
1227
1215
  }
1228
1216
  return {};
1229
1217
  }
1230
- let rspackMinVersion = '1.0.0', getNodeEnv = ()=>process.env.NODE_ENV, setNodeEnv = (env)=>{
1218
+ let rspackMinVersion = '1.2.4', getNodeEnv = ()=>process.env.NODE_ENV, setNodeEnv = (env)=>{
1231
1219
  process.env.NODE_ENV = env;
1232
1220
  }, isFunction = (func)=>'function' == typeof func, isObject = (obj)=>'[object Object]' === Object.prototype.toString.call(obj), isPlainObject = (obj)=>null !== obj && 'object' == typeof obj && Object.getPrototypeOf(obj) === Object.prototype, castArray = (arr)=>void 0 === arr ? [] : Array.isArray(arr) ? arr : [
1233
1221
  arr
@@ -1278,7 +1266,7 @@ function getFilename(config, type, isProd, isServer) {
1278
1266
  case 'assets':
1279
1267
  return filename.assets ?? `[name]${hash}[ext]`;
1280
1268
  default:
1281
- throw Error(`[rsbuild:config] unknown key ${type} in "output.filename"`);
1269
+ throw Error(`${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim('[rsbuild:config]')} unknown key ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow(type)} in ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow('output.filename')}`);
1282
1270
  }
1283
1271
  }
1284
1272
  let applyToCompiler = (compiler, apply)=>{
@@ -1302,7 +1290,7 @@ let camelCase = (input)=>input.replace(/[-_](\w)/g, (_, c)=>c.toUpperCase()), pr
1302
1290
  function loadEnv({ cwd = process.cwd(), mode = getNodeEnv(), prefixes = [
1303
1291
  'PUBLIC_'
1304
1292
  ], processEnv = process.env } = {}) {
1305
- if ('local' === mode) throw Error("[rsbuild:loadEnv] 'local' cannot be used as a value for env mode, because \".env.local\" represents a temporary local file. Please use another value.");
1293
+ if ('local' === mode) throw Error(`${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim('[rsbuild:loadEnv]')} ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow('local')} cannot be used as a value for env mode, because ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow('.env.local')} represents a temporary local file. Please use another value.`);
1306
1294
  let filePaths = [
1307
1295
  '.env',
1308
1296
  '.env.local',
@@ -1442,9 +1430,10 @@ let configCache = {}, OVERRIDE_PATHS = [
1442
1430
  merged[key] = merge(x[key], y[key], childPath);
1443
1431
  }
1444
1432
  return merged;
1445
- }, mergeRsbuildConfig = (...configs)=>2 === configs.length ? merge(configs[0], configs[1]) : configs.length < 2 ? configs[0] : configs.reduce((result, config)=>merge(result, config), {}), config_require = (0, __WEBPACK_EXTERNAL_MODULE_node_module_ab9f2194__.createRequire)(import.meta.url), getDefaultDevConfig = ()=>({
1433
+ }, mergeRsbuildConfig = (...configs)=>2 === configs.length ? merge(configs[0], configs[1]) : configs.length < 2 ? configs[0] : configs.reduce((result, config)=>merge(result, config), {}), defaultConfig_require = (0, __WEBPACK_EXTERNAL_MODULE_node_module_ab9f2194__.createRequire)(import.meta.url), getDefaultDevConfig = ()=>({
1446
1434
  hmr: !0,
1447
1435
  liveReload: !0,
1436
+ watchFiles: [],
1448
1437
  assetPrefix: DEFAULT_ASSET_PREFIX,
1449
1438
  writeToDisk: !1,
1450
1439
  cliShortcuts: !1,
@@ -1469,7 +1458,6 @@ let configCache = {}, OVERRIDE_PATHS = [
1469
1458
  },
1470
1459
  middlewareMode: !1
1471
1460
  }), getDefaultSourceConfig = ()=>({
1472
- alias: {},
1473
1461
  define: {},
1474
1462
  preEntry: [],
1475
1463
  decorators: {
@@ -1551,7 +1539,7 @@ let configCache = {}, OVERRIDE_PATHS = [
1551
1539
  exportLocalsConvention: 'camelCase'
1552
1540
  },
1553
1541
  emitAssets: !0
1554
- }), getDefaultResolveConfig = ()=>(swcHelpersPath || (swcHelpersPath = (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.dirname)(config_require.resolve('@swc/helpers/package.json'))), {
1542
+ }), getDefaultResolveConfig = ()=>(swcHelpersPath || (swcHelpersPath = (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.dirname)(defaultConfig_require.resolve('@swc/helpers/package.json'))), {
1555
1543
  alias: {
1556
1544
  '@swc/helpers': swcHelpersPath
1557
1545
  },
@@ -1583,154 +1571,19 @@ let configCache = {}, OVERRIDE_PATHS = [
1583
1571
  await isFileExists(tsconfigPath) && (merged.source.tsconfigPath = tsconfigPath);
1584
1572
  }
1585
1573
  return merged;
1586
- }, normalizeConfig = (config)=>mergeRsbuildConfig({
1574
+ }, normalizeConfig = (config)=>{
1575
+ let mergedConfig = mergeRsbuildConfig({
1587
1576
  ...createDefaultConfig(),
1588
1577
  mode: (()=>{
1589
1578
  if (config.mode) return config.mode;
1590
1579
  let nodeEnv = getNodeEnv();
1591
1580
  return 'production' === nodeEnv || 'development' === nodeEnv ? nodeEnv : 'none';
1592
1581
  })()
1593
- }, config);
1594
- function defineConfig(config) {
1595
- return config;
1596
- }
1597
- let resolveConfigPath = (root, customConfig)=>{
1598
- if (customConfig) {
1599
- let customConfigPath = (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.isAbsolute)(customConfig) ? customConfig : (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(root, customConfig);
1600
- if (__WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__.default.existsSync(customConfigPath)) return customConfigPath;
1601
- __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.warn(`Cannot find config file: ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim(customConfigPath)}\n`);
1602
- }
1603
- for (let file of [
1604
- 'rsbuild.config.mjs',
1605
- 'rsbuild.config.ts',
1606
- 'rsbuild.config.js',
1607
- 'rsbuild.config.cjs',
1608
- 'rsbuild.config.mts',
1609
- 'rsbuild.config.cts'
1610
- ]){
1611
- let configFile = (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(root, file);
1612
- if (__WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__.default.existsSync(configFile)) return configFile;
1613
- }
1614
- return null;
1615
- };
1616
- async function config_loadConfig({ cwd = process.cwd(), path, envMode, meta, loader = 'jiti' } = {}) {
1617
- let configExport, configFilePath = resolveConfigPath(cwd, path);
1618
- if (!configFilePath) return __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.debug('no config file found.'), {
1619
- content: {},
1620
- filePath: configFilePath
1621
- };
1622
- let applyMetaInfo = (config)=>(config._privateMeta = {
1623
- configFilePath
1624
- }, config);
1625
- if ('native' === loader || /\.(?:js|mjs|cjs)$/.test(configFilePath)) try {
1626
- let configFileURL = (0, __WEBPACK_EXTERNAL_MODULE_node_url_e96de089__.pathToFileURL)(configFilePath).href, exportModule = await import(`${configFileURL}?t=${Date.now()}`);
1627
- configExport = exportModule.default ? exportModule.default : exportModule;
1628
- } catch (err) {
1629
- if ('native' === loader) throw __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.error(`Failed to load file with native loader: ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim(configFilePath)}`), err;
1630
- __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.debug(`failed to load file with dynamic import: ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim(configFilePath)}`);
1631
- }
1632
- try {
1633
- if (void 0 === configExport) {
1634
- let { createJiti } = await import("jiti"), jiti = createJiti(constants_filename, {
1635
- moduleCache: !1,
1636
- interopDefault: !0,
1637
- nativeModules: [
1638
- '@rspack/core',
1639
- "typescript"
1640
- ]
1641
- });
1642
- configExport = await jiti.import(configFilePath, {
1643
- default: !0
1644
- });
1645
- }
1646
- } catch (err) {
1647
- throw __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.error(`Failed to load file with jiti: ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim(configFilePath)}`), err;
1648
- }
1649
- if ('function' == typeof configExport) {
1650
- let command = process.argv[2], nodeEnv = getNodeEnv(), result = await configExport({
1651
- env: nodeEnv,
1652
- command,
1653
- envMode: envMode || nodeEnv,
1654
- meta
1655
- });
1656
- if (void 0 === result) throw Error('[rsbuild:loadConfig] The config function must return a config object.');
1657
- return {
1658
- content: applyMetaInfo(result),
1659
- filePath: configFilePath
1660
- };
1661
- }
1662
- if (!isObject(configExport)) throw Error(`[rsbuild:loadConfig] The config must be an object or a function that returns an object, get ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow(configExport)}`);
1663
- return __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.debug('loaded config file:', configFilePath), {
1664
- content: applyMetaInfo(configExport),
1665
- filePath: configFilePath
1666
- };
1667
- }
1668
- let normalizePluginObject = (plugin)=>{
1669
- let { setup: _, ...rest } = plugin;
1670
- return {
1671
- ...rest,
1672
- setup () {}
1673
- };
1674
- }, getRsbuildInspectConfig = ({ normalizedConfig, inspectOptions, pluginManager })=>{
1675
- let { environments, ...rsbuildConfig } = normalizedConfig, rawRsbuildConfig = stringifyConfig({
1676
- ...rsbuildConfig,
1677
- plugins: pluginManager.getPlugins().map(normalizePluginObject)
1678
- }, inspectOptions.verbose), environmentConfigs = {}, rawEnvironmentConfigs = [];
1679
- for (let [name, config] of Object.entries(environments)){
1680
- let debugConfig = {
1681
- ...config,
1682
- plugins: pluginManager.getPlugins({
1683
- environment: name
1684
- }).map(normalizePluginObject)
1685
- };
1686
- rawEnvironmentConfigs.push({
1687
- name,
1688
- content: stringifyConfig(debugConfig, inspectOptions.verbose)
1689
- }), environmentConfigs[name] = debugConfig;
1690
- }
1691
- return {
1692
- rsbuildConfig,
1693
- rawRsbuildConfig,
1694
- environmentConfigs: environments,
1695
- rawEnvironmentConfigs
1696
- };
1697
- };
1698
- async function outputInspectConfigFiles({ rawBundlerConfigs, rawEnvironmentConfigs, inspectOptions, configType }) {
1699
- let { outputPath } = inspectOptions, files = [
1700
- ...rawEnvironmentConfigs.map(({ name, content })=>{
1701
- if (1 === rawEnvironmentConfigs.length) return {
1702
- path: (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(outputPath, 'rsbuild.config.mjs'),
1703
- label: 'Rsbuild config',
1704
- content
1705
- };
1706
- let outputFile = `rsbuild.config.${name}.mjs`;
1707
- return {
1708
- path: (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(outputPath, outputFile),
1709
- label: `Rsbuild config (${name})`,
1710
- content
1711
- };
1712
- }),
1713
- ...rawBundlerConfigs.map(({ name, content })=>{
1714
- let outputFile = `${configType}.config.${name}.mjs`, outputFilePath = (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(outputPath, outputFile);
1715
- return __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__.default.existsSync(outputFilePath) && (outputFilePath = outputFilePath.replace(/\.mjs$/, `.${Date.now()}.mjs`)), {
1716
- path: outputFilePath,
1717
- label: `${upperFirst(configType)} Config (${name})`,
1718
- content
1719
- };
1720
- })
1721
- ];
1722
- await __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__.default.promises.mkdir(outputPath, {
1723
- recursive: !0
1724
- }), await Promise.all(files.map(async (item)=>__WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__.default.promises.writeFile(item.path, `export default ${item.content}`)));
1725
- let fileInfos = files.map((item)=>` - ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.bold(__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow(item.label))}: ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.underline(item.path)}`).join('\n');
1726
- __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.success(`config inspection completed, generated files: \n\n${fileInfos}\n`);
1727
- }
1728
- function stringifyConfig(config, verbose) {
1729
- return (0, __WEBPACK_EXTERNAL_MODULE__compiled_rspack_chain_index_js_b67fefbd__.default.toString)(config, {
1730
- verbose
1731
- });
1732
- }
1733
- let normalizePublicDirs = (publicDir)=>{
1582
+ }, config), { watchFiles } = mergedConfig.dev;
1583
+ return Array.isArray(watchFiles) || (mergedConfig.dev.watchFiles = [
1584
+ watchFiles
1585
+ ]), mergedConfig;
1586
+ }, normalizePublicDirs = (publicDir)=>{
1734
1587
  if (!1 === publicDir) return [];
1735
1588
  let defaultConfig = {
1736
1589
  name: 'public',
@@ -1752,7 +1605,7 @@ let normalizePublicDirs = (publicDir)=>{
1752
1605
  let allLines = [];
1753
1606
  function getPlugin(name) {
1754
1607
  let targets = plugins.filter((item)=>item.instance.name === name);
1755
- if (!targets.length) throw Error(`[rsbuild:plugin] Plugin "${name}" not existed`);
1608
+ if (!targets.length) throw Error(`${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim('[rsbuild:plugin]')} Plugin "${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow(name)}" not existed`);
1756
1609
  return targets;
1757
1610
  }
1758
1611
  for (let plugin of plugins){
@@ -1773,7 +1626,7 @@ let normalizePublicDirs = (publicDir)=>{
1773
1626
  if (allLines.length) {
1774
1627
  let restInRingPoints = {};
1775
1628
  for (let l of allLines)restInRingPoints[l[0]] = !0, restInRingPoints[l[1]] = !0;
1776
- throw Error(`[rsbuild:plugin] Plugins dependencies has loop: ${Object.keys(restInRingPoints).join(',')}`);
1629
+ throw Error(`${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim('[rsbuild:plugin]')} Plugins dependencies has loop: ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow(Object.keys(restInRingPoints).join(','))}`);
1777
1630
  }
1778
1631
  return sortedPoint;
1779
1632
  };
@@ -2034,7 +1887,7 @@ let mapProcessAssetsStage = (compiler, stage)=>{
2034
1887
  case 'report':
2035
1888
  return Compilation.PROCESS_ASSETS_STAGE_REPORT;
2036
1889
  default:
2037
- throw Error(`[rsbuild] Invalid process assets stage: ${stage}`);
1890
+ throw Error(`${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim('[rsbuild]')} Invalid process assets stage: ${stage}`);
2038
1891
  }
2039
1892
  }, browsersListCache = new Map();
2040
1893
  async function getBrowserslist(path) {
@@ -2089,17 +1942,17 @@ let getEnvironmentHTMLPaths = (entry, config)=>'web' !== config.output.target ||
2089
1942
  let filename;
2090
1943
  filename = config.output.filename.html ? config.output.filename.html.replace('[name]', entryName) : 'flat' === config.html.outputStructure ? `${entryName}.html` : `${entryName}/index.html`;
2091
1944
  let prefix = config.output.distPath.html;
2092
- return prefix.startsWith('/') && __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.warn(`Absolute path is not recommended at \`output.distPath.html\`: "${prefix}", please use relative path instead.`), removeLeadingSlash(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.posix.join(prefix, filename));
1945
+ return prefix.startsWith('/') && __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.warn(`${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim('[rsbuild:config]')} Absolute path is not recommended at ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow(`output.distPath.html: "${prefix}"`)}, use relative path instead.`), removeLeadingSlash(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.posix.join(prefix, filename));
2093
1946
  }(key, config)), prev;
2094
1947
  }, {});
2095
1948
  async function updateEnvironmentContext(context, configs) {
2096
1949
  for (let [index, [name, config]] of (context.environments ||= {}, Object.entries(configs).entries())){
2097
- let tsconfigPath = config.source.tsconfigPath ? getAbsolutePath(context.rootPath, config.source.tsconfigPath) : void 0, browserslist = await getBrowserslistByEnvironment(context.rootPath, config), entry = config.source.entry ?? {}, htmlPaths = getEnvironmentHTMLPaths(entry, config), environmentContext = {
1950
+ let browserslist = await getBrowserslistByEnvironment(context.rootPath, config), { entry = {}, tsconfigPath } = config.source, htmlPaths = getEnvironmentHTMLPaths(entry, config), environmentContext = {
2098
1951
  index,
2099
1952
  name,
2100
1953
  distPath: function(cwd, config) {
2101
1954
  var _config_output_distPath, _config_output;
2102
- return getAbsolutePath(cwd, (null == (_config_output = config.output) || null == (_config_output_distPath = _config_output.distPath) ? void 0 : _config_output_distPath.root) ?? ROOT_DIST_DIR);
1955
+ return ensureAbsolutePath(cwd, (null == (_config_output = config.output) || null == (_config_output_distPath = _config_output.distPath) ? void 0 : _config_output_distPath.root) ?? ROOT_DIST_DIR);
2103
1956
  }(context.rootPath, config),
2104
1957
  entry,
2105
1958
  browserslist,
@@ -2114,9 +1967,9 @@ async function updateEnvironmentContext(context, configs) {
2114
1967
  }
2115
1968
  }
2116
1969
  async function createContext(options, userConfig) {
2117
- let { cwd } = options, rootPath = userConfig.root ? getAbsolutePath(cwd, userConfig.root) : cwd, rsbuildConfig = await withDefaultConfig(rootPath, userConfig), cachePath = (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(rootPath, 'node_modules', '.cache'), specifiedEnvironments = options.environment && options.environment.length > 0 ? options.environment : void 0, bundlerType = userConfig.provider ? 'webpack' : 'rspack';
1970
+ let { cwd } = options, rootPath = userConfig.root ? ensureAbsolutePath(cwd, userConfig.root) : cwd, rsbuildConfig = await withDefaultConfig(rootPath, userConfig), cachePath = (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(rootPath, 'node_modules', '.cache'), specifiedEnvironments = options.environment && options.environment.length > 0 ? options.environment : void 0, bundlerType = userConfig.provider ? 'webpack' : 'rspack';
2118
1971
  return {
2119
- version: "1.3.20",
1972
+ version: "1.3.22",
2120
1973
  rootPath,
2121
1974
  distPath: '',
2122
1975
  cachePath,
@@ -2190,21 +2043,21 @@ let pluginAppIcon = ()=>({
2190
2043
  let distDir = config.output.distPath.image, manifestFile = appIcon.filename ?? 'manifest.webmanifest', publicPath = getPublicPathFromCompiler(compilation), icons = appIcon.icons.map((icon)=>formatIcon(icon, distDir, publicPath)), tags = [];
2191
2044
  for (let icon of icons){
2192
2045
  if ('web-app-manifest' === icon.target && !appIcon.name) {
2193
- addCompilationError(compilation, '[rsbuild:app-icon] "appIcon.name" is required when "target" is "web-app-manifest".');
2046
+ addCompilationError(compilation, `${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim('[rsbuild:app-icon]')} ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow('"appIcon.name"')} is required when ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow('"target"')} is ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow('"web-app-manifest"')}.`);
2194
2047
  continue;
2195
2048
  }
2196
2049
  if (!icon.isURL) {
2197
2050
  if (!compilation.inputFileSystem) {
2198
- addCompilationError(compilation, '[rsbuild:app-icon] Failed to read the icon file as "compilation.inputFileSystem" is not available.');
2051
+ addCompilationError(compilation, `${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim('[rsbuild:app-icon]')} Failed to read the icon file as ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow('"compilation.inputFileSystem"')} is not available.`);
2199
2052
  continue;
2200
2053
  }
2201
2054
  if (!await fileExistsByCompilation(compilation, icon.absolutePath)) {
2202
- addCompilationError(compilation, `[rsbuild:app-icon] Failed to find the icon file at "${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.cyan(icon.absolutePath)}".`);
2055
+ addCompilationError(compilation, `${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim('[rsbuild:app-icon]')} Failed to find the icon file at ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow(icon.absolutePath)}.`);
2203
2056
  continue;
2204
2057
  }
2205
2058
  let source = await (0, __WEBPACK_EXTERNAL_MODULE_node_util_1b29d436__.promisify)(compilation.inputFileSystem.readFile)(icon.absolutePath);
2206
2059
  if (!source) {
2207
- addCompilationError(compilation, `[rsbuild:app-icon] Failed to read the icon file at "${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.cyan(icon.absolutePath)}".`);
2060
+ addCompilationError(compilation, `${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim('[rsbuild:app-icon]')} Failed to read the icon file at ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow(icon.absolutePath)}.`);
2208
2061
  continue;
2209
2062
  }
2210
2063
  compilation.emitAsset(icon.relativePath, new sources.RawSource(source));
@@ -2491,7 +2344,7 @@ let pluginCache = ()=>({
2491
2344
  setup (api) {
2492
2345
  let cacheEnabled = !1;
2493
2346
  api.modifyBundlerChain(async (chain, { environment, env })=>{
2494
- var digest;
2347
+ var data;
2495
2348
  let { config } = environment, { bundlerType } = api.context, buildCache = config.performance.buildCache ?? 'webpack' === bundlerType;
2496
2349
  if (!1 === buildCache) return;
2497
2350
  cacheEnabled = !0;
@@ -2501,7 +2354,7 @@ let pluginCache = ()=>({
2501
2354
  userBuildDependencies: cacheConfig.buildDependencies
2502
2355
  } : {});
2503
2356
  'webpack' === bundlerType && await validateWebpackCache(cacheDirectory, buildDependencies);
2504
- let cacheVersion = Array.isArray(cacheConfig.cacheDigest) && cacheConfig.cacheDigest.length ? `${environment.name}-${env}-${digest = cacheConfig.cacheDigest, __WEBPACK_EXTERNAL_MODULE_node_crypto_9ba42079__.default.createHash('md5').update(JSON.stringify(digest)).digest('hex').slice(0, 8)}` : `${environment.name}-${env}`;
2357
+ let cacheVersion = Array.isArray(cacheConfig.cacheDigest) && cacheConfig.cacheDigest.length ? `${environment.name}-${env}-${data = JSON.stringify(cacheConfig.cacheDigest), __WEBPACK_EXTERNAL_MODULE_node_crypto_9ba42079__.default.hash ? __WEBPACK_EXTERNAL_MODULE_node_crypto_9ba42079__.default.hash('sha256', data, 'hex').slice(0, 16) : __WEBPACK_EXTERNAL_MODULE_node_crypto_9ba42079__.default.createHash('sha256').update(data).digest('hex').slice(0, 16)}` : `${environment.name}-${env}`;
2505
2358
  'rspack' === bundlerType ? (chain.cache(!0), chain.experiments({
2506
2359
  ...chain.get('experiments'),
2507
2360
  cache: {
@@ -2610,7 +2463,7 @@ let pluginHelper_require = (0, __WEBPACK_EXTERNAL_MODULE_node_module_ab9f2194__.
2610
2463
  plugin && (pluginHelper_htmlPlugin = plugin);
2611
2464
  }, getHTMLPlugin = ()=>(pluginHelper_htmlPlugin || (pluginHelper_htmlPlugin = pluginHelper_require('../compiled/html-rspack-plugin/index.js')), pluginHelper_htmlPlugin), setCssExtractPlugin = (plugin)=>{
2612
2465
  cssExtractPlugin = plugin;
2613
- }, getCssExtractPlugin = ()=>cssExtractPlugin || __WEBPACK_EXTERNAL_MODULE__rspack_core_e0096ff7__.default.CssExtractRspackPlugin, getSwcMinimizerOptions = (config, jsOptions)=>{
2466
+ }, getCssExtractPlugin = ()=>cssExtractPlugin || __WEBPACK_EXTERNAL_MODULE__rspack_core_e0096ff7__.rspack.CssExtractRspackPlugin, getSwcMinimizerOptions = (config, jsOptions)=>{
2614
2467
  let options = {};
2615
2468
  options.minimizerOptions ||= {}, options.minimizerOptions.format ||= {};
2616
2469
  let { removeConsole } = config.performance;
@@ -2634,26 +2487,27 @@ let pluginHelper_require = (0, __WEBPACK_EXTERNAL_MODULE_node_module_ab9f2194__.
2634
2487
  options.minimizerOptions.format.comments = !1, options.extractComments = !1;
2635
2488
  }
2636
2489
  return (options.minimizerOptions.format.asciiOnly = 'ascii' === config.output.charset, jsOptions) ? cjs_default()(options, jsOptions) : options;
2637
- }, parseMinifyOptions = (config, isProd)=>{
2638
- let { minify } = config.output;
2639
- return !1 !== minify && isProd ? !0 === minify ? {
2640
- minifyJs: !0,
2641
- minifyCss: !0
2642
- } : {
2643
- minifyJs: !1 !== minify.js,
2644
- minifyCss: !1 !== minify.css,
2490
+ }, parseMinifyOptions = (config)=>{
2491
+ let isProd = 'production' === config.mode, { minify } = config.output;
2492
+ if ('boolean' == typeof minify) {
2493
+ let shouldMinify = !0 === minify && isProd;
2494
+ return {
2495
+ minifyJs: shouldMinify,
2496
+ minifyCss: shouldMinify
2497
+ };
2498
+ }
2499
+ return {
2500
+ minifyJs: !1 !== minify.js && ('always' === minify.js || isProd),
2501
+ minifyCss: !1 !== minify.css && ('always' === minify.css || isProd),
2645
2502
  jsOptions: minify.jsOptions,
2646
2503
  cssOptions: minify.cssOptions
2647
- } : {
2648
- minifyJs: !1,
2649
- minifyCss: !1
2650
2504
  };
2651
2505
  }, pluginMinimize = ()=>({
2652
2506
  name: 'rsbuild:minimize',
2653
2507
  setup (api) {
2654
2508
  let isRspack = 'rspack' === api.context.bundlerType;
2655
- api.modifyBundlerChain(async (chain, { isProd, environment, CHAIN_ID })=>{
2656
- let { config } = environment, { minifyJs, minifyCss, jsOptions, cssOptions } = parseMinifyOptions(config, isProd);
2509
+ api.modifyBundlerChain(async (chain, { environment, CHAIN_ID })=>{
2510
+ let { config } = environment, { minifyJs, minifyCss, jsOptions, cssOptions } = parseMinifyOptions(config);
2657
2511
  if (chain.optimization.minimize(minifyJs || minifyCss), minifyJs && isRspack && chain.optimization.minimizer(CHAIN_ID.MINIMIZER.JS).use(__WEBPACK_EXTERNAL_MODULE__rspack_core_e0096ff7__.rspack.SwcJsMinimizerRspackPlugin, [
2658
2512
  getSwcMinimizerOptions(config, jsOptions)
2659
2513
  ]).end(), minifyCss && isRspack) {
@@ -2743,7 +2597,7 @@ let isPostcssPluginCreator = (plugin)=>'function' == typeof plugin && !0 === plu
2743
2597
  if ('function' == typeof postcssOptions) {
2744
2598
  let postcssOptionsWrapper = (loaderContext)=>{
2745
2599
  let options = postcssOptions(loaderContext);
2746
- if ('object' != typeof options || null === options) throw Error(`[rsbuild:css] \`postcssOptions\` function must return a PostCSSOptions object, got "${typeof options}".`);
2600
+ if ('object' != typeof options || null === options) throw Error(`${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim('[rsbuild:css]')} \`postcssOptions\` function must return a PostCSSOptions object, got ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow(typeof options)}.`);
2747
2601
  return updatePostcssOptions({
2748
2602
  ...userOptions,
2749
2603
  ...options,
@@ -2804,9 +2658,9 @@ let isPostcssPluginCreator = (plugin)=>'function' == typeof plugin && !0 === plu
2804
2658
  var _postcssLoaderOptions_postcssOptions_plugins, _postcssLoaderOptions_postcssOptions;
2805
2659
  if ('rspack' === api.context.bundlerType && !1 !== config.tools.lightningcssLoader) {
2806
2660
  importLoaders++;
2807
- let { minifyCss } = parseMinifyOptions(config, isProd);
2661
+ let { minifyCss } = parseMinifyOptions(config);
2808
2662
  updateRules((rule, type)=>{
2809
- let minify = ('inline' === type || config.output.injectStyles) && isProd && minifyCss, lightningcssOptions = getLightningCSSLoaderOptions(config, environment.browserslist, minify);
2663
+ let inlineStyle = 'inline' === type || config.output.injectStyles, lightningcssOptions = getLightningCSSLoaderOptions(config, environment.browserslist, inlineStyle && minifyCss);
2810
2664
  rule.use(CHAIN_ID.USE.LIGHTNINGCSS).loader('builtin:lightningcss-loader').options(lightningcssOptions);
2811
2665
  });
2812
2666
  }
@@ -2877,7 +2731,7 @@ let isPostcssPluginCreator = (plugin)=>'function' == typeof plugin && !0 === plu
2877
2731
  if (!value) return;
2878
2732
  let check = (value)=>{
2879
2733
  let pathKey = Object.keys(value).find((key)=>'path' === key.toLowerCase() && value[key] === process.env[key]);
2880
- pathKey && __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.warn(__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow(`[rsbuild:config] The "source.define" option includes an object with the key ${JSON.stringify(pathKey)} under "process.env", indicating potential exposure of all environment variables. This can lead to security risks and should be avoided.`));
2734
+ pathKey && __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.warn(`${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim('[rsbuild:config]')} The ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow('"source.define"')} option includes an object with the key ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow(JSON.stringify(pathKey))} under ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow('"process.env"')}, indicating potential exposure of all environment variables. This can lead to security risks and should be avoided.`);
2881
2735
  };
2882
2736
  if ('object' == typeof value) return check(value);
2883
2737
  if ('string' == typeof value) try {
@@ -2903,7 +2757,7 @@ let isPostcssPluginCreator = (plugin)=>'function' == typeof plugin && !0 === plu
2903
2757
  preEntry.forEach(addEntry), injectCoreJsEntry && addEntry(createVirtualModule('import "core-js";')), castArray(entry[entryName]).forEach(addEntry);
2904
2758
  }
2905
2759
  }), api.onBeforeCreateCompiler(({ bundlerConfigs })=>{
2906
- if (bundlerConfigs.every((config)=>!config.entry)) throw Error(`[rsbuild:config] Could not find any entry module, please make sure that ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.cyan('src/index.(ts|js|tsx|jsx|mts|cts|mjs|cjs)')} exists, or customize entry through the ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.cyan('source.entry')} configuration.`);
2760
+ if (bundlerConfigs.every((config)=>!config.entry)) throw Error(`${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim('[rsbuild:config]')} Could not find any entry module, please make sure that ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow('src/index.(ts|js|tsx|jsx|mts|cts|mjs|cjs)')} exists, or customize entry through the ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow('source.entry')} configuration.`);
2907
2761
  });
2908
2762
  }
2909
2763
  }), fileSize_gzip = (0, __WEBPACK_EXTERNAL_MODULE_node_util_1b29d436__.promisify)(__WEBPACK_EXTERNAL_MODULE_node_zlib_a5bb16fc__.default.gzip);
@@ -3127,12 +2981,12 @@ class RsbuildHtmlPlugin {
3127
2981
  let emitFavicon = async (compilation, favicon)=>{
3128
2982
  let buffer, name = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.default.basename(favicon);
3129
2983
  if (compilation.assets[name]) return name;
3130
- if (!compilation.inputFileSystem) return addCompilationError(compilation, '[rsbuild:html] Failed to read the favicon file as "compilation.inputFileSystem" is not available.'), null;
2984
+ if (!compilation.inputFileSystem) return addCompilationError(compilation, `${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim('[rsbuild:html]')} Failed to read the favicon file as ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow('compilation.inputFileSystem')} is not available.`), null;
3131
2985
  let filename = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.default.isAbsolute(favicon) ? favicon : __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.default.join(compilation.compiler.context, favicon);
3132
2986
  try {
3133
2987
  if (!(buffer = await (0, __WEBPACK_EXTERNAL_MODULE_node_util_1b29d436__.promisify)(compilation.inputFileSystem.readFile)(filename))) throw Error('Buffer is undefined');
3134
2988
  } catch (error) {
3135
- return __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.debug(`read favicon error: ${error}`), addCompilationError(compilation, `[rsbuild:html] Failed to read the favicon file at "${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.cyan(filename)}".`), null;
2989
+ return __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.debug(`read favicon error: ${error}`), addCompilationError(compilation, `${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim('[rsbuild:html]')} Failed to read the favicon file at ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow(filename)}.`), null;
3136
2990
  }
3137
2991
  let source = new compiler.webpack.sources.RawSource(buffer, !1);
3138
2992
  return compilation.emitAsset(name, source), name;
@@ -3230,7 +3084,7 @@ async function getTemplate(entryName, config, rootPath) {
3230
3084
  };
3231
3085
  let absolutePath = (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.isAbsolute)(templatePath) ? templatePath : __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.default.join(rootPath, templatePath);
3232
3086
  if (!existTemplatePath.has(absolutePath)) {
3233
- if (!await isFileExists(absolutePath)) throw Error(`[rsbuild:html] Failed to resolve HTML template, please check if the file exists: ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.cyan(absolutePath)}`);
3087
+ if (!await isFileExists(absolutePath)) throw Error(`${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim('[rsbuild:html]')} Failed to resolve HTML template, check if the file exists: ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow(absolutePath)}`);
3234
3088
  existTemplatePath.add(absolutePath);
3235
3089
  }
3236
3090
  let templateContent = await __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__.default.promises.readFile(absolutePath, 'utf-8');
@@ -3525,7 +3379,7 @@ let generateManifest = (htmlPaths, manifestOptions, environment)=>(_seed, files)
3525
3379
  manifestData
3526
3380
  });
3527
3381
  if (isObject(generatedManifest)) return environment.manifest = generatedManifest, generatedManifest;
3528
- throw Error('[rsbuild:manifest] `manifest.generate` function must return a valid manifest object.');
3382
+ throw Error(`${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim('[rsbuild:manifest]')} \`manifest.generate\` function must return a valid manifest object.`);
3529
3383
  }
3530
3384
  return environment.manifest = manifestData, manifestData;
3531
3385
  }, pluginManifest = ()=>({
@@ -3558,7 +3412,7 @@ let generateManifest = (htmlPaths, manifestOptions, environment)=>(_seed, files)
3558
3412
  }), api.onAfterCreateCompiler(()=>{
3559
3413
  if (manifestFilenames.size <= 1) return void manifestFilenames.clear();
3560
3414
  let environmentNames = Array.from(manifestFilenames.keys()), filenames = Array.from(manifestFilenames.values());
3561
- new Set(filenames).size !== filenames.length && __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.warn(`[rsbuild:manifest] The \`manifest.filename\` option must be unique when there are multiple environments (${environmentNames.join(', ')}), otherwise the manifest file will be overwritten.`), manifestFilenames.clear();
3415
+ new Set(filenames).size !== filenames.length && __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.warn(`${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim('[rsbuild:manifest]')} The ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow('"manifest.filename"')} option must be unique when there are multiple environments (${environmentNames.join(', ')}), otherwise the manifest file will be overwritten.`), manifestFilenames.clear();
3562
3416
  });
3563
3417
  }
3564
3418
  });
@@ -3629,7 +3483,7 @@ let pluginMoment = ()=>({
3629
3483
  raw: !0
3630
3484
  }, ({ code, emitFile, resourcePath })=>{
3631
3485
  let name = nodeAddons_getFilename(resourcePath);
3632
- if (null === name) throw Error(`[rsbuild:node-addons] Failed to load Node.js addon: "${resourcePath}"`);
3486
+ if (null === name) throw Error(`${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim('[rsbuild:node-addons]')} Failed to load Node.js addon: ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow(resourcePath)}`);
3633
3487
  return emitFile(name, code), `
3634
3488
  try {
3635
3489
  const path = require("path");
@@ -3706,7 +3560,7 @@ function printServerURLs({ urls: originalUrls, port, routes, protocol, printUrls
3706
3560
  protocol
3707
3561
  });
3708
3562
  if (!newUrls) return null;
3709
- if (!Array.isArray(newUrls)) throw Error(`[rsbuild:config] "server.printUrls" must return an array, but got ${typeof newUrls}.`);
3563
+ if (!Array.isArray(newUrls)) throw Error(`${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim('[rsbuild:config]')} "server.printUrls" must return an array, but got ${typeof newUrls}.`);
3710
3564
  urls = newUrls.map((url)=>({
3711
3565
  url,
3712
3566
  label: getUrlLabel(url)
@@ -3730,10 +3584,10 @@ function printServerURLs({ urls: originalUrls, port, routes, protocol, printUrls
3730
3584
  }
3731
3585
  let getPort = async ({ host, port, strictPort, tryLimits = 20 })=>{
3732
3586
  'string' == typeof port && (port = Number.parseInt(port, 10)), strictPort && (tryLimits = 1);
3733
- let original = port, found = !1, attempts = 0;
3587
+ let { createServer } = await import("node:net"), original = port, found = !1, attempts = 0;
3734
3588
  for(; !found && attempts <= tryLimits;)try {
3735
3589
  await new Promise((resolve, reject)=>{
3736
- let server = __WEBPACK_EXTERNAL_MODULE_node_net_0373943e__.default.createServer();
3590
+ let server = createServer();
3737
3591
  server.unref(), server.on('error', reject), server.listen({
3738
3592
  port,
3739
3593
  host
@@ -3745,7 +3599,7 @@ let getPort = async ({ host, port, strictPort, tryLimits = 20 })=>{
3745
3599
  if ('EADDRINUSE' !== e.code) throw e;
3746
3600
  port++, attempts++;
3747
3601
  }
3748
- if (port !== original && strictPort) throw Error(`[rsbuild:server] Port "${original}" is occupied, please choose another one.`);
3602
+ if (port !== original && strictPort) throw Error(`${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim('[rsbuild:server]')} Port ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow(original)} is occupied, please choose another one.`);
3749
3603
  return port;
3750
3604
  }, getServerConfig = async ({ config })=>{
3751
3605
  let { host, port: originalPort, strictPort } = config.server, port = await getPort({
@@ -3775,24 +3629,31 @@ let getPort = async ({ host, port, strictPort, tryLimits = 20 })=>{
3775
3629
  '127.0.0.1',
3776
3630
  '::1',
3777
3631
  '0000:0000:0000:0000:0000:0000:0000:0001'
3778
- ]).has(host), getHostInUrl = (host)=>host === DEFAULT_DEV_HOST ? 'localhost' : __WEBPACK_EXTERNAL_MODULE_node_net_0373943e__.default.isIPv6(host) ? '::' === host ? '[::1]' : `[${host}]` : host, concatUrl = ({ host, port, protocol })=>`${protocol}://${host}:${port}`, LOCAL_LABEL = 'Local: ', NETWORK_LABEL = 'Network: ', getUrlLabel = (url)=>{
3632
+ ]).has(host), getHostInUrl = async (host)=>{
3633
+ if (host === DEFAULT_DEV_HOST) return 'localhost';
3634
+ let { isIPv6 } = await import("node:net");
3635
+ return isIPv6(host) ? '::' === host ? '[::1]' : `[${host}]` : host;
3636
+ }, concatUrl = ({ host, port, protocol })=>`${protocol}://${host}:${port}`, LOCAL_LABEL = 'Local: ', NETWORK_LABEL = 'Network: ', getUrlLabel = (url)=>{
3779
3637
  try {
3780
3638
  let { host } = new URL(url);
3781
3639
  return isLoopbackHost(host) ? LOCAL_LABEL : NETWORK_LABEL;
3782
3640
  } catch (err) {
3783
3641
  return NETWORK_LABEL;
3784
3642
  }
3785
- }, getAddressUrls = ({ protocol = 'http', port, host })=>{
3786
- if (host && host !== DEFAULT_DEV_HOST) return [
3787
- {
3788
- label: isLoopbackHost(host) ? LOCAL_LABEL : NETWORK_LABEL,
3789
- url: concatUrl({
3790
- port,
3791
- host: getHostInUrl(host),
3792
- protocol
3793
- })
3794
- }
3795
- ];
3643
+ }, getAddressUrls = async ({ protocol = 'http', port, host })=>{
3644
+ if (host && host !== DEFAULT_DEV_HOST) {
3645
+ let url = concatUrl({
3646
+ port,
3647
+ host: await getHostInUrl(host),
3648
+ protocol
3649
+ });
3650
+ return [
3651
+ {
3652
+ label: isLoopbackHost(host) ? LOCAL_LABEL : NETWORK_LABEL,
3653
+ url
3654
+ }
3655
+ ];
3656
+ }
3796
3657
  let ipv4Interfaces = getIpv4Interfaces(), addressUrls = [], hasLocalUrl = !1;
3797
3658
  for (let detail of ipv4Interfaces)if (isLoopbackHost(detail.address) || detail.internal) {
3798
3659
  if (hasLocalUrl) continue;
@@ -3830,7 +3691,7 @@ function getServerTerminator(server) {
3830
3691
  listened ? server.close((err)=>err ? reject(err) : resolve()) : resolve();
3831
3692
  });
3832
3693
  }
3833
- let execAsync = (0, __WEBPACK_EXTERNAL_MODULE_node_util_1b29d436__.promisify)(__WEBPACK_EXTERNAL_MODULE_node_child_process_27f17141__.exec), supportedChromiumBrowsers = [
3694
+ let supportedChromiumBrowsers = [
3834
3695
  'Google Chrome Canary',
3835
3696
  'Google Chrome Dev',
3836
3697
  'Google Chrome Beta',
@@ -3839,20 +3700,23 @@ let execAsync = (0, __WEBPACK_EXTERNAL_MODULE_node_util_1b29d436__.promisify)(__
3839
3700
  'Brave Browser',
3840
3701
  'Vivaldi',
3841
3702
  'Chromium'
3842
- ], getDefaultBrowserForAppleScript = async ()=>{
3843
- let { stdout: ps } = await execAsync('ps cax');
3844
- return supportedChromiumBrowsers.find((b)=>ps.includes(b));
3845
- }, mapChromiumBrowserName = (browser)=>'chrome' === browser || 'google chrome' === browser ? 'Google Chrome' : browser, shouldTryAppleScript = (browser, browserArgs)=>'darwin' === process.platform && (!browser || !browserArgs) && (!browser || supportedChromiumBrowsers.includes(mapChromiumBrowserName(browser)));
3703
+ ], mapChromiumBrowserName = (browser)=>'chrome' === browser || 'google chrome' === browser ? 'Google Chrome' : browser, shouldTryAppleScript = (browser, browserArgs)=>'darwin' === process.platform && (!browser || !browserArgs) && (!browser || supportedChromiumBrowsers.includes(mapChromiumBrowserName(browser)));
3846
3704
  async function openBrowser(url) {
3847
3705
  let browser = process.env.BROWSER, browserArgs = process.env.BROWSER_ARGS;
3848
- if (shouldTryAppleScript(browser, browserArgs)) try {
3849
- let chromiumBrowser = browser ? mapChromiumBrowserName(browser) : await getDefaultBrowserForAppleScript();
3850
- if (chromiumBrowser) return await execAsync(`osascript openChrome.applescript "${encodeURI(url)}" "${chromiumBrowser}"`, {
3851
- cwd: STATIC_PATH
3852
- }), !0;
3853
- __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.debug('failed to find the target browser.');
3854
- } catch (err) {
3855
- __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.debug("failed to open start URL with apple script."), __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.debug(err);
3706
+ if (shouldTryAppleScript(browser, browserArgs)) {
3707
+ let { exec } = await import("node:child_process"), { promisify } = await import("node:util"), execAsync = promisify(exec), getDefaultBrowserForAppleScript = async ()=>{
3708
+ let { stdout: ps } = await execAsync('ps cax');
3709
+ return supportedChromiumBrowsers.find((b)=>ps.includes(b));
3710
+ };
3711
+ try {
3712
+ let chromiumBrowser = browser ? mapChromiumBrowserName(browser) : await getDefaultBrowserForAppleScript();
3713
+ if (chromiumBrowser) return await execAsync(`osascript openChrome.applescript "${encodeURI(url)}" "${chromiumBrowser}"`, {
3714
+ cwd: STATIC_PATH
3715
+ }), !0;
3716
+ __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.debug('failed to find the target browser.');
3717
+ } catch (err) {
3718
+ __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.debug("failed to open start URL with apple script."), __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.debug(err);
3719
+ }
3856
3720
  }
3857
3721
  try {
3858
3722
  let { default: open } = await import("../compiled/open/index.js"), { apps } = open, options = browser ? {
@@ -3887,13 +3751,13 @@ async function open_open({ https, port, routes, config, clearCache }) {
3887
3751
  let { targets, before } = normalizeOpenConfig(config);
3888
3752
  if ('true' === process.env.CSB) return;
3889
3753
  clearCache && clearOpenedURLs();
3890
- let urls = [], host = getHostInUrl(config.server.host), baseUrl = `${https ? 'https' : 'http'}://${host}:${port}`;
3754
+ let urls = [], host = await getHostInUrl(config.server.host), baseUrl = `${https ? 'https' : 'http'}://${host}:${port}`;
3891
3755
  for (let url of (targets.length ? urls.push(...targets.map((target)=>(function(str, base) {
3892
3756
  if (canParse(str)) return str;
3893
3757
  try {
3894
3758
  return new URL(str, base).href;
3895
3759
  } catch (e) {
3896
- throw Error('[rsbuild:open]: Invalid input: not a valid URL or pathname');
3760
+ throw Error(`${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim('[rsbuild:open]')} Invalid input: ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow(str)} is not a valid URL or pathname`);
3897
3761
  }
3898
3762
  })(replacePortPlaceholder(target, port), baseUrl))) : routes.length && urls.push(`${baseUrl}${routes[0].pathname}`), before && await before(), urls))openedURLs.includes(url) || (openBrowser(url), openedURLs.push(url));
3899
3763
  }
@@ -3997,13 +3861,13 @@ let getJsAsyncPath = (jsPath, isServer, jsAsync)=>void 0 !== jsAsync ? jsAsync :
3997
3861
  initial: {},
3998
3862
  config: config.resolve.alias
3999
3863
  });
4000
- if (mergedAlias = reduceConfigs({
3864
+ if (config.source.alias && (__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.warn(`${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim('[rsbuild:config]')} The ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow('"source.alias"')} config is deprecated, use ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow('"resolve.alias"')} instead.`), mergedAlias = reduceConfigs({
4001
3865
  initial: mergedAlias,
4002
3866
  config: config.source.alias
4003
- }), config.resolve.dedupe) for (let pkgName of config.resolve.dedupe){
3867
+ })), config.resolve.dedupe) for (let pkgName of config.resolve.dedupe){
4004
3868
  let pkgPath;
4005
3869
  if (mergedAlias[pkgName]) {
4006
- __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.debug(`[rsbuild:resolve] The package "${pkgName}" is already in the alias config, dedupe option for "${pkgName}" will be ignored.`);
3870
+ __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.debug(`${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim('[rsbuild:resolve]')} The package ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow(pkgName)} is already in the alias config, dedupe option for ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow(pkgName)} will be ignored.`);
4007
3871
  continue;
4008
3872
  }
4009
3873
  try {
@@ -4025,7 +3889,7 @@ let getJsAsyncPath = (jsPath, isServer, jsAsync)=>void 0 !== jsAsync ? jsAsync :
4025
3889
  ].join(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.sep);
4026
3890
  for(; !pkgPath.endsWith(trailing) && pkgPath.includes('node_modules');)pkgPath = (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.dirname)(pkgPath);
4027
3891
  } catch (e) {
4028
- __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.debug(`[rsbuild:resolve] The package "${pkgName}" is not resolved in the project, dedupe option for "${pkgName}" will be ignored.`);
3892
+ __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.debug(`${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim('[rsbuild:resolve]')} The package ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow(pkgName)} is not resolved in the project, dedupe option for ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow(pkgName)} will be ignored.`);
4029
3893
  continue;
4030
3894
  }
4031
3895
  mergedAlias[pkgName] = pkgPath;
@@ -4038,7 +3902,7 @@ let getJsAsyncPath = (jsPath, isServer, jsAsync)=>void 0 !== jsAsync ? jsAsync :
4038
3902
  chain,
4039
3903
  config,
4040
3904
  rootPath: api.context.rootPath
4041
- }), chain.module.rule(CHAIN_ID.RULE.MJS).test(/\.m?js/).resolve.set('fullySpecified', !1);
3905
+ }), chain.module.rule(CHAIN_ID.RULE.MJS).test(/\.m?js/).resolve.set('fullySpecified', !1), config.source.aliasStrategy && __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.warn(`${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim('[rsbuild:config]')} The ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow('"source.aliasStrategy"')} config is deprecated, use ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow('"resolve.aliasStrategy"')} instead.`);
4042
3906
  let aliasStrategy = config.source.aliasStrategy ?? config.resolve.aliasStrategy;
4043
3907
  tsconfigPath && 'rspack' === api.context.bundlerType && 'prefer-tsconfig' === aliasStrategy && chain.resolve.tsConfig({
4044
3908
  configFile: tsconfigPath,
@@ -4271,7 +4135,7 @@ async function applyProfile(root, filterValue, traceLayer = 'chrome', traceOutpu
4271
4135
  let timestamp = Date.now(), defaultOutputDir = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.default.join(root, `.rspack-profile-${timestamp}-${process.pid}`), defaultRustTraceChromeOutput = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.default.join(defaultOutputDir, 'trace.json');
4272
4136
  traceOutput = 'chrome' === traceLayer ? defaultRustTraceChromeOutput : 'stdout';
4273
4137
  }
4274
- return await ensureFileDir(traceOutput), await __WEBPACK_EXTERNAL_MODULE__rspack_core_e0096ff7__.default.experiments.globalTrace.register("OVERVIEW" === filterValue ? 'info' : "ALL" === filterValue ? 'trace' : filterValue, traceLayer, traceOutput), traceOutput;
4138
+ return await ensureFileDir(traceOutput), await __WEBPACK_EXTERNAL_MODULE__rspack_core_e0096ff7__.rspack.experiments.globalTrace.register("OVERVIEW" === filterValue ? 'info' : "ALL" === filterValue ? 'trace' : filterValue, traceLayer, traceOutput), traceOutput;
4275
4139
  }
4276
4140
  let pluginRspackProfile = ()=>({
4277
4141
  name: 'rsbuild:rspack-profile',
@@ -4286,7 +4150,7 @@ let pluginRspackProfile = ()=>({
4286
4150
  api.onBeforeBuild(({ isFirstCompile })=>{
4287
4151
  isFirstCompile && onStart();
4288
4152
  }), api.onBeforeStartDevServer(onStart), api.onExit(()=>{
4289
- traceOutput && (__WEBPACK_EXTERNAL_MODULE__rspack_core_e0096ff7__.default.experiments.globalTrace.cleanup(), __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.info(`profile file saved to ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.cyan(traceOutput)}`));
4153
+ traceOutput && (__WEBPACK_EXTERNAL_MODULE__rspack_core_e0096ff7__.rspack.experiments.globalTrace.cleanup(), __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.info(`profile file saved to ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.cyan(traceOutput)}`));
4290
4154
  });
4291
4155
  }
4292
4156
  }), pluginServer = ()=>({
@@ -4376,7 +4240,7 @@ let pluginRspackProfile = ()=>({
4376
4240
  },
4377
4241
  'split-by-size': function(ctx) {
4378
4242
  let { override, forceSplittingGroups, defaultConfig, userConfig } = ctx;
4379
- return (0, __WEBPACK_EXTERNAL_MODULE_node_assert_3e74d44e__.default)('split-by-size' === userConfig.strategy), {
4243
+ return {
4380
4244
  ...defaultConfig,
4381
4245
  minSize: userConfig.minSize ?? 0,
4382
4246
  maxSize: userConfig.maxSize ?? Number.POSITIVE_INFINITY,
@@ -4552,7 +4416,7 @@ let pluginRspackProfile = ()=>({
4552
4416
  swcConfig.jsc.transform.legacyDecorator = !1, swcConfig.jsc.transform.decoratorVersion = '2022-03';
4553
4417
  break;
4554
4418
  default:
4555
- throw Error(`[rsbuild:swc] Unknown decorators version: ${version}`);
4419
+ throw Error(`${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim('[rsbuild:swc]')} Unknown decorators version: ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow(version)}`);
4556
4420
  }
4557
4421
  }(swcConfig, config), castArray(target).includes('web') || target.includes('web-worker')) {
4558
4422
  let polyfillMode = config.output.polyfill;
@@ -4630,14 +4494,75 @@ let reduceTransformImportConfig = (options)=>{
4630
4494
  });
4631
4495
  });
4632
4496
  }
4633
- }), getInspectOutputPath = (context, inspectOptions)=>inspectOptions.outputPath ? (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.isAbsolute)(inspectOptions.outputPath) ? inspectOptions.outputPath : (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(context.distPath, inspectOptions.outputPath) : (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(context.distPath, RSBUILD_OUTPUTS_PATH);
4634
- async function inspectConfig({ context, pluginManager, rsbuildOptions, bundlerConfigs, inspectOptions = {} }) {
4497
+ }), normalizePluginObject = (plugin)=>{
4498
+ let { setup: _, ...rest } = plugin;
4499
+ return {
4500
+ ...rest,
4501
+ setup () {}
4502
+ };
4503
+ }, getRsbuildInspectConfig = ({ normalizedConfig, inspectOptions, pluginManager })=>{
4504
+ let { environments, ...rsbuildConfig } = normalizedConfig, rawRsbuildConfig = stringifyConfig({
4505
+ ...rsbuildConfig,
4506
+ plugins: pluginManager.getPlugins().map(normalizePluginObject)
4507
+ }, inspectOptions.verbose), environmentConfigs = {}, rawEnvironmentConfigs = [];
4508
+ for (let [name, config] of Object.entries(environments)){
4509
+ let debugConfig = {
4510
+ ...config,
4511
+ plugins: pluginManager.getPlugins({
4512
+ environment: name
4513
+ }).map(normalizePluginObject)
4514
+ };
4515
+ rawEnvironmentConfigs.push({
4516
+ name,
4517
+ content: stringifyConfig(debugConfig, inspectOptions.verbose)
4518
+ }), environmentConfigs[name] = debugConfig;
4519
+ }
4520
+ return {
4521
+ rsbuildConfig,
4522
+ rawRsbuildConfig,
4523
+ environmentConfigs: environments,
4524
+ rawEnvironmentConfigs
4525
+ };
4526
+ };
4527
+ async function outputInspectConfigFiles({ rawBundlerConfigs, rawEnvironmentConfigs, inspectOptions, configType }) {
4528
+ let { outputPath } = inspectOptions, files = [
4529
+ ...rawEnvironmentConfigs.map(({ name, content })=>{
4530
+ if (1 === rawEnvironmentConfigs.length) return {
4531
+ path: (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(outputPath, 'rsbuild.config.mjs'),
4532
+ label: 'Rsbuild config',
4533
+ content
4534
+ };
4535
+ let outputFile = `rsbuild.config.${name}.mjs`;
4536
+ return {
4537
+ path: (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(outputPath, outputFile),
4538
+ label: `Rsbuild config (${name})`,
4539
+ content
4540
+ };
4541
+ }),
4542
+ ...rawBundlerConfigs.map(({ name, content })=>{
4543
+ let outputFile = `${configType}.config.${name}.mjs`, outputFilePath = (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(outputPath, outputFile);
4544
+ return __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__.default.existsSync(outputFilePath) && (outputFilePath = outputFilePath.replace(/\.mjs$/, `.${Date.now()}.mjs`)), {
4545
+ path: outputFilePath,
4546
+ label: `${upperFirst(configType)} Config (${name})`,
4547
+ content
4548
+ };
4549
+ })
4550
+ ];
4551
+ await __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__.default.promises.mkdir(outputPath, {
4552
+ recursive: !0
4553
+ }), await Promise.all(files.map(async (item)=>__WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__.default.promises.writeFile(item.path, `export default ${item.content}`)));
4554
+ let fileInfos = files.map((item)=>` - ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.bold(__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow(item.label))}: ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.underline(item.path)}`).join('\n');
4555
+ __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.success(`config inspection completed, generated files: \n\n${fileInfos}\n`);
4556
+ }
4557
+ function stringifyConfig(config, verbose) {
4558
+ return (0, __WEBPACK_EXTERNAL_MODULE__compiled_rspack_chain_index_js_b67fefbd__.default.toString)(config, {
4559
+ verbose
4560
+ });
4561
+ }
4562
+ let getInspectOutputPath = (context, inspectOptions)=>inspectOptions.outputPath ? (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.isAbsolute)(inspectOptions.outputPath) ? inspectOptions.outputPath : (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(context.distPath, inspectOptions.outputPath) : (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(context.distPath, RSBUILD_OUTPUTS_PATH);
4563
+ async function inspectConfig({ context, pluginManager, bundlerConfigs, inspectOptions = {}, bundler = 'rspack' }) {
4635
4564
  inspectOptions.mode ? setNodeEnv(inspectOptions.mode) : getNodeEnv() || setNodeEnv('development');
4636
- let rspackConfigs = bundlerConfigs || (await initConfigs({
4637
- context,
4638
- pluginManager,
4639
- rsbuildOptions
4640
- })).rspackConfigs, rawBundlerConfigs = rspackConfigs.map((config, index)=>({
4565
+ let rawBundlerConfigs = bundlerConfigs.map((config, index)=>({
4641
4566
  name: config.name || String(index),
4642
4567
  content: stringifyConfig(config, inspectOptions.verbose)
4643
4568
  })), { rsbuildConfig, rawRsbuildConfig, environmentConfigs, rawEnvironmentConfigs } = getRsbuildInspectConfig({
@@ -4652,7 +4577,7 @@ async function inspectConfig({ context, pluginManager, rsbuildOptions, bundlerCo
4652
4577
  ...inspectOptions,
4653
4578
  outputPath
4654
4579
  },
4655
- configType: 'rspack'
4580
+ configType: bundler
4656
4581
  }), {
4657
4582
  rsbuildConfig: rawRsbuildConfig,
4658
4583
  environmentConfigs: rawEnvironmentConfigs.map((r)=>r.content),
@@ -4660,7 +4585,7 @@ async function inspectConfig({ context, pluginManager, rsbuildOptions, bundlerCo
4660
4585
  origin: {
4661
4586
  rsbuildConfig,
4662
4587
  environmentConfigs,
4663
- bundlerConfigs: rspackConfigs
4588
+ bundlerConfigs
4664
4589
  }
4665
4590
  };
4666
4591
  }
@@ -4745,17 +4670,18 @@ async function generateRspackConfig({ target, context, environment }) {
4745
4670
  if (config.plugins) {
4746
4671
  for (let plugin of config.plugins)if (plugin && void 0 === plugin.apply && 'name' in plugin && 'setup' in plugin) {
4747
4672
  let name = __WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.bold(__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow(plugin.name));
4748
- throw Error(`[rsbuild:plugin] "${name}" appears to be an Rsbuild plugin. It cannot be used as an Rspack plugin.`);
4673
+ throw Error(`${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim('[rsbuild:plugin]')} "${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow(name)}" appears to be an Rsbuild plugin. It cannot be used as an Rspack plugin.`);
4749
4674
  }
4750
4675
  }
4751
- return config.devServer && __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.warn(`[rsbuild:config] Find invalid Rspack config: "${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.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.`), rspackConfig;
4676
+ return config.devServer && __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.warn(`${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim('[rsbuild:config]')} Find invalid Rspack config: "${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.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.`), rspackConfig;
4752
4677
  }
4753
4678
  async function modifyRsbuildConfig(context) {
4679
+ var _context_config_plugins, _modified_plugins;
4754
4680
  __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.debug('modify Rsbuild config');
4755
- let [modified] = await context.hooks.modifyRsbuildConfig.callChain(context.config, {
4681
+ let pluginsCount = (null == (_context_config_plugins = context.config.plugins) ? void 0 : _context_config_plugins.length) ?? 0, [modified] = await context.hooks.modifyRsbuildConfig.callChain(context.config, {
4756
4682
  mergeRsbuildConfig: mergeRsbuildConfig
4757
4683
  });
4758
- context.config = modified, __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.debug('modify Rsbuild config done');
4684
+ context.config = modified, ((null == (_modified_plugins = modified.plugins) ? void 0 : _modified_plugins.length) ?? 0) !== pluginsCount && __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.warn(`${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim('[rsbuild]')} Cannot change plugins via ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow('modifyRsbuildConfig')} as plugins are already initialized when it executes.`), __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.debug('modify Rsbuild config done');
4759
4685
  }
4760
4686
  async function modifyEnvironmentConfig(context, config, name) {
4761
4687
  __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.debug(`modify Rsbuild environment(${name}) config`);
@@ -4807,11 +4733,11 @@ let initEnvironmentConfigs = (normalizedConfig, rootPath, specifiedEnvironments)
4807
4733
  }, config)
4808
4734
  })
4809
4735
  ]));
4810
- if (!Object.keys(resolvedEnvironments).length) throw Error(`[rsbuild:config] The current build is specified to run only in the ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow(null == specifiedEnvironments ? void 0 : specifiedEnvironments.join(','))} environment, but the configuration of the specified environment was not found.`);
4736
+ if (!Object.keys(resolvedEnvironments).length) throw Error(`${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim('[rsbuild:config]')} The current build is specified to run only in the ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow(null == specifiedEnvironments ? void 0 : specifiedEnvironments.join(','))} environment, but the configuration of the specified environment was not found.`);
4811
4737
  return resolvedEnvironments;
4812
4738
  }
4813
4739
  let defaultEnvironmentName = camelCase(rsbuildSharedConfig.output.target);
4814
- if (!isEnvironmentEnabled(defaultEnvironmentName)) throw Error(`[rsbuild:config] The current build is specified to run only in the ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow(null == specifiedEnvironments ? void 0 : specifiedEnvironments.join(','))} environment, but the configuration of the specified environment was not found.`);
4740
+ if (!isEnvironmentEnabled(defaultEnvironmentName)) throw Error(`${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim('[rsbuild:config]')} The current build is specified to run only in the ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow(null == specifiedEnvironments ? void 0 : specifiedEnvironments.join(','))} environment, but the configuration of the specified environment was not found.`);
4815
4741
  return {
4816
4742
  [defaultEnvironmentName]: applyEnvironmentDefaultConfig({
4817
4743
  ...rsbuildSharedConfig,
@@ -4825,7 +4751,7 @@ let initEnvironmentConfigs = (normalizedConfig, rootPath, specifiedEnvironments)
4825
4751
  })
4826
4752
  };
4827
4753
  }, validateRsbuildConfig = (config)=>{
4828
- if (config.server.base && !config.server.base.startsWith('/')) throw Error('[rsbuild:config] The "server.base" option should start with a slash, for example: "/base"');
4754
+ if (config.server.base && !config.server.base.startsWith('/')) throw Error(`${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim('[rsbuild:config]')} The ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow('"server.base"')} option should start with a slash, for example: "/base"`);
4829
4755
  };
4830
4756
  async function initRsbuildConfig({ context, pluginManager }) {
4831
4757
  if (context.normalizedConfig) return context.normalizedConfig;
@@ -4833,19 +4759,26 @@ async function initRsbuildConfig({ context, pluginManager }) {
4833
4759
  getPluginAPI: context.getPluginAPI,
4834
4760
  pluginManager
4835
4761
  }), await modifyRsbuildConfig(context);
4836
- let normalizedBaseConfig = normalizeConfig(context.config), environments = {}, mergedEnvironments = initEnvironmentConfigs(normalizedBaseConfig, context.rootPath, context.specifiedEnvironments), { dev: { hmr, assetPrefix, progressBar, lazyCompilation, writeToDisk, ...rsbuildSharedDev }, server } = normalizedBaseConfig;
4762
+ let normalizedBaseConfig = normalizeConfig(context.config), environments = {}, mergedEnvironments = initEnvironmentConfigs(normalizedBaseConfig, context.rootPath, context.specifiedEnvironments), { dev: { hmr, assetPrefix, progressBar, lazyCompilation, writeToDisk, ...rsbuildSharedDev }, server } = normalizedBaseConfig, tsconfigPaths = new Set();
4837
4763
  for (let [name, config] of Object.entries(mergedEnvironments)){
4838
- let environmentConfig = await modifyEnvironmentConfig(context, config, name);
4839
- environments[name] = {
4764
+ let environmentConfig = await modifyEnvironmentConfig(context, config, name), normalizedEnvironmentConfig = {
4840
4765
  ...environmentConfig,
4841
4766
  dev: {
4842
4767
  ...environmentConfig.dev,
4843
4768
  ...rsbuildSharedDev
4844
4769
  },
4845
4770
  server
4846
- };
4771
+ }, { tsconfigPath } = normalizedEnvironmentConfig.source;
4772
+ if (tsconfigPath) {
4773
+ let absoluteTsconfigPath = ensureAbsolutePath(context.rootPath, tsconfigPath);
4774
+ normalizedEnvironmentConfig.source.tsconfigPath = absoluteTsconfigPath, tsconfigPaths.add(absoluteTsconfigPath);
4775
+ }
4776
+ environments[name] = normalizedEnvironmentConfig;
4847
4777
  }
4848
- context.normalizedConfig = {
4778
+ tsconfigPaths.size && 'prefer-tsconfig' === normalizedBaseConfig.resolve.aliasStrategy && normalizedBaseConfig.dev.watchFiles.push({
4779
+ paths: Array.from(tsconfigPaths),
4780
+ type: 'reload-server'
4781
+ }), context.normalizedConfig = {
4849
4782
  ...normalizedBaseConfig,
4850
4783
  environments
4851
4784
  }, await updateEnvironmentContext(context, environments);
@@ -4894,9 +4827,83 @@ async function initConfigs({ context, pluginManager, rsbuildOptions }) {
4894
4827
  rspackConfigs
4895
4828
  };
4896
4829
  }
4830
+ function defineConfig(config) {
4831
+ return config;
4832
+ }
4833
+ let resolveConfigPath = (root, customConfig)=>{
4834
+ if (customConfig) {
4835
+ let customConfigPath = (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.isAbsolute)(customConfig) ? customConfig : (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(root, customConfig);
4836
+ if (__WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__.default.existsSync(customConfigPath)) return customConfigPath;
4837
+ __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.warn(`Cannot find config file: ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim(customConfigPath)}\n`);
4838
+ }
4839
+ for (let file of [
4840
+ 'rsbuild.config.mjs',
4841
+ 'rsbuild.config.ts',
4842
+ 'rsbuild.config.js',
4843
+ 'rsbuild.config.cjs',
4844
+ 'rsbuild.config.mts',
4845
+ 'rsbuild.config.cts'
4846
+ ]){
4847
+ let configFile = (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(root, file);
4848
+ if (__WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__.default.existsSync(configFile)) return configFile;
4849
+ }
4850
+ return null;
4851
+ };
4852
+ async function loadConfig_loadConfig({ cwd = process.cwd(), path, envMode, meta, loader = 'jiti' } = {}) {
4853
+ let configExport, configFilePath = resolveConfigPath(cwd, path);
4854
+ if (!configFilePath) return __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.debug('no config file found.'), {
4855
+ content: {},
4856
+ filePath: configFilePath
4857
+ };
4858
+ let applyMetaInfo = (config)=>(config._privateMeta = {
4859
+ configFilePath
4860
+ }, config);
4861
+ if ('native' === loader || /\.(?:js|mjs|cjs)$/.test(configFilePath)) try {
4862
+ let configFileURL = (0, __WEBPACK_EXTERNAL_MODULE_node_url_e96de089__.pathToFileURL)(configFilePath).href, exportModule = await import(`${configFileURL}?t=${Date.now()}`);
4863
+ configExport = exportModule.default ? exportModule.default : exportModule;
4864
+ } catch (err) {
4865
+ if ('native' === loader) throw __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.error(`Failed to load file with native loader: ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim(configFilePath)}`), err;
4866
+ __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.debug(`failed to load file with dynamic import: ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim(configFilePath)}`);
4867
+ }
4868
+ try {
4869
+ if (void 0 === configExport) {
4870
+ let { createJiti } = await import("jiti"), jiti = createJiti(constants_filename, {
4871
+ moduleCache: !1,
4872
+ interopDefault: !0,
4873
+ nativeModules: [
4874
+ '@rspack/core',
4875
+ "typescript"
4876
+ ]
4877
+ });
4878
+ configExport = await jiti.import(configFilePath, {
4879
+ default: !0
4880
+ });
4881
+ }
4882
+ } catch (err) {
4883
+ throw __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.error(`Failed to load file with jiti: ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim(configFilePath)}`), err;
4884
+ }
4885
+ if ('function' == typeof configExport) {
4886
+ let command = process.argv[2], nodeEnv = getNodeEnv(), result = await configExport({
4887
+ env: nodeEnv,
4888
+ command,
4889
+ envMode: envMode || nodeEnv,
4890
+ meta
4891
+ });
4892
+ if (void 0 === result) throw Error(`${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim('[rsbuild:loadConfig]')} The config function must return a config object.`);
4893
+ return {
4894
+ content: applyMetaInfo(result),
4895
+ filePath: configFilePath
4896
+ };
4897
+ }
4898
+ if (!isObject(configExport)) throw Error(`${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim('[rsbuild:loadConfig]')} The config must be an object or a function that returns an object, get ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow(configExport)}`);
4899
+ return __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.debug('loaded config file:', configFilePath), {
4900
+ content: applyMetaInfo(configExport),
4901
+ filePath: configFilePath
4902
+ };
4903
+ }
4897
4904
  let commonOpts = {}, getEnvDir = (cwd, envDir)=>envDir ? __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.default.isAbsolute(envDir) ? envDir : __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.default.join(cwd, envDir) : cwd, init_loadConfig = async (root)=>{
4898
4905
  var _config_server;
4899
- let { content: config, filePath } = await config_loadConfig({
4906
+ let { content: config, filePath } = await loadConfig_loadConfig({
4900
4907
  cwd: root,
4901
4908
  path: commonOpts.config,
4902
4909
  envMode: commonOpts.envMode,
@@ -4913,7 +4920,7 @@ let commonOpts = {}, getEnvDir = (cwd, envDir)=>envDir ? __WEBPACK_EXTERNAL_MODU
4913
4920
  async function init({ cliOptions, isRestart, isBuildWatch = !1 }) {
4914
4921
  cliOptions && (commonOpts = cliOptions);
4915
4922
  try {
4916
- let cwd = process.cwd(), root = commonOpts.root ? getAbsolutePath(cwd, commonOpts.root) : cwd, rsbuild = await createRsbuild({
4923
+ let cwd = process.cwd(), root = commonOpts.root ? ensureAbsolutePath(cwd, commonOpts.root) : cwd, rsbuild = await createRsbuild({
4917
4924
  cwd: root,
4918
4925
  rsbuildConfig: ()=>init_loadConfig(root),
4919
4926
  environment: commonOpts.environment,
@@ -4923,17 +4930,16 @@ async function init({ cliOptions, isRestart, isBuildWatch = !1 }) {
4923
4930
  }
4924
4931
  });
4925
4932
  return rsbuild.onBeforeCreateCompiler(()=>{
4926
- var _config_dev;
4927
4933
  if ('dev' !== rsbuild.context.action && !isBuildWatch) return;
4928
4934
  let files = [], config = rsbuild.getNormalizedConfig();
4929
- if (null == (_config_dev = config.dev) ? void 0 : _config_dev.watchFiles) for (let watchFilesConfig of castArray(config.dev.watchFiles)){
4930
- if ('reload-server' !== watchFilesConfig.type) continue;
4931
- let paths = castArray(watchFilesConfig.paths);
4932
- watchFilesConfig.options ? watchFilesForRestart({
4935
+ if (config.dev.watchFiles) for (let watchConfig of config.dev.watchFiles){
4936
+ if ('reload-server' !== watchConfig.type) continue;
4937
+ let paths = castArray(watchConfig.paths);
4938
+ watchConfig.options ? watchFilesForRestart({
4933
4939
  files: paths,
4934
4940
  rsbuild,
4935
4941
  isBuildWatch,
4936
- watchOptions: watchFilesConfig.options
4942
+ watchOptions: watchConfig.options
4937
4943
  }) : files.push(...paths);
4938
4944
  }
4939
4945
  watchFilesForRestart({
@@ -5058,7 +5064,7 @@ async function watchFilesForRestart({ files, rsbuild, isBuildWatch, watchOptions
5058
5064
  watcher.on('add', onChange), watcher.on('change', onChange), watcher.on('unlink', onChange);
5059
5065
  }
5060
5066
  let isCliShortcutsEnabled = (devConfig)=>devConfig.cliShortcuts && isTTY('stdin');
5061
- function setupCliShortcuts({ help = !0, openPage, closeServer, printUrls, restartServer, customShortcuts }) {
5067
+ async function setupCliShortcuts({ help = !0, openPage, closeServer, printUrls, restartServer, customShortcuts }) {
5062
5068
  let shortcuts = [
5063
5069
  {
5064
5070
  key: 'c',
@@ -5094,9 +5100,9 @@ function setupCliShortcuts({ help = !0, openPage, closeServer, printUrls, restar
5094
5100
  action: printUrls
5095
5101
  }
5096
5102
  ].filter(Boolean);
5097
- if (customShortcuts && !Array.isArray(shortcuts = customShortcuts(shortcuts))) throw Error('[rsbuild:config] `dev.cliShortcuts` must return an array of shortcuts.');
5098
- help && __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.log(` \u{279C} ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim('press')} ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.bold('h + enter')} ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim('to show shortcuts')}\n`);
5099
- let rl = __WEBPACK_EXTERNAL_MODULE_node_readline_91c31510__.default.createInterface({
5103
+ if (customShortcuts && !Array.isArray(shortcuts = customShortcuts(shortcuts))) throw Error(`${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim('[rsbuild:config]')} ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow('dev.cliShortcuts')} option must return an array of shortcuts.`);
5104
+ help && __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.log(!0 === help ? ` \u{279C} ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim('press')} ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.bold('h + enter')} ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim('to show shortcuts')}\n` : ` \u{279C} ${help}\n`);
5105
+ let { createInterface } = await import("node:readline"), rl = createInterface({
5100
5106
  input: process.stdin
5101
5107
  });
5102
5108
  return rl.on('line', (input)=>{
@@ -5111,9 +5117,9 @@ function setupCliShortcuts({ help = !0, openPage, closeServer, printUrls, restar
5111
5117
  };
5112
5118
  }
5113
5119
  async function getLocalhostResolvedAddress() {
5114
- let [defaultLookup, explicitLookup] = await Promise.all([
5115
- __WEBPACK_EXTERNAL_MODULE_node_dns_78d346ee__.promises.lookup('localhost'),
5116
- __WEBPACK_EXTERNAL_MODULE_node_dns_78d346ee__.promises.lookup('localhost', {
5120
+ let { promises: dns } = await import("node:dns"), [defaultLookup, explicitLookup] = await Promise.all([
5121
+ dns.lookup('localhost'),
5122
+ dns.lookup('localhost', {
5117
5123
  verbatim: !0
5118
5124
  })
5119
5125
  ]);
@@ -5226,7 +5232,7 @@ class SocketServer {
5226
5232
  __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.error(err);
5227
5233
  }), this.heartbeatTimer = setTimeout(this.checkSockets, 30000).unref(), this.wsServer.on('connection', (socket, req)=>{
5228
5234
  let queryStr = req.url ? req.url.split('?')[1] : '';
5229
- this.onConnect(socket, queryStr ? (0, __WEBPACK_EXTERNAL_MODULE_node_querystring_aeb3c0b4__.parse)(queryStr) : {});
5235
+ this.onConnect(socket, queryStr ? Object.fromEntries(new URLSearchParams(queryStr)) : {});
5230
5236
  });
5231
5237
  }
5232
5238
  updateStats(stats) {
@@ -5578,7 +5584,7 @@ class CompilationManager {
5578
5584
  clientPaths,
5579
5585
  devConfig,
5580
5586
  serverConfig
5581
- }), { base } = serverConfig, assetPrefixes = publicPaths.map(pathnameParse).map((prefix)=>base && '/' !== base ? stripBase(prefix, base) : prefix), wrapper = async (req, res, next)=>{
5587
+ }), { base } = serverConfig, assetPrefixes = publicPaths.map(getPathnameFromUrl).map((prefix)=>base && '/' !== base ? stripBase(prefix, base) : prefix), wrapper = async (req, res, next)=>{
5582
5588
  let { url } = req, assetPrefix = url && assetPrefixes.find((prefix)=>url.startsWith(prefix));
5583
5589
  assetPrefix && '/' !== assetPrefix ? (req.url = url.slice(assetPrefix.length - 1), middleware(req, res, (...args)=>{
5584
5590
  req.url = url, next(...args);
@@ -5811,7 +5817,7 @@ let ENCODING_REGEX = /\bgzip\b/, CONTENT_TYPE_REGEX = /text|javascript|\/json|xm
5811
5817
  }
5812
5818
  if (server.compress && middlewares.push(gzipMiddleware()), 'dev' === context.action && 'rspack' === context.bundlerType && dev.lazyCompilation && compilationManager) {
5813
5819
  let { compiler } = compilationManager;
5814
- 'object' == typeof dev.lazyCompilation && 'string' == typeof dev.lazyCompilation.serverUrl && context.devServer && (dev.lazyCompilation.serverUrl = replacePortPlaceholder(dev.lazyCompilation.serverUrl, context.devServer.port)), middlewares.push(__WEBPACK_EXTERNAL_MODULE__rspack_core_e0096ff7__.default.experiments.lazyCompilationMiddleware(helpers_isMultiCompiler(compiler) ? compiler.compilers[0] : compiler, dev.lazyCompilation));
5820
+ 'object' == typeof dev.lazyCompilation && 'string' == typeof dev.lazyCompilation.serverUrl && context.devServer && (dev.lazyCompilation.serverUrl = replacePortPlaceholder(dev.lazyCompilation.serverUrl, context.devServer.port)), middlewares.push(__WEBPACK_EXTERNAL_MODULE__rspack_core_e0096ff7__.rspack.experiments.lazyCompilationMiddleware(helpers_isMultiCompiler(compiler) ? compiler.compilers[0] : compiler, dev.lazyCompilation));
5815
5821
  }
5816
5822
  server.base && '/' !== server.base && middlewares.push(getBaseMiddleware({
5817
5823
  base: server.base
@@ -5866,13 +5872,14 @@ let ENCODING_REGEX = /\bgzip\b/, CONTENT_TYPE_REGEX = /text|javascript|\/json|xm
5866
5872
  middlewares
5867
5873
  };
5868
5874
  }, asModule = async (something, context, unlinked)=>{
5869
- if (something instanceof __WEBPACK_EXTERNAL_MODULE_node_vm_bd3d9cea__.default.Module) return something;
5875
+ let { Module, SyntheticModule } = await import("node:vm");
5876
+ if (something instanceof Module) return something;
5870
5877
  let exports = [
5871
5878
  ...new Set([
5872
5879
  'default',
5873
5880
  ...Object.keys(something)
5874
5881
  ])
5875
- ], m = new __WEBPACK_EXTERNAL_MODULE_node_vm_bd3d9cea__.default.SyntheticModule(exports, ()=>{
5882
+ ], m = new SyntheticModule(exports, ()=>{
5876
5883
  for (let name of exports)m.setExport(name, 'default' === name ? something : something[name]);
5877
5884
  }, {
5878
5885
  context
@@ -5925,7 +5932,7 @@ class BasicRunner {
5925
5932
  postExecute(_m, _file) {}
5926
5933
  createRunner() {
5927
5934
  this.requirers.set('entry', (_currentDirectory, _modulePath, _context = {})=>{
5928
- throw Error('[rsbuild:runner] Not implement');
5935
+ throw Error(`${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim('[rsbuild:runner]')} Not implemented`);
5929
5936
  });
5930
5937
  }
5931
5938
  constructor(_options){
@@ -5983,7 +5990,7 @@ class CommonJsRunner extends BasicRunner {
5983
5990
  };
5984
5991
  }
5985
5992
  createCjsRequirer() {
5986
- let requireCache = Object.create(null);
5993
+ let requireCache = Object.create(null), vm = cjs_require('node:vm');
5987
5994
  return (currentDirectory, modulePath, context = {})=>{
5988
5995
  let file = context.file || this.getFile(modulePath, currentDirectory);
5989
5996
  if (!file) return this.requirers.get('miss')(currentDirectory, modulePath);
@@ -5997,7 +6004,7 @@ class CommonJsRunner extends BasicRunner {
5997
6004
  })`;
5998
6005
  this.preExecute(code, file);
5999
6006
  let dynamicImport = Function('specifier', 'return import(specifier)');
6000
- return __WEBPACK_EXTERNAL_MODULE_node_vm_bd3d9cea__.default.runInThisContext(code, {
6007
+ return vm.runInThisContext(code, {
6001
6008
  filename: file.path,
6002
6009
  importModuleDynamically: async (specifier)=>await dynamicImport(specifier)
6003
6010
  }).call(m.exports, ...argValues), this.postExecute(m, file), m.exports;
@@ -6005,6 +6012,7 @@ class CommonJsRunner extends BasicRunner {
6005
6012
  }
6006
6013
  }
6007
6014
  var type_EsmMode = ((EsmMode = {})[EsmMode.Unknown = 0] = "Unknown", EsmMode[EsmMode.Evaluated = 1] = "Evaluated", EsmMode[EsmMode.Unlinked = 2] = "Unlinked", EsmMode);
6015
+ let esm_require = (0, __WEBPACK_EXTERNAL_MODULE_node_module_ab9f2194__.createRequire)(import.meta.url);
6008
6016
  class EsmRunner extends CommonJsRunner {
6009
6017
  createRunner() {
6010
6018
  var _this__options_compilerOptions_experiments;
@@ -6022,13 +6030,13 @@ class EsmRunner extends CommonJsRunner {
6022
6030
  });
6023
6031
  }
6024
6032
  createEsmRequirer() {
6025
- let esmCache = new Map(), esmIdentifier = this._options.name;
6033
+ let esmCache = new Map(), esmIdentifier = this._options.name, vm = esm_require('node:vm');
6026
6034
  return (currentDirectory, modulePath, context = {})=>{
6027
- if (!__WEBPACK_EXTERNAL_MODULE_node_vm_bd3d9cea__.default.SourceTextModule) throw Error('[rsbuild:runner] Running ESM bundle needs add Node.js option "--experimental-vm-modules".');
6035
+ if (!vm.SourceTextModule) throw Error(`${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim('[rsbuild:runner]')} Running ESM bundle needs add Node.js option ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow('--experimental-vm-modules')}.`);
6028
6036
  let _require = this.getRequire(), file = context.file || this.getFile(modulePath, currentDirectory);
6029
6037
  if (!file) return this.requirers.get('miss')(currentDirectory, modulePath);
6030
6038
  let esm = esmCache.get(file.path);
6031
- return (esm || (esm = new __WEBPACK_EXTERNAL_MODULE_node_vm_bd3d9cea__.default.SourceTextModule(file.content, {
6039
+ return (esm || (esm = new vm.SourceTextModule(file.content, {
6032
6040
  identifier: `${esmIdentifier}-${file.path}`,
6033
6041
  url: `${(0, __WEBPACK_EXTERNAL_MODULE_node_url_e96de089__.pathToFileURL)(file.path).href}?${esmIdentifier}`,
6034
6042
  initializeImportMeta: (meta, _)=>{
@@ -6059,7 +6067,7 @@ class BasicRunnerFactory {
6059
6067
  name: this.name,
6060
6068
  ...options
6061
6069
  }, { compilerOptions } = options;
6062
- if ('web' === compilerOptions.target || 'webworker' === compilerOptions.target) throw Error(`[rsbuild:runner] Not support run "${compilerOptions.target}" resource in Rsbuild server`);
6070
+ if ('web' === compilerOptions.target || 'webworker' === compilerOptions.target) throw Error(`${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim('[rsbuild:runner]')} Not support run ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow(compilerOptions.target)} resource in Rsbuild server`);
6063
6071
  return new EsmRunner(runnerOptions);
6064
6072
  }
6065
6073
  constructor(name){
@@ -6079,7 +6087,7 @@ let runner_run = async ({ bundlePath, ...runnerFactoryOptions })=>new BasicRunne
6079
6087
  entrypoints: !0,
6080
6088
  outputPath: !0
6081
6089
  });
6082
- if (!(null == entrypoints ? void 0 : entrypoints[entryName])) throw Error(`[rsbuild:loadBundle] Can't find entry: "${entryName}"`);
6090
+ if (!(null == entrypoints ? void 0 : entrypoints[entryName])) throw Error(`${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim('[rsbuild:loadBundle]')} Can't find entry: ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow(entryName)}`);
6083
6091
  let { chunks: entryChunks = [] } = entrypoints[entryName], files = entryChunks.reduce((prev, entryChunkName)=>{
6084
6092
  let chunk = null == chunks ? void 0 : chunks.find((chunk)=>{
6085
6093
  var _chunk_names;
@@ -6087,8 +6095,8 @@ let runner_run = async ({ bundlePath, ...runnerFactoryOptions })=>new BasicRunne
6087
6095
  });
6088
6096
  return (null == chunk ? void 0 : chunk.files) ? prev.concat(chunk.files.filter((file)=>!file.endsWith('.css'))) : prev;
6089
6097
  }, []);
6090
- if (0 === files.length) throw Error(`[rsbuild:loadBundle] Failed to get bundle by entryName: "${entryName}"`);
6091
- if (files.length > 1) throw Error(`[rsbuild:loadBundle] Only support load single entry chunk, but got ${files.length}: ${files.join(',')}`);
6098
+ if (0 === files.length) throw Error(`${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim('[rsbuild:loadBundle]')} Failed to get bundle by entryName: ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow(entryName)}`);
6099
+ if (files.length > 1) throw Error(`${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim('[rsbuild:loadBundle]')} Only support load single entry chunk, but got ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow(files.length)}: ${files.join(',')}`);
6092
6100
  let allChunkFiles = (null == chunks ? void 0 : chunks.flatMap((c)=>c.files).map((file)=>(0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(outputPath, file))) || [];
6093
6101
  return await runner_run({
6094
6102
  bundlePath: files[0],
@@ -6099,7 +6107,7 @@ let runner_run = async ({ bundlePath, ...runnerFactoryOptions })=>new BasicRunne
6099
6107
  });
6100
6108
  }, getTransformedHtml = async (entryName, utils)=>{
6101
6109
  let { htmlPaths, distPath } = utils.environment, htmlPath = htmlPaths[entryName];
6102
- if (!htmlPath) throw Error(`[rsbuild:getTransformedHtml] Failed to get HTML file by entryName: "${entryName}"`);
6110
+ if (!htmlPath) throw Error(`${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim('[rsbuild:getTransformedHtml]')} Failed to get HTML file by entryName: ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow(entryName)}`);
6103
6111
  let fileName = (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(distPath, htmlPath);
6104
6112
  return utils.readFileSync(fileName);
6105
6113
  }, createCacheableFunction = (getter)=>{
@@ -6172,7 +6180,7 @@ async function devServer_createDevServer(options, createCompiler, config, { comp
6172
6180
  });
6173
6181
  }) : Promise.resolve(), startCompile = async ()=>{
6174
6182
  let compiler = customCompiler || await createCompiler();
6175
- if (!compiler) throw Error('[rsbuild:server] Failed to get compiler instance.');
6183
+ if (!compiler) throw Error(`${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim('[rsbuild:server]')} Failed to get compiler instance.`);
6176
6184
  let publicPaths = helpers_isMultiCompiler(compiler) ? compiler.compilers.map(getPublicPathFromCompiler) : [
6177
6185
  getPublicPathFromCompiler(compiler)
6178
6186
  ], compilationManager = new CompilationManager({
@@ -6186,7 +6194,7 @@ async function devServer_createDevServer(options, createCompiler, config, { comp
6186
6194
  environments: context.environments
6187
6195
  });
6188
6196
  return await compilationManager.init(), compilationManager;
6189
- }, protocol = https ? 'https' : 'http', urls = getAddressUrls({
6197
+ }, protocol = https ? 'https' : 'http', urls = await getAddressUrls({
6190
6198
  protocol,
6191
6199
  port,
6192
6200
  host
@@ -6210,9 +6218,9 @@ async function devServer_createDevServer(options, createCompiler, config, { comp
6210
6218
  ]);
6211
6219
  };
6212
6220
  middlewareMode || registerCleanup(closeServer);
6213
- let beforeCreateCompiler = ()=>{
6221
+ let beforeCreateCompiler = async ()=>{
6214
6222
  if (printUrls(), cliShortcutsEnabled) {
6215
- let shortcutsOptions = 'boolean' == typeof devConfig.cliShortcuts ? {} : devConfig.cliShortcuts, cleanup = setupCliShortcuts({
6223
+ let shortcutsOptions = 'boolean' == typeof devConfig.cliShortcuts ? {} : devConfig.cliShortcuts, cleanup = await setupCliShortcuts({
6216
6224
  openPage,
6217
6225
  closeServer,
6218
6226
  printUrls,
@@ -6229,18 +6237,18 @@ async function devServer_createDevServer(options, createCompiler, config, { comp
6229
6237
  name,
6230
6238
  {
6231
6239
  getStats: async ()=>{
6232
- if (!compilationManager) throw Error('[rsbuild:server] Can not call `getStats` when `runCompile` is false');
6240
+ if (!compilationManager) throw Error(`${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim('[rsbuild:server]')} Can not call ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow('getStats')} when ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow('runCompile')} is false`);
6233
6241
  return await waitFirstCompileDone, lastStats[environment.index];
6234
6242
  },
6235
6243
  loadBundle: async (entryName)=>{
6236
- if (!compilationManager) throw Error('[rsbuild:server] Can not call `loadBundle` when `runCompile` is false');
6244
+ if (!compilationManager) throw Error(`${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim('[rsbuild:server]')} Can not call ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow('loadBundle')} when ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow('runCompile')} is false`);
6237
6245
  return await waitFirstCompileDone, cacheableLoadBundle(lastStats[environment.index], entryName, {
6238
6246
  readFileSync: compilationManager.readFileSync,
6239
6247
  environment
6240
6248
  });
6241
6249
  },
6242
6250
  getTransformedHtml: async (entryName)=>{
6243
- if (!compilationManager) throw Error('[rsbuild:server] Can not call `getTransformedHtml` when `runCompile` is false');
6251
+ if (!compilationManager) throw Error(`${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim('[rsbuild:server]')} Can not call ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow('getTransformedHtml')} when ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow('runCompile')} is false`);
6244
6252
  return await waitFirstCompileDone, cacheableTransformedHtml(lastStats[environment.index], entryName, {
6245
6253
  readFileSync: compilationManager.readFileSync,
6246
6254
  environment
@@ -6260,7 +6268,7 @@ async function devServer_createDevServer(options, createCompiler, config, { comp
6260
6268
  data
6261
6269
  }),
6262
6270
  listen: async ()=>{
6263
- if (!httpServer) throw Error('[rsbuild:server] Can not listen dev server as `server.middlewareMode` is enabled.');
6271
+ if (!httpServer) throw Error(`${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim('[rsbuild:server]')} Can not listen dev server as ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow('server.middlewareMode')} is enabled.`);
6264
6272
  let serverTerminator = getServerTerminator(httpServer);
6265
6273
  return __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.debug('listen dev server'), context.hooks.onCloseDevServer.tap(serverTerminator), new Promise((resolve)=>{
6266
6274
  httpServer.listen({
@@ -6295,7 +6303,7 @@ async function devServer_createDevServer(options, createCompiler, config, { comp
6295
6303
  server: devServerAPI,
6296
6304
  environments: context.environments
6297
6305
  })).filter((item)=>'function' == typeof item);
6298
- runCompile ? context.hooks.onBeforeCreateCompiler.tap(beforeCreateCompiler) : beforeCreateCompiler();
6306
+ runCompile ? context.hooks.onBeforeCreateCompiler.tap(beforeCreateCompiler) : await beforeCreateCompiler();
6299
6307
  let compilationManager = runCompile ? await startCompile() : void 0;
6300
6308
  for (let item of (fileWatcher = await setupWatchFiles({
6301
6309
  dev: devConfig,
@@ -6335,7 +6343,7 @@ async function createCompiler_createCompiler(options) {
6335
6343
  if (await context.hooks.onBeforeCreateCompiler.callBatch({
6336
6344
  bundlerConfigs: rspackConfigs,
6337
6345
  environments: context.environments
6338
- }), !await isSatisfyRspackVersion(__WEBPACK_EXTERNAL_MODULE__rspack_core_e0096ff7__.rspack.rspackVersion)) throw Error(`[rsbuild] The current Rspack version does not meet the requirements, the minimum supported version of Rspack is ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.green(rspackMinVersion)}`);
6346
+ }), !await isSatisfyRspackVersion(__WEBPACK_EXTERNAL_MODULE__rspack_core_e0096ff7__.rspack.rspackVersion)) throw Error(`${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim('[rsbuild]')} The current Rspack version does not meet the requirements, the minimum supported version of Rspack is ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.green(rspackMinVersion)}`);
6339
6347
  let isMultiCompiler = rspackConfigs.length > 1, compiler = isMultiCompiler ? (0, __WEBPACK_EXTERNAL_MODULE__rspack_core_e0096ff7__.rspack)(rspackConfigs) : (0, __WEBPACK_EXTERNAL_MODULE__rspack_core_e0096ff7__.rspack)(rspackConfigs[0]), isVersionLogged = !1, isCompiling = !1, logRspackVersion = ()=>{
6340
6348
  isVersionLogged || (__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.debug(`use Rspack v${__WEBPACK_EXTERNAL_MODULE__rspack_core_e0096ff7__.rspack.rspackVersion}`), isVersionLogged = !0);
6341
6349
  };
@@ -6472,12 +6480,20 @@ let RSPACK_BUILD_ERROR = 'Rspack build failed.', build_build = async (initOption
6472
6480
  });
6473
6481
  return rspackConfigs;
6474
6482
  },
6475
- inspectConfig: async (inspectOptions)=>inspectConfig({
6483
+ async inspectConfig (inspectOptions) {
6484
+ let bundlerConfigs = (await initConfigs({
6485
+ context,
6486
+ pluginManager,
6487
+ rsbuildOptions
6488
+ })).rspackConfigs;
6489
+ return inspectConfig({
6476
6490
  context,
6477
6491
  pluginManager,
6478
6492
  rsbuildOptions,
6479
- inspectOptions
6480
- })
6493
+ inspectOptions,
6494
+ bundlerConfigs
6495
+ });
6496
+ }
6481
6497
  };
6482
6498
  };
6483
6499
  function prodServer_define_property(obj, key, value) {
@@ -6544,7 +6560,7 @@ async function startProdServer(context, config, { getPortSilently } = {}) {
6544
6560
  pwd: context.rootPath,
6545
6561
  output: {
6546
6562
  path: context.distPath,
6547
- assetPrefixes: Object.values(context.environments).map((e)=>pathnameParse(e.config.output.assetPrefix))
6563
+ assetPrefixes: Object.values(context.environments).map((e)=>getPathnameFromUrl(e.config.output.assetPrefix))
6548
6564
  },
6549
6565
  serverConfig
6550
6566
  }, middlewares);
@@ -6564,7 +6580,7 @@ async function startProdServer(context, config, { getPortSilently } = {}) {
6564
6580
  routes,
6565
6581
  environments: context.environments
6566
6582
  });
6567
- let protocol = https ? 'https' : 'http', urls = getAddressUrls({
6583
+ let protocol = https ? 'https' : 'http', urls = await getAddressUrls({
6568
6584
  protocol,
6569
6585
  port,
6570
6586
  host
@@ -6591,7 +6607,7 @@ async function startProdServer(context, config, { getPortSilently } = {}) {
6591
6607
  });
6592
6608
  if (printUrls(), cliShortcutsEnabled) {
6593
6609
  let shortcutsOptions = 'boolean' == typeof config.dev.cliShortcuts ? {} : config.dev.cliShortcuts;
6594
- setupCliShortcuts({
6610
+ await setupCliShortcuts({
6595
6611
  openPage,
6596
6612
  closeServer,
6597
6613
  printUrls,
@@ -6743,7 +6759,7 @@ async function createRsbuild(options = {}) {
6743
6759
  let { before, environment = RSBUILD_ALL_ENVIRONMENT_SYMBOL } = options || {};
6744
6760
  for (let newPlugin of newPlugins)if (newPlugin) {
6745
6761
  let type = typeof newPlugin;
6746
- if ('object' !== type || null === newPlugin) throw Error(`[rsbuild:plugin] Expect Rsbuild plugin instance to be an object, but got ${type}.`);
6762
+ if ('object' !== type || null === newPlugin) throw Error(`${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim('[rsbuild:plugin]')} Expect Rsbuild plugin instance to be an object, but got ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow(type)}.`);
6747
6763
  if (!isFunction(newPlugin.setup)) {
6748
6764
  if (isFunction(newPlugin.apply)) {
6749
6765
  let { name = 'SomeWebpackPlugin' } = newPlugin.constructor || {};
@@ -6761,7 +6777,7 @@ async function createRsbuild(options = {}) {
6761
6777
  `)
6762
6778
  ].join('\n'));
6763
6779
  }
6764
- throw Error(`[rsbuild:plugin] Expect the setup function of Rsbuild plugin to be a function, but got ${type}.`);
6780
+ throw Error(`${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim('[rsbuild:plugin]')} Expect the setup function of Rsbuild plugin to be a function, but got ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow(type)}.`);
6765
6781
  }
6766
6782
  if (before) {
6767
6783
  let index = plugins.findIndex((item)=>item.instance.name === before);
@@ -6807,12 +6823,12 @@ async function createRsbuild(options = {}) {
6807
6823
  if (context.normalizedConfig) {
6808
6824
  if (null == options ? void 0 : options.environment) {
6809
6825
  let config = context.normalizedConfig.environments[options.environment];
6810
- if (!config) throw Error(`[rsbuild] Cannot find normalized config by environment: ${options.environment}.`);
6826
+ if (!config) throw Error(`${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim('[rsbuild]')} Cannot find normalized config by environment: ${options.environment}.`);
6811
6827
  return config;
6812
6828
  }
6813
6829
  return context.normalizedConfig;
6814
6830
  }
6815
- throw Error('[rsbuild] Cannot access normalized config until modifyRsbuildConfig is called.');
6831
+ throw Error(`${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim('[rsbuild]')} Cannot access normalized config until ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow('modifyRsbuildConfig')} is called.`);
6816
6832
  }
6817
6833
  let getRsbuildConfig = (type = 'current')=>{
6818
6834
  switch(type){
@@ -6823,7 +6839,7 @@ async function createRsbuild(options = {}) {
6823
6839
  case 'normalized':
6824
6840
  return getNormalizedConfig();
6825
6841
  }
6826
- throw Error('[rsbuild] `getRsbuildConfig` get an invalid type param.');
6842
+ throw Error(`${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim('[rsbuild]')} ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow('getRsbuildConfig')} get an invalid type param.`);
6827
6843
  }, exposed = [], expose = (id, api)=>{
6828
6844
  exposed.push({
6829
6845
  id,
@@ -7006,11 +7022,11 @@ async function createRsbuild(options = {}) {
7006
7022
  pluginManager
7007
7023
  }), { distPath } = context, { checkDistDir = !0 } = options;
7008
7024
  if (checkDistDir) {
7009
- if (!(0, __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__.existsSync)(distPath)) throw Error(`[rsbuild:preview] The output directory ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow(distPath)} does not exist, please build the project before previewing.`);
7025
+ if (!(0, __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__.existsSync)(distPath)) throw Error(`${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim('[rsbuild:preview]')} The output directory ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow(distPath)} does not exist, please build the project before previewing.`);
7010
7026
  if (function(path) {
7011
7027
  let files = __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__.default.readdirSync(path);
7012
7028
  return 0 === files.length || 1 === files.length && '.git' === files[0];
7013
- }(distPath)) throw Error(`[rsbuild:preview] The output directory ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow(distPath)} is empty, please build the project before previewing.`);
7029
+ }(distPath)) throw Error(`${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim('[rsbuild:preview]')} The output directory ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow(distPath)} is empty, please build the project before previewing.`);
7014
7030
  }
7015
7031
  return startProdServer(context, config, options);
7016
7032
  },
@@ -7388,11 +7404,11 @@ async function runCLI() {
7388
7404
  }
7389
7405
  process.title = 'rsbuild-node';
7390
7406
  let { npm_execpath } = process.env;
7391
- (!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) && console.log(), __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.greet(` Rsbuild v1.3.20\n`);
7407
+ (!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) && console.log(), __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.greet(` Rsbuild v1.3.22\n`);
7392
7408
  try {
7393
7409
  !function() {
7394
7410
  let cli = cac_dist('rsbuild');
7395
- cli.help(), cli.version("1.3.20"), applyCommonOptions(cli);
7411
+ cli.help(), cli.version("1.3.22"), applyCommonOptions(cli);
7396
7412
  let devCommand = cli.command('', 'starting the dev server').alias('dev'), buildCommand = cli.command('build', 'build the app for production'), previewCommand = cli.command('preview', 'preview the production build locally'), inspectCommand = cli.command('inspect', 'inspect the Rspack and Rsbuild configs');
7397
7413
  applyServerOptions(devCommand), applyServerOptions(previewCommand), devCommand.action(async (options)=>{
7398
7414
  try {
@@ -7443,6 +7459,6 @@ async function runCLI() {
7443
7459
  __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.error('Failed to start Rsbuild CLI.'), __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.error(err);
7444
7460
  }
7445
7461
  }
7446
- let src_version = "1.3.20";
7462
+ let src_version = "1.3.22";
7447
7463
  var __webpack_exports__logger = __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger, __webpack_exports__rspack = __WEBPACK_EXTERNAL_MODULE__rspack_core_e0096ff7__.rspack;
7448
- export { PLUGIN_CSS_NAME, PLUGIN_SWC_NAME, createRsbuild, defaultAllowedOrigins, defineConfig, ensureAssetPrefix, config_loadConfig as loadConfig, loadEnv, mergeRsbuildConfig, runCLI, src_version as version, __webpack_exports__logger as logger, __webpack_exports__rspack as rspack };
7464
+ export { PLUGIN_CSS_NAME, PLUGIN_SWC_NAME, createRsbuild, defaultAllowedOrigins, defineConfig, ensureAssetPrefix, loadConfig_loadConfig as loadConfig, loadEnv, mergeRsbuildConfig, runCLI, src_version as version, __webpack_exports__logger as logger, __webpack_exports__rspack as rspack };