@rsbuild/core 1.3.21 → 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
@@ -19,13 +19,6 @@ 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
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__) {
@@ -1273,7 +1266,7 @@ function getFilename(config, type, isProd, isServer) {
1273
1266
  case 'assets':
1274
1267
  return filename.assets ?? `[name]${hash}[ext]`;
1275
1268
  default:
1276
- 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')}`);
1277
1270
  }
1278
1271
  }
1279
1272
  let applyToCompiler = (compiler, apply)=>{
@@ -1297,7 +1290,7 @@ let camelCase = (input)=>input.replace(/[-_](\w)/g, (_, c)=>c.toUpperCase()), pr
1297
1290
  function loadEnv({ cwd = process.cwd(), mode = getNodeEnv(), prefixes = [
1298
1291
  'PUBLIC_'
1299
1292
  ], processEnv = process.env } = {}) {
1300
- 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.`);
1301
1294
  let filePaths = [
1302
1295
  '.env',
1303
1296
  '.env.local',
@@ -1437,7 +1430,7 @@ let configCache = {}, OVERRIDE_PATHS = [
1437
1430
  merged[key] = merge(x[key], y[key], childPath);
1438
1431
  }
1439
1432
  return merged;
1440
- }, 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 = ()=>({
1441
1434
  hmr: !0,
1442
1435
  liveReload: !0,
1443
1436
  watchFiles: [],
@@ -1465,7 +1458,6 @@ let configCache = {}, OVERRIDE_PATHS = [
1465
1458
  },
1466
1459
  middlewareMode: !1
1467
1460
  }), getDefaultSourceConfig = ()=>({
1468
- alias: {},
1469
1461
  define: {},
1470
1462
  preEntry: [],
1471
1463
  decorators: {
@@ -1547,7 +1539,7 @@ let configCache = {}, OVERRIDE_PATHS = [
1547
1539
  exportLocalsConvention: 'camelCase'
1548
1540
  },
1549
1541
  emitAssets: !0
1550
- }), 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'))), {
1551
1543
  alias: {
1552
1544
  '@swc/helpers': swcHelpersPath
1553
1545
  },
@@ -1591,82 +1583,7 @@ let configCache = {}, OVERRIDE_PATHS = [
1591
1583
  return Array.isArray(watchFiles) || (mergedConfig.dev.watchFiles = [
1592
1584
  watchFiles
1593
1585
  ]), mergedConfig;
1594
- };
1595
- function defineConfig(config) {
1596
- return config;
1597
- }
1598
- let resolveConfigPath = (root, customConfig)=>{
1599
- if (customConfig) {
1600
- let customConfigPath = (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.isAbsolute)(customConfig) ? customConfig : (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(root, customConfig);
1601
- if (__WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__.default.existsSync(customConfigPath)) return customConfigPath;
1602
- __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`);
1603
- }
1604
- for (let file of [
1605
- 'rsbuild.config.mjs',
1606
- 'rsbuild.config.ts',
1607
- 'rsbuild.config.js',
1608
- 'rsbuild.config.cjs',
1609
- 'rsbuild.config.mts',
1610
- 'rsbuild.config.cts'
1611
- ]){
1612
- let configFile = (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(root, file);
1613
- if (__WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__.default.existsSync(configFile)) return configFile;
1614
- }
1615
- return null;
1616
- };
1617
- async function config_loadConfig({ cwd = process.cwd(), path, envMode, meta, loader = 'jiti' } = {}) {
1618
- let configExport, configFilePath = resolveConfigPath(cwd, path);
1619
- if (!configFilePath) return __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.debug('no config file found.'), {
1620
- content: {},
1621
- filePath: configFilePath
1622
- };
1623
- let applyMetaInfo = (config)=>(config._privateMeta = {
1624
- configFilePath
1625
- }, config);
1626
- if ('native' === loader || /\.(?:js|mjs|cjs)$/.test(configFilePath)) try {
1627
- let configFileURL = (0, __WEBPACK_EXTERNAL_MODULE_node_url_e96de089__.pathToFileURL)(configFilePath).href, exportModule = await import(`${configFileURL}?t=${Date.now()}`);
1628
- configExport = exportModule.default ? exportModule.default : exportModule;
1629
- } catch (err) {
1630
- 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;
1631
- __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)}`);
1632
- }
1633
- try {
1634
- if (void 0 === configExport) {
1635
- let { createJiti } = await import("jiti"), jiti = createJiti(constants_filename, {
1636
- moduleCache: !1,
1637
- interopDefault: !0,
1638
- nativeModules: [
1639
- '@rspack/core',
1640
- "typescript"
1641
- ]
1642
- });
1643
- configExport = await jiti.import(configFilePath, {
1644
- default: !0
1645
- });
1646
- }
1647
- } catch (err) {
1648
- 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;
1649
- }
1650
- if ('function' == typeof configExport) {
1651
- let command = process.argv[2], nodeEnv = getNodeEnv(), result = await configExport({
1652
- env: nodeEnv,
1653
- command,
1654
- envMode: envMode || nodeEnv,
1655
- meta
1656
- });
1657
- if (void 0 === result) throw Error('[rsbuild:loadConfig] The config function must return a config object.');
1658
- return {
1659
- content: applyMetaInfo(result),
1660
- filePath: configFilePath
1661
- };
1662
- }
1663
- 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)}`);
1664
- return __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.debug('loaded config file:', configFilePath), {
1665
- content: applyMetaInfo(configExport),
1666
- filePath: configFilePath
1667
- };
1668
- }
1669
- let normalizePublicDirs = (publicDir)=>{
1586
+ }, normalizePublicDirs = (publicDir)=>{
1670
1587
  if (!1 === publicDir) return [];
1671
1588
  let defaultConfig = {
1672
1589
  name: 'public',
@@ -1688,7 +1605,7 @@ let normalizePublicDirs = (publicDir)=>{
1688
1605
  let allLines = [];
1689
1606
  function getPlugin(name) {
1690
1607
  let targets = plugins.filter((item)=>item.instance.name === name);
1691
- 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`);
1692
1609
  return targets;
1693
1610
  }
1694
1611
  for (let plugin of plugins){
@@ -1709,7 +1626,7 @@ let normalizePublicDirs = (publicDir)=>{
1709
1626
  if (allLines.length) {
1710
1627
  let restInRingPoints = {};
1711
1628
  for (let l of allLines)restInRingPoints[l[0]] = !0, restInRingPoints[l[1]] = !0;
1712
- 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(','))}`);
1713
1630
  }
1714
1631
  return sortedPoint;
1715
1632
  };
@@ -1970,7 +1887,7 @@ let mapProcessAssetsStage = (compiler, stage)=>{
1970
1887
  case 'report':
1971
1888
  return Compilation.PROCESS_ASSETS_STAGE_REPORT;
1972
1889
  default:
1973
- 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}`);
1974
1891
  }
1975
1892
  }, browsersListCache = new Map();
1976
1893
  async function getBrowserslist(path) {
@@ -2025,7 +1942,7 @@ let getEnvironmentHTMLPaths = (entry, config)=>'web' !== config.output.target ||
2025
1942
  let filename;
2026
1943
  filename = config.output.filename.html ? config.output.filename.html.replace('[name]', entryName) : 'flat' === config.html.outputStructure ? `${entryName}.html` : `${entryName}/index.html`;
2027
1944
  let prefix = config.output.distPath.html;
2028
- 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));
2029
1946
  }(key, config)), prev;
2030
1947
  }, {});
2031
1948
  async function updateEnvironmentContext(context, configs) {
@@ -2052,7 +1969,7 @@ async function updateEnvironmentContext(context, configs) {
2052
1969
  async function createContext(options, userConfig) {
2053
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';
2054
1971
  return {
2055
- version: "1.3.21",
1972
+ version: "1.3.22",
2056
1973
  rootPath,
2057
1974
  distPath: '',
2058
1975
  cachePath,
@@ -2126,21 +2043,21 @@ let pluginAppIcon = ()=>({
2126
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 = [];
2127
2044
  for (let icon of icons){
2128
2045
  if ('web-app-manifest' === icon.target && !appIcon.name) {
2129
- 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"')}.`);
2130
2047
  continue;
2131
2048
  }
2132
2049
  if (!icon.isURL) {
2133
2050
  if (!compilation.inputFileSystem) {
2134
- 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.`);
2135
2052
  continue;
2136
2053
  }
2137
2054
  if (!await fileExistsByCompilation(compilation, icon.absolutePath)) {
2138
- 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)}.`);
2139
2056
  continue;
2140
2057
  }
2141
2058
  let source = await (0, __WEBPACK_EXTERNAL_MODULE_node_util_1b29d436__.promisify)(compilation.inputFileSystem.readFile)(icon.absolutePath);
2142
2059
  if (!source) {
2143
- 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)}.`);
2144
2061
  continue;
2145
2062
  }
2146
2063
  compilation.emitAsset(icon.relativePath, new sources.RawSource(source));
@@ -2546,7 +2463,7 @@ let pluginHelper_require = (0, __WEBPACK_EXTERNAL_MODULE_node_module_ab9f2194__.
2546
2463
  plugin && (pluginHelper_htmlPlugin = plugin);
2547
2464
  }, getHTMLPlugin = ()=>(pluginHelper_htmlPlugin || (pluginHelper_htmlPlugin = pluginHelper_require('../compiled/html-rspack-plugin/index.js')), pluginHelper_htmlPlugin), setCssExtractPlugin = (plugin)=>{
2548
2465
  cssExtractPlugin = plugin;
2549
- }, 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)=>{
2550
2467
  let options = {};
2551
2468
  options.minimizerOptions ||= {}, options.minimizerOptions.format ||= {};
2552
2469
  let { removeConsole } = config.performance;
@@ -2570,26 +2487,27 @@ let pluginHelper_require = (0, __WEBPACK_EXTERNAL_MODULE_node_module_ab9f2194__.
2570
2487
  options.minimizerOptions.format.comments = !1, options.extractComments = !1;
2571
2488
  }
2572
2489
  return (options.minimizerOptions.format.asciiOnly = 'ascii' === config.output.charset, jsOptions) ? cjs_default()(options, jsOptions) : options;
2573
- }, parseMinifyOptions = (config, isProd)=>{
2574
- let { minify } = config.output;
2575
- return !1 !== minify && isProd ? !0 === minify ? {
2576
- minifyJs: !0,
2577
- minifyCss: !0
2578
- } : {
2579
- minifyJs: !1 !== minify.js,
2580
- 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),
2581
2502
  jsOptions: minify.jsOptions,
2582
2503
  cssOptions: minify.cssOptions
2583
- } : {
2584
- minifyJs: !1,
2585
- minifyCss: !1
2586
2504
  };
2587
2505
  }, pluginMinimize = ()=>({
2588
2506
  name: 'rsbuild:minimize',
2589
2507
  setup (api) {
2590
2508
  let isRspack = 'rspack' === api.context.bundlerType;
2591
- api.modifyBundlerChain(async (chain, { isProd, environment, CHAIN_ID })=>{
2592
- 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);
2593
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, [
2594
2512
  getSwcMinimizerOptions(config, jsOptions)
2595
2513
  ]).end(), minifyCss && isRspack) {
@@ -2679,7 +2597,7 @@ let isPostcssPluginCreator = (plugin)=>'function' == typeof plugin && !0 === plu
2679
2597
  if ('function' == typeof postcssOptions) {
2680
2598
  let postcssOptionsWrapper = (loaderContext)=>{
2681
2599
  let options = postcssOptions(loaderContext);
2682
- 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)}.`);
2683
2601
  return updatePostcssOptions({
2684
2602
  ...userOptions,
2685
2603
  ...options,
@@ -2740,9 +2658,9 @@ let isPostcssPluginCreator = (plugin)=>'function' == typeof plugin && !0 === plu
2740
2658
  var _postcssLoaderOptions_postcssOptions_plugins, _postcssLoaderOptions_postcssOptions;
2741
2659
  if ('rspack' === api.context.bundlerType && !1 !== config.tools.lightningcssLoader) {
2742
2660
  importLoaders++;
2743
- let { minifyCss } = parseMinifyOptions(config, isProd);
2661
+ let { minifyCss } = parseMinifyOptions(config);
2744
2662
  updateRules((rule, type)=>{
2745
- 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);
2746
2664
  rule.use(CHAIN_ID.USE.LIGHTNINGCSS).loader('builtin:lightningcss-loader').options(lightningcssOptions);
2747
2665
  });
2748
2666
  }
@@ -2813,7 +2731,7 @@ let isPostcssPluginCreator = (plugin)=>'function' == typeof plugin && !0 === plu
2813
2731
  if (!value) return;
2814
2732
  let check = (value)=>{
2815
2733
  let pathKey = Object.keys(value).find((key)=>'path' === key.toLowerCase() && value[key] === process.env[key]);
2816
- 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.`);
2817
2735
  };
2818
2736
  if ('object' == typeof value) return check(value);
2819
2737
  if ('string' == typeof value) try {
@@ -2839,7 +2757,7 @@ let isPostcssPluginCreator = (plugin)=>'function' == typeof plugin && !0 === plu
2839
2757
  preEntry.forEach(addEntry), injectCoreJsEntry && addEntry(createVirtualModule('import "core-js";')), castArray(entry[entryName]).forEach(addEntry);
2840
2758
  }
2841
2759
  }), api.onBeforeCreateCompiler(({ bundlerConfigs })=>{
2842
- 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.`);
2843
2761
  });
2844
2762
  }
2845
2763
  }), fileSize_gzip = (0, __WEBPACK_EXTERNAL_MODULE_node_util_1b29d436__.promisify)(__WEBPACK_EXTERNAL_MODULE_node_zlib_a5bb16fc__.default.gzip);
@@ -3063,12 +2981,12 @@ class RsbuildHtmlPlugin {
3063
2981
  let emitFavicon = async (compilation, favicon)=>{
3064
2982
  let buffer, name = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.default.basename(favicon);
3065
2983
  if (compilation.assets[name]) return name;
3066
- 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;
3067
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);
3068
2986
  try {
3069
2987
  if (!(buffer = await (0, __WEBPACK_EXTERNAL_MODULE_node_util_1b29d436__.promisify)(compilation.inputFileSystem.readFile)(filename))) throw Error('Buffer is undefined');
3070
2988
  } catch (error) {
3071
- 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;
3072
2990
  }
3073
2991
  let source = new compiler.webpack.sources.RawSource(buffer, !1);
3074
2992
  return compilation.emitAsset(name, source), name;
@@ -3166,7 +3084,7 @@ async function getTemplate(entryName, config, rootPath) {
3166
3084
  };
3167
3085
  let absolutePath = (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.isAbsolute)(templatePath) ? templatePath : __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.default.join(rootPath, templatePath);
3168
3086
  if (!existTemplatePath.has(absolutePath)) {
3169
- 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)}`);
3170
3088
  existTemplatePath.add(absolutePath);
3171
3089
  }
3172
3090
  let templateContent = await __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__.default.promises.readFile(absolutePath, 'utf-8');
@@ -3461,7 +3379,7 @@ let generateManifest = (htmlPaths, manifestOptions, environment)=>(_seed, files)
3461
3379
  manifestData
3462
3380
  });
3463
3381
  if (isObject(generatedManifest)) return environment.manifest = generatedManifest, generatedManifest;
3464
- 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.`);
3465
3383
  }
3466
3384
  return environment.manifest = manifestData, manifestData;
3467
3385
  }, pluginManifest = ()=>({
@@ -3494,7 +3412,7 @@ let generateManifest = (htmlPaths, manifestOptions, environment)=>(_seed, files)
3494
3412
  }), api.onAfterCreateCompiler(()=>{
3495
3413
  if (manifestFilenames.size <= 1) return void manifestFilenames.clear();
3496
3414
  let environmentNames = Array.from(manifestFilenames.keys()), filenames = Array.from(manifestFilenames.values());
3497
- 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();
3498
3416
  });
3499
3417
  }
3500
3418
  });
@@ -3565,7 +3483,7 @@ let pluginMoment = ()=>({
3565
3483
  raw: !0
3566
3484
  }, ({ code, emitFile, resourcePath })=>{
3567
3485
  let name = nodeAddons_getFilename(resourcePath);
3568
- 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)}`);
3569
3487
  return emitFile(name, code), `
3570
3488
  try {
3571
3489
  const path = require("path");
@@ -3642,7 +3560,7 @@ function printServerURLs({ urls: originalUrls, port, routes, protocol, printUrls
3642
3560
  protocol
3643
3561
  });
3644
3562
  if (!newUrls) return null;
3645
- 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}.`);
3646
3564
  urls = newUrls.map((url)=>({
3647
3565
  url,
3648
3566
  label: getUrlLabel(url)
@@ -3666,10 +3584,10 @@ function printServerURLs({ urls: originalUrls, port, routes, protocol, printUrls
3666
3584
  }
3667
3585
  let getPort = async ({ host, port, strictPort, tryLimits = 20 })=>{
3668
3586
  'string' == typeof port && (port = Number.parseInt(port, 10)), strictPort && (tryLimits = 1);
3669
- let original = port, found = !1, attempts = 0;
3587
+ let { createServer } = await import("node:net"), original = port, found = !1, attempts = 0;
3670
3588
  for(; !found && attempts <= tryLimits;)try {
3671
3589
  await new Promise((resolve, reject)=>{
3672
- let server = __WEBPACK_EXTERNAL_MODULE_node_net_0373943e__.default.createServer();
3590
+ let server = createServer();
3673
3591
  server.unref(), server.on('error', reject), server.listen({
3674
3592
  port,
3675
3593
  host
@@ -3681,7 +3599,7 @@ let getPort = async ({ host, port, strictPort, tryLimits = 20 })=>{
3681
3599
  if ('EADDRINUSE' !== e.code) throw e;
3682
3600
  port++, attempts++;
3683
3601
  }
3684
- 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.`);
3685
3603
  return port;
3686
3604
  }, getServerConfig = async ({ config })=>{
3687
3605
  let { host, port: originalPort, strictPort } = config.server, port = await getPort({
@@ -3711,24 +3629,31 @@ let getPort = async ({ host, port, strictPort, tryLimits = 20 })=>{
3711
3629
  '127.0.0.1',
3712
3630
  '::1',
3713
3631
  '0000:0000:0000:0000:0000:0000:0000:0001'
3714
- ]).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)=>{
3715
3637
  try {
3716
3638
  let { host } = new URL(url);
3717
3639
  return isLoopbackHost(host) ? LOCAL_LABEL : NETWORK_LABEL;
3718
3640
  } catch (err) {
3719
3641
  return NETWORK_LABEL;
3720
3642
  }
3721
- }, getAddressUrls = ({ protocol = 'http', port, host })=>{
3722
- if (host && host !== DEFAULT_DEV_HOST) return [
3723
- {
3724
- label: isLoopbackHost(host) ? LOCAL_LABEL : NETWORK_LABEL,
3725
- url: concatUrl({
3726
- port,
3727
- host: getHostInUrl(host),
3728
- protocol
3729
- })
3730
- }
3731
- ];
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
+ }
3732
3657
  let ipv4Interfaces = getIpv4Interfaces(), addressUrls = [], hasLocalUrl = !1;
3733
3658
  for (let detail of ipv4Interfaces)if (isLoopbackHost(detail.address) || detail.internal) {
3734
3659
  if (hasLocalUrl) continue;
@@ -3766,7 +3691,7 @@ function getServerTerminator(server) {
3766
3691
  listened ? server.close((err)=>err ? reject(err) : resolve()) : resolve();
3767
3692
  });
3768
3693
  }
3769
- let execAsync = (0, __WEBPACK_EXTERNAL_MODULE_node_util_1b29d436__.promisify)(__WEBPACK_EXTERNAL_MODULE_node_child_process_27f17141__.exec), supportedChromiumBrowsers = [
3694
+ let supportedChromiumBrowsers = [
3770
3695
  'Google Chrome Canary',
3771
3696
  'Google Chrome Dev',
3772
3697
  'Google Chrome Beta',
@@ -3775,20 +3700,23 @@ let execAsync = (0, __WEBPACK_EXTERNAL_MODULE_node_util_1b29d436__.promisify)(__
3775
3700
  'Brave Browser',
3776
3701
  'Vivaldi',
3777
3702
  'Chromium'
3778
- ], getDefaultBrowserForAppleScript = async ()=>{
3779
- let { stdout: ps } = await execAsync('ps cax');
3780
- return supportedChromiumBrowsers.find((b)=>ps.includes(b));
3781
- }, 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)));
3782
3704
  async function openBrowser(url) {
3783
3705
  let browser = process.env.BROWSER, browserArgs = process.env.BROWSER_ARGS;
3784
- if (shouldTryAppleScript(browser, browserArgs)) try {
3785
- let chromiumBrowser = browser ? mapChromiumBrowserName(browser) : await getDefaultBrowserForAppleScript();
3786
- if (chromiumBrowser) return await execAsync(`osascript openChrome.applescript "${encodeURI(url)}" "${chromiumBrowser}"`, {
3787
- cwd: STATIC_PATH
3788
- }), !0;
3789
- __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.debug('failed to find the target browser.');
3790
- } catch (err) {
3791
- __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
+ }
3792
3720
  }
3793
3721
  try {
3794
3722
  let { default: open } = await import("../compiled/open/index.js"), { apps } = open, options = browser ? {
@@ -3823,13 +3751,13 @@ async function open_open({ https, port, routes, config, clearCache }) {
3823
3751
  let { targets, before } = normalizeOpenConfig(config);
3824
3752
  if ('true' === process.env.CSB) return;
3825
3753
  clearCache && clearOpenedURLs();
3826
- 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}`;
3827
3755
  for (let url of (targets.length ? urls.push(...targets.map((target)=>(function(str, base) {
3828
3756
  if (canParse(str)) return str;
3829
3757
  try {
3830
3758
  return new URL(str, base).href;
3831
3759
  } catch (e) {
3832
- 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`);
3833
3761
  }
3834
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));
3835
3763
  }
@@ -3933,13 +3861,13 @@ let getJsAsyncPath = (jsPath, isServer, jsAsync)=>void 0 !== jsAsync ? jsAsync :
3933
3861
  initial: {},
3934
3862
  config: config.resolve.alias
3935
3863
  });
3936
- 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({
3937
3865
  initial: mergedAlias,
3938
3866
  config: config.source.alias
3939
- }), config.resolve.dedupe) for (let pkgName of config.resolve.dedupe){
3867
+ })), config.resolve.dedupe) for (let pkgName of config.resolve.dedupe){
3940
3868
  let pkgPath;
3941
3869
  if (mergedAlias[pkgName]) {
3942
- __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.`);
3943
3871
  continue;
3944
3872
  }
3945
3873
  try {
@@ -3961,7 +3889,7 @@ let getJsAsyncPath = (jsPath, isServer, jsAsync)=>void 0 !== jsAsync ? jsAsync :
3961
3889
  ].join(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.sep);
3962
3890
  for(; !pkgPath.endsWith(trailing) && pkgPath.includes('node_modules');)pkgPath = (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.dirname)(pkgPath);
3963
3891
  } catch (e) {
3964
- __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.`);
3965
3893
  continue;
3966
3894
  }
3967
3895
  mergedAlias[pkgName] = pkgPath;
@@ -3974,7 +3902,7 @@ let getJsAsyncPath = (jsPath, isServer, jsAsync)=>void 0 !== jsAsync ? jsAsync :
3974
3902
  chain,
3975
3903
  config,
3976
3904
  rootPath: api.context.rootPath
3977
- }), 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.`);
3978
3906
  let aliasStrategy = config.source.aliasStrategy ?? config.resolve.aliasStrategy;
3979
3907
  tsconfigPath && 'rspack' === api.context.bundlerType && 'prefer-tsconfig' === aliasStrategy && chain.resolve.tsConfig({
3980
3908
  configFile: tsconfigPath,
@@ -4207,7 +4135,7 @@ async function applyProfile(root, filterValue, traceLayer = 'chrome', traceOutpu
4207
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');
4208
4136
  traceOutput = 'chrome' === traceLayer ? defaultRustTraceChromeOutput : 'stdout';
4209
4137
  }
4210
- 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;
4211
4139
  }
4212
4140
  let pluginRspackProfile = ()=>({
4213
4141
  name: 'rsbuild:rspack-profile',
@@ -4222,7 +4150,7 @@ let pluginRspackProfile = ()=>({
4222
4150
  api.onBeforeBuild(({ isFirstCompile })=>{
4223
4151
  isFirstCompile && onStart();
4224
4152
  }), api.onBeforeStartDevServer(onStart), api.onExit(()=>{
4225
- 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)}`));
4226
4154
  });
4227
4155
  }
4228
4156
  }), pluginServer = ()=>({
@@ -4312,7 +4240,7 @@ let pluginRspackProfile = ()=>({
4312
4240
  },
4313
4241
  'split-by-size': function(ctx) {
4314
4242
  let { override, forceSplittingGroups, defaultConfig, userConfig } = ctx;
4315
- return (0, __WEBPACK_EXTERNAL_MODULE_node_assert_3e74d44e__.default)('split-by-size' === userConfig.strategy), {
4243
+ return {
4316
4244
  ...defaultConfig,
4317
4245
  minSize: userConfig.minSize ?? 0,
4318
4246
  maxSize: userConfig.maxSize ?? Number.POSITIVE_INFINITY,
@@ -4488,7 +4416,7 @@ let pluginRspackProfile = ()=>({
4488
4416
  swcConfig.jsc.transform.legacyDecorator = !1, swcConfig.jsc.transform.decoratorVersion = '2022-03';
4489
4417
  break;
4490
4418
  default:
4491
- 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)}`);
4492
4420
  }
4493
4421
  }(swcConfig, config), castArray(target).includes('web') || target.includes('web-worker')) {
4494
4422
  let polyfillMode = config.output.polyfill;
@@ -4742,17 +4670,18 @@ async function generateRspackConfig({ target, context, environment }) {
4742
4670
  if (config.plugins) {
4743
4671
  for (let plugin of config.plugins)if (plugin && void 0 === plugin.apply && 'name' in plugin && 'setup' in plugin) {
4744
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));
4745
- 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.`);
4746
4674
  }
4747
4675
  }
4748
- 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;
4749
4677
  }
4750
4678
  async function modifyRsbuildConfig(context) {
4679
+ var _context_config_plugins, _modified_plugins;
4751
4680
  __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.debug('modify Rsbuild config');
4752
- 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, {
4753
4682
  mergeRsbuildConfig: mergeRsbuildConfig
4754
4683
  });
4755
- 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');
4756
4685
  }
4757
4686
  async function modifyEnvironmentConfig(context, config, name) {
4758
4687
  __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.debug(`modify Rsbuild environment(${name}) config`);
@@ -4804,11 +4733,11 @@ let initEnvironmentConfigs = (normalizedConfig, rootPath, specifiedEnvironments)
4804
4733
  }, config)
4805
4734
  })
4806
4735
  ]));
4807
- 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.`);
4808
4737
  return resolvedEnvironments;
4809
4738
  }
4810
4739
  let defaultEnvironmentName = camelCase(rsbuildSharedConfig.output.target);
4811
- 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.`);
4812
4741
  return {
4813
4742
  [defaultEnvironmentName]: applyEnvironmentDefaultConfig({
4814
4743
  ...rsbuildSharedConfig,
@@ -4822,7 +4751,7 @@ let initEnvironmentConfigs = (normalizedConfig, rootPath, specifiedEnvironments)
4822
4751
  })
4823
4752
  };
4824
4753
  }, validateRsbuildConfig = (config)=>{
4825
- 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"`);
4826
4755
  };
4827
4756
  async function initRsbuildConfig({ context, pluginManager }) {
4828
4757
  if (context.normalizedConfig) return context.normalizedConfig;
@@ -4898,9 +4827,83 @@ async function initConfigs({ context, pluginManager, rsbuildOptions }) {
4898
4827
  rspackConfigs
4899
4828
  };
4900
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
+ }
4901
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)=>{
4902
4905
  var _config_server;
4903
- let { content: config, filePath } = await config_loadConfig({
4906
+ let { content: config, filePath } = await loadConfig_loadConfig({
4904
4907
  cwd: root,
4905
4908
  path: commonOpts.config,
4906
4909
  envMode: commonOpts.envMode,
@@ -5061,7 +5064,7 @@ async function watchFilesForRestart({ files, rsbuild, isBuildWatch, watchOptions
5061
5064
  watcher.on('add', onChange), watcher.on('change', onChange), watcher.on('unlink', onChange);
5062
5065
  }
5063
5066
  let isCliShortcutsEnabled = (devConfig)=>devConfig.cliShortcuts && isTTY('stdin');
5064
- function setupCliShortcuts({ help = !0, openPage, closeServer, printUrls, restartServer, customShortcuts }) {
5067
+ async function setupCliShortcuts({ help = !0, openPage, closeServer, printUrls, restartServer, customShortcuts }) {
5065
5068
  let shortcuts = [
5066
5069
  {
5067
5070
  key: 'c',
@@ -5097,9 +5100,9 @@ function setupCliShortcuts({ help = !0, openPage, closeServer, printUrls, restar
5097
5100
  action: printUrls
5098
5101
  }
5099
5102
  ].filter(Boolean);
5100
- if (customShortcuts && !Array.isArray(shortcuts = customShortcuts(shortcuts))) throw Error('[rsbuild:config] `dev.cliShortcuts` must return an array of shortcuts.');
5101
- 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`);
5102
- 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({
5103
5106
  input: process.stdin
5104
5107
  });
5105
5108
  return rl.on('line', (input)=>{
@@ -5114,9 +5117,9 @@ function setupCliShortcuts({ help = !0, openPage, closeServer, printUrls, restar
5114
5117
  };
5115
5118
  }
5116
5119
  async function getLocalhostResolvedAddress() {
5117
- let [defaultLookup, explicitLookup] = await Promise.all([
5118
- __WEBPACK_EXTERNAL_MODULE_node_dns_78d346ee__.promises.lookup('localhost'),
5119
- __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', {
5120
5123
  verbatim: !0
5121
5124
  })
5122
5125
  ]);
@@ -5229,7 +5232,7 @@ class SocketServer {
5229
5232
  __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.error(err);
5230
5233
  }), this.heartbeatTimer = setTimeout(this.checkSockets, 30000).unref(), this.wsServer.on('connection', (socket, req)=>{
5231
5234
  let queryStr = req.url ? req.url.split('?')[1] : '';
5232
- this.onConnect(socket, queryStr ? (0, __WEBPACK_EXTERNAL_MODULE_node_querystring_aeb3c0b4__.parse)(queryStr) : {});
5235
+ this.onConnect(socket, queryStr ? Object.fromEntries(new URLSearchParams(queryStr)) : {});
5233
5236
  });
5234
5237
  }
5235
5238
  updateStats(stats) {
@@ -5814,7 +5817,7 @@ let ENCODING_REGEX = /\bgzip\b/, CONTENT_TYPE_REGEX = /text|javascript|\/json|xm
5814
5817
  }
5815
5818
  if (server.compress && middlewares.push(gzipMiddleware()), 'dev' === context.action && 'rspack' === context.bundlerType && dev.lazyCompilation && compilationManager) {
5816
5819
  let { compiler } = compilationManager;
5817
- '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));
5818
5821
  }
5819
5822
  server.base && '/' !== server.base && middlewares.push(getBaseMiddleware({
5820
5823
  base: server.base
@@ -5869,13 +5872,14 @@ let ENCODING_REGEX = /\bgzip\b/, CONTENT_TYPE_REGEX = /text|javascript|\/json|xm
5869
5872
  middlewares
5870
5873
  };
5871
5874
  }, asModule = async (something, context, unlinked)=>{
5872
- 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;
5873
5877
  let exports = [
5874
5878
  ...new Set([
5875
5879
  'default',
5876
5880
  ...Object.keys(something)
5877
5881
  ])
5878
- ], m = new __WEBPACK_EXTERNAL_MODULE_node_vm_bd3d9cea__.default.SyntheticModule(exports, ()=>{
5882
+ ], m = new SyntheticModule(exports, ()=>{
5879
5883
  for (let name of exports)m.setExport(name, 'default' === name ? something : something[name]);
5880
5884
  }, {
5881
5885
  context
@@ -5928,7 +5932,7 @@ class BasicRunner {
5928
5932
  postExecute(_m, _file) {}
5929
5933
  createRunner() {
5930
5934
  this.requirers.set('entry', (_currentDirectory, _modulePath, _context = {})=>{
5931
- throw Error('[rsbuild:runner] Not implement');
5935
+ throw Error(`${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim('[rsbuild:runner]')} Not implemented`);
5932
5936
  });
5933
5937
  }
5934
5938
  constructor(_options){
@@ -5986,7 +5990,7 @@ class CommonJsRunner extends BasicRunner {
5986
5990
  };
5987
5991
  }
5988
5992
  createCjsRequirer() {
5989
- let requireCache = Object.create(null);
5993
+ let requireCache = Object.create(null), vm = cjs_require('node:vm');
5990
5994
  return (currentDirectory, modulePath, context = {})=>{
5991
5995
  let file = context.file || this.getFile(modulePath, currentDirectory);
5992
5996
  if (!file) return this.requirers.get('miss')(currentDirectory, modulePath);
@@ -6000,7 +6004,7 @@ class CommonJsRunner extends BasicRunner {
6000
6004
  })`;
6001
6005
  this.preExecute(code, file);
6002
6006
  let dynamicImport = Function('specifier', 'return import(specifier)');
6003
- return __WEBPACK_EXTERNAL_MODULE_node_vm_bd3d9cea__.default.runInThisContext(code, {
6007
+ return vm.runInThisContext(code, {
6004
6008
  filename: file.path,
6005
6009
  importModuleDynamically: async (specifier)=>await dynamicImport(specifier)
6006
6010
  }).call(m.exports, ...argValues), this.postExecute(m, file), m.exports;
@@ -6008,6 +6012,7 @@ class CommonJsRunner extends BasicRunner {
6008
6012
  }
6009
6013
  }
6010
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);
6011
6016
  class EsmRunner extends CommonJsRunner {
6012
6017
  createRunner() {
6013
6018
  var _this__options_compilerOptions_experiments;
@@ -6025,13 +6030,13 @@ class EsmRunner extends CommonJsRunner {
6025
6030
  });
6026
6031
  }
6027
6032
  createEsmRequirer() {
6028
- let esmCache = new Map(), esmIdentifier = this._options.name;
6033
+ let esmCache = new Map(), esmIdentifier = this._options.name, vm = esm_require('node:vm');
6029
6034
  return (currentDirectory, modulePath, context = {})=>{
6030
- 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')}.`);
6031
6036
  let _require = this.getRequire(), file = context.file || this.getFile(modulePath, currentDirectory);
6032
6037
  if (!file) return this.requirers.get('miss')(currentDirectory, modulePath);
6033
6038
  let esm = esmCache.get(file.path);
6034
- return (esm || (esm = new __WEBPACK_EXTERNAL_MODULE_node_vm_bd3d9cea__.default.SourceTextModule(file.content, {
6039
+ return (esm || (esm = new vm.SourceTextModule(file.content, {
6035
6040
  identifier: `${esmIdentifier}-${file.path}`,
6036
6041
  url: `${(0, __WEBPACK_EXTERNAL_MODULE_node_url_e96de089__.pathToFileURL)(file.path).href}?${esmIdentifier}`,
6037
6042
  initializeImportMeta: (meta, _)=>{
@@ -6062,7 +6067,7 @@ class BasicRunnerFactory {
6062
6067
  name: this.name,
6063
6068
  ...options
6064
6069
  }, { compilerOptions } = options;
6065
- 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`);
6066
6071
  return new EsmRunner(runnerOptions);
6067
6072
  }
6068
6073
  constructor(name){
@@ -6082,7 +6087,7 @@ let runner_run = async ({ bundlePath, ...runnerFactoryOptions })=>new BasicRunne
6082
6087
  entrypoints: !0,
6083
6088
  outputPath: !0
6084
6089
  });
6085
- 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)}`);
6086
6091
  let { chunks: entryChunks = [] } = entrypoints[entryName], files = entryChunks.reduce((prev, entryChunkName)=>{
6087
6092
  let chunk = null == chunks ? void 0 : chunks.find((chunk)=>{
6088
6093
  var _chunk_names;
@@ -6090,8 +6095,8 @@ let runner_run = async ({ bundlePath, ...runnerFactoryOptions })=>new BasicRunne
6090
6095
  });
6091
6096
  return (null == chunk ? void 0 : chunk.files) ? prev.concat(chunk.files.filter((file)=>!file.endsWith('.css'))) : prev;
6092
6097
  }, []);
6093
- if (0 === files.length) throw Error(`[rsbuild:loadBundle] Failed to get bundle by entryName: "${entryName}"`);
6094
- 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(',')}`);
6095
6100
  let allChunkFiles = (null == chunks ? void 0 : chunks.flatMap((c)=>c.files).map((file)=>(0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(outputPath, file))) || [];
6096
6101
  return await runner_run({
6097
6102
  bundlePath: files[0],
@@ -6102,7 +6107,7 @@ let runner_run = async ({ bundlePath, ...runnerFactoryOptions })=>new BasicRunne
6102
6107
  });
6103
6108
  }, getTransformedHtml = async (entryName, utils)=>{
6104
6109
  let { htmlPaths, distPath } = utils.environment, htmlPath = htmlPaths[entryName];
6105
- 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)}`);
6106
6111
  let fileName = (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(distPath, htmlPath);
6107
6112
  return utils.readFileSync(fileName);
6108
6113
  }, createCacheableFunction = (getter)=>{
@@ -6175,7 +6180,7 @@ async function devServer_createDevServer(options, createCompiler, config, { comp
6175
6180
  });
6176
6181
  }) : Promise.resolve(), startCompile = async ()=>{
6177
6182
  let compiler = customCompiler || await createCompiler();
6178
- 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.`);
6179
6184
  let publicPaths = helpers_isMultiCompiler(compiler) ? compiler.compilers.map(getPublicPathFromCompiler) : [
6180
6185
  getPublicPathFromCompiler(compiler)
6181
6186
  ], compilationManager = new CompilationManager({
@@ -6189,7 +6194,7 @@ async function devServer_createDevServer(options, createCompiler, config, { comp
6189
6194
  environments: context.environments
6190
6195
  });
6191
6196
  return await compilationManager.init(), compilationManager;
6192
- }, protocol = https ? 'https' : 'http', urls = getAddressUrls({
6197
+ }, protocol = https ? 'https' : 'http', urls = await getAddressUrls({
6193
6198
  protocol,
6194
6199
  port,
6195
6200
  host
@@ -6213,9 +6218,9 @@ async function devServer_createDevServer(options, createCompiler, config, { comp
6213
6218
  ]);
6214
6219
  };
6215
6220
  middlewareMode || registerCleanup(closeServer);
6216
- let beforeCreateCompiler = ()=>{
6221
+ let beforeCreateCompiler = async ()=>{
6217
6222
  if (printUrls(), cliShortcutsEnabled) {
6218
- let shortcutsOptions = 'boolean' == typeof devConfig.cliShortcuts ? {} : devConfig.cliShortcuts, cleanup = setupCliShortcuts({
6223
+ let shortcutsOptions = 'boolean' == typeof devConfig.cliShortcuts ? {} : devConfig.cliShortcuts, cleanup = await setupCliShortcuts({
6219
6224
  openPage,
6220
6225
  closeServer,
6221
6226
  printUrls,
@@ -6232,18 +6237,18 @@ async function devServer_createDevServer(options, createCompiler, config, { comp
6232
6237
  name,
6233
6238
  {
6234
6239
  getStats: async ()=>{
6235
- 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`);
6236
6241
  return await waitFirstCompileDone, lastStats[environment.index];
6237
6242
  },
6238
6243
  loadBundle: async (entryName)=>{
6239
- 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`);
6240
6245
  return await waitFirstCompileDone, cacheableLoadBundle(lastStats[environment.index], entryName, {
6241
6246
  readFileSync: compilationManager.readFileSync,
6242
6247
  environment
6243
6248
  });
6244
6249
  },
6245
6250
  getTransformedHtml: async (entryName)=>{
6246
- 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`);
6247
6252
  return await waitFirstCompileDone, cacheableTransformedHtml(lastStats[environment.index], entryName, {
6248
6253
  readFileSync: compilationManager.readFileSync,
6249
6254
  environment
@@ -6263,7 +6268,7 @@ async function devServer_createDevServer(options, createCompiler, config, { comp
6263
6268
  data
6264
6269
  }),
6265
6270
  listen: async ()=>{
6266
- 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.`);
6267
6272
  let serverTerminator = getServerTerminator(httpServer);
6268
6273
  return __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.debug('listen dev server'), context.hooks.onCloseDevServer.tap(serverTerminator), new Promise((resolve)=>{
6269
6274
  httpServer.listen({
@@ -6298,7 +6303,7 @@ async function devServer_createDevServer(options, createCompiler, config, { comp
6298
6303
  server: devServerAPI,
6299
6304
  environments: context.environments
6300
6305
  })).filter((item)=>'function' == typeof item);
6301
- runCompile ? context.hooks.onBeforeCreateCompiler.tap(beforeCreateCompiler) : beforeCreateCompiler();
6306
+ runCompile ? context.hooks.onBeforeCreateCompiler.tap(beforeCreateCompiler) : await beforeCreateCompiler();
6302
6307
  let compilationManager = runCompile ? await startCompile() : void 0;
6303
6308
  for (let item of (fileWatcher = await setupWatchFiles({
6304
6309
  dev: devConfig,
@@ -6338,7 +6343,7 @@ async function createCompiler_createCompiler(options) {
6338
6343
  if (await context.hooks.onBeforeCreateCompiler.callBatch({
6339
6344
  bundlerConfigs: rspackConfigs,
6340
6345
  environments: context.environments
6341
- }), !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)}`);
6342
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 = ()=>{
6343
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);
6344
6349
  };
@@ -6575,7 +6580,7 @@ async function startProdServer(context, config, { getPortSilently } = {}) {
6575
6580
  routes,
6576
6581
  environments: context.environments
6577
6582
  });
6578
- let protocol = https ? 'https' : 'http', urls = getAddressUrls({
6583
+ let protocol = https ? 'https' : 'http', urls = await getAddressUrls({
6579
6584
  protocol,
6580
6585
  port,
6581
6586
  host
@@ -6602,7 +6607,7 @@ async function startProdServer(context, config, { getPortSilently } = {}) {
6602
6607
  });
6603
6608
  if (printUrls(), cliShortcutsEnabled) {
6604
6609
  let shortcutsOptions = 'boolean' == typeof config.dev.cliShortcuts ? {} : config.dev.cliShortcuts;
6605
- setupCliShortcuts({
6610
+ await setupCliShortcuts({
6606
6611
  openPage,
6607
6612
  closeServer,
6608
6613
  printUrls,
@@ -6754,7 +6759,7 @@ async function createRsbuild(options = {}) {
6754
6759
  let { before, environment = RSBUILD_ALL_ENVIRONMENT_SYMBOL } = options || {};
6755
6760
  for (let newPlugin of newPlugins)if (newPlugin) {
6756
6761
  let type = typeof newPlugin;
6757
- 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)}.`);
6758
6763
  if (!isFunction(newPlugin.setup)) {
6759
6764
  if (isFunction(newPlugin.apply)) {
6760
6765
  let { name = 'SomeWebpackPlugin' } = newPlugin.constructor || {};
@@ -6772,7 +6777,7 @@ async function createRsbuild(options = {}) {
6772
6777
  `)
6773
6778
  ].join('\n'));
6774
6779
  }
6775
- 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)}.`);
6776
6781
  }
6777
6782
  if (before) {
6778
6783
  let index = plugins.findIndex((item)=>item.instance.name === before);
@@ -6818,12 +6823,12 @@ async function createRsbuild(options = {}) {
6818
6823
  if (context.normalizedConfig) {
6819
6824
  if (null == options ? void 0 : options.environment) {
6820
6825
  let config = context.normalizedConfig.environments[options.environment];
6821
- 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}.`);
6822
6827
  return config;
6823
6828
  }
6824
6829
  return context.normalizedConfig;
6825
6830
  }
6826
- 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.`);
6827
6832
  }
6828
6833
  let getRsbuildConfig = (type = 'current')=>{
6829
6834
  switch(type){
@@ -6834,7 +6839,7 @@ async function createRsbuild(options = {}) {
6834
6839
  case 'normalized':
6835
6840
  return getNormalizedConfig();
6836
6841
  }
6837
- 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.`);
6838
6843
  }, exposed = [], expose = (id, api)=>{
6839
6844
  exposed.push({
6840
6845
  id,
@@ -7017,11 +7022,11 @@ async function createRsbuild(options = {}) {
7017
7022
  pluginManager
7018
7023
  }), { distPath } = context, { checkDistDir = !0 } = options;
7019
7024
  if (checkDistDir) {
7020
- 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.`);
7021
7026
  if (function(path) {
7022
7027
  let files = __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__.default.readdirSync(path);
7023
7028
  return 0 === files.length || 1 === files.length && '.git' === files[0];
7024
- }(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.`);
7025
7030
  }
7026
7031
  return startProdServer(context, config, options);
7027
7032
  },
@@ -7399,11 +7404,11 @@ async function runCLI() {
7399
7404
  }
7400
7405
  process.title = 'rsbuild-node';
7401
7406
  let { npm_execpath } = process.env;
7402
- (!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.21\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`);
7403
7408
  try {
7404
7409
  !function() {
7405
7410
  let cli = cac_dist('rsbuild');
7406
- cli.help(), cli.version("1.3.21"), applyCommonOptions(cli);
7411
+ cli.help(), cli.version("1.3.22"), applyCommonOptions(cli);
7407
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');
7408
7413
  applyServerOptions(devCommand), applyServerOptions(previewCommand), devCommand.action(async (options)=>{
7409
7414
  try {
@@ -7454,6 +7459,6 @@ async function runCLI() {
7454
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);
7455
7460
  }
7456
7461
  }
7457
- let src_version = "1.3.21";
7462
+ let src_version = "1.3.22";
7458
7463
  var __webpack_exports__logger = __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger, __webpack_exports__rspack = __WEBPACK_EXTERNAL_MODULE__rspack_core_e0096ff7__.rspack;
7459
- 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 };