@rsbuild/core 1.3.21 → 1.4.0-beta.0

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.
Files changed (37) hide show
  1. package/README.md +2 -2
  2. package/compiled/css-loader/index.js +44 -44
  3. package/compiled/html-rspack-plugin/index.js +14 -14
  4. package/compiled/postcss/index.js +189 -144
  5. package/compiled/postcss/lib/input.d.ts +24 -3
  6. package/compiled/postcss/lib/node.d.ts +17 -2
  7. package/compiled/postcss/lib/stringifier.d.ts +2 -2
  8. package/compiled/postcss/package.json +1 -1
  9. package/compiled/postcss-load-config/index.js +10 -10
  10. package/compiled/postcss-loader/index.js +6 -6
  11. package/compiled/rsbuild-dev-middleware/index.js +115 -125
  12. package/compiled/rspack-chain/index.js +67 -67
  13. package/compiled/rspack-chain/package.json +1 -1
  14. package/compiled/rspack-chain/types/index.d.ts +1 -0
  15. package/compiled/rspack-manifest-plugin/index.js +4 -4
  16. package/compiled/sirv/index.js +12 -6
  17. package/compiled/style-loader/index.js +10 -10
  18. package/compiled/tinyglobby/index.d.ts +35 -16
  19. package/compiled/tinyglobby/index.js +517 -531
  20. package/compiled/tinyglobby/package.json +1 -1
  21. package/compiled/webpack-bundle-analyzer/index.js +62 -46
  22. package/dist/index.cjs +274 -236
  23. package/dist/index.js +233 -227
  24. package/dist-types/cli/commands.d.ts +1 -1
  25. package/dist-types/defaultConfig.d.ts +26 -0
  26. package/dist-types/index.d.ts +2 -2
  27. package/dist-types/{config.d.ts → loadConfig.d.ts} +9 -34
  28. package/dist-types/pluginHelper.d.ts +1 -1
  29. package/dist-types/plugins/minimize.d.ts +1 -1
  30. package/dist-types/server/cliShortcuts.d.ts +2 -2
  31. package/dist-types/server/helper.d.ts +2 -2
  32. package/dist-types/server/runner/asModule.d.ts +2 -2
  33. package/dist-types/types/config.d.ts +41 -20
  34. package/dist-types/types/hooks.d.ts +1 -1
  35. package/dist-types/types/plugin.d.ts +18 -18
  36. package/dist-types/types/rsbuild.d.ts +2 -2
  37. package/package.json +11 -10
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.4.0-beta.0",
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);
@@ -2850,7 +2768,7 @@ async function gzipSize(input) {
2850
2768
  let EXCLUDE_ASSET_REGEX = /\.(?:map|LICENSE\.txt|d\.ts)$/, excludeAsset = (asset)=>EXCLUDE_ASSET_REGEX.test(asset.name), getAssetColor = (size)=>size > 300000 ? __WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.red : size > 100000 ? __WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow : __WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.green, calcFileSize = (len)=>{
2851
2769
  let val = len / 1000;
2852
2770
  return `${val.toFixed(val < 1 ? 2 : 1)} kB`;
2853
- }, coloringAssetName = (assetName)=>JS_REGEX.test(assetName) ? __WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.cyan(assetName) : CSS_REGEX.test(assetName) ? __WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow(assetName) : HTML_REGEX.test(assetName) ? __WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.green(assetName) : __WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.magenta(assetName), COMPRESSIBLE_REGEX = /\.(?:js|css|html|json|svg|txt|xml|xhtml|wasm|manifest)$/i, isCompressible = (assetName)=>COMPRESSIBLE_REGEX.test(assetName);
2771
+ }, coloringAssetName = (assetName)=>JS_REGEX.test(assetName) ? __WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.cyan(assetName) : CSS_REGEX.test(assetName) ? __WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow(assetName) : HTML_REGEX.test(assetName) ? __WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.green(assetName) : __WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.magenta(assetName), COMPRESSIBLE_REGEX = /\.(?:js|css|html|json|svg|txt|xml|xhtml|wasm|manifest|md)$/i, isCompressible = (assetName)=>COMPRESSIBLE_REGEX.test(assetName);
2854
2772
  async function printFileSizes(options, stats, rootPath, environmentName) {
2855
2773
  let logs = [], showTotal = !1 !== options.total, showDetail = !1 !== options.detail, exclude = options.exclude ?? excludeAsset;
2856
2774
  if (!showTotal && !showDetail) return logs;
@@ -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
  }
@@ -3901,7 +3829,7 @@ let getJsAsyncPath = (jsPath, isServer, jsAsync)=>void 0 !== jsAsync ? jsAsync :
3901
3829
  name: 'rsbuild:progress',
3902
3830
  setup (api) {
3903
3831
  'webpack' !== api.context.bundlerType && api.modifyBundlerChain(async (chain, { CHAIN_ID, environment })=>{
3904
- let { config } = environment, options = config.dev.progressBar ?? 'production' === config.mode;
3832
+ let { config } = environment, options = config.dev.progressBar;
3905
3833
  if (!options) return;
3906
3834
  let prefix = !0 !== options && void 0 !== options.id ? options.id : environment.name;
3907
3835
  chain.plugin(CHAIN_ID.PLUGIN.PROGRESS).use(__WEBPACK_EXTERNAL_MODULE__rspack_core_e0096ff7__.rspack.ProgressPlugin, [
@@ -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,
@@ -4439,21 +4367,15 @@ let pluginRspackProfile = ()=>({
4439
4367
  "application/javascript"
4440
4368
  ]
4441
4369
  });
4442
- if (!function({ rule, isDev, config, context, rsbuildTarget }) {
4370
+ if (!function({ rule, isDev, config, rsbuildTarget }) {
4443
4371
  for (let condition of (rule.include.add({
4444
- and: [
4445
- context.rootPath,
4446
- {
4447
- not: NODE_MODULES_REGEX
4448
- }
4449
- ]
4372
+ not: NODE_MODULES_REGEX
4450
4373
  }), rule.include.add(/\.(?:ts|tsx|jsx|mts|cts)$/), 'web' === rsbuildTarget && isDev && rule.include.add(/[\\/]@rsbuild[\\/]core[\\/]dist[\\/]/), config.source.include || []))rule.include.add(condition);
4451
4374
  for (let condition of config.source.exclude || [])rule.exclude.add(condition);
4452
4375
  }({
4453
4376
  rule,
4454
4377
  isDev,
4455
4378
  config,
4456
- context: api.context,
4457
4379
  rsbuildTarget: target
4458
4380
  }), 'webpack' === api.context.bundlerType) return;
4459
4381
  let swcConfig = {
@@ -4488,7 +4410,7 @@ let pluginRspackProfile = ()=>({
4488
4410
  swcConfig.jsc.transform.legacyDecorator = !1, swcConfig.jsc.transform.decoratorVersion = '2022-03';
4489
4411
  break;
4490
4412
  default:
4491
- throw Error(`[rsbuild:swc] Unknown decorators version: ${version}`);
4413
+ 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
4414
  }
4493
4415
  }(swcConfig, config), castArray(target).includes('web') || target.includes('web-worker')) {
4494
4416
  let polyfillMode = config.output.polyfill;
@@ -4742,17 +4664,18 @@ async function generateRspackConfig({ target, context, environment }) {
4742
4664
  if (config.plugins) {
4743
4665
  for (let plugin of config.plugins)if (plugin && void 0 === plugin.apply && 'name' in plugin && 'setup' in plugin) {
4744
4666
  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.`);
4667
+ 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
4668
  }
4747
4669
  }
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;
4670
+ 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
4671
  }
4750
4672
  async function modifyRsbuildConfig(context) {
4673
+ var _context_config_plugins, _modified_plugins;
4751
4674
  __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.debug('modify Rsbuild config');
4752
- let [modified] = await context.hooks.modifyRsbuildConfig.callChain(context.config, {
4675
+ 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
4676
  mergeRsbuildConfig: mergeRsbuildConfig
4754
4677
  });
4755
- context.config = modified, __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.debug('modify Rsbuild config done');
4678
+ 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
4679
  }
4757
4680
  async function modifyEnvironmentConfig(context, config, name) {
4758
4681
  __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.debug(`modify Rsbuild environment(${name}) config`);
@@ -4804,11 +4727,11 @@ let initEnvironmentConfigs = (normalizedConfig, rootPath, specifiedEnvironments)
4804
4727
  }, config)
4805
4728
  })
4806
4729
  ]));
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.`);
4730
+ 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
4731
  return resolvedEnvironments;
4809
4732
  }
4810
4733
  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.`);
4734
+ 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
4735
  return {
4813
4736
  [defaultEnvironmentName]: applyEnvironmentDefaultConfig({
4814
4737
  ...rsbuildSharedConfig,
@@ -4822,7 +4745,11 @@ let initEnvironmentConfigs = (normalizedConfig, rootPath, specifiedEnvironments)
4822
4745
  })
4823
4746
  };
4824
4747
  }, 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"');
4748
+ 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"`);
4749
+ if (config.environments) {
4750
+ let names = Object.keys(config.environments), regexp = /^[\w$-]+$/;
4751
+ for (let name of names)regexp.test(name) || __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.warn(`${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim('[rsbuild:config]')} Environment name "${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow(name)}" contains invalid characters. Only letters, numbers, "-", "_", and "$" are allowed.`);
4752
+ }
4826
4753
  };
4827
4754
  async function initRsbuildConfig({ context, pluginManager }) {
4828
4755
  if (context.normalizedConfig) return context.normalizedConfig;
@@ -4898,9 +4825,83 @@ async function initConfigs({ context, pluginManager, rsbuildOptions }) {
4898
4825
  rspackConfigs
4899
4826
  };
4900
4827
  }
4828
+ function defineConfig(config) {
4829
+ return config;
4830
+ }
4831
+ let resolveConfigPath = (root, customConfig)=>{
4832
+ if (customConfig) {
4833
+ let customConfigPath = (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.isAbsolute)(customConfig) ? customConfig : (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(root, customConfig);
4834
+ if (__WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__.default.existsSync(customConfigPath)) return customConfigPath;
4835
+ __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`);
4836
+ }
4837
+ for (let file of [
4838
+ 'rsbuild.config.mjs',
4839
+ 'rsbuild.config.ts',
4840
+ 'rsbuild.config.js',
4841
+ 'rsbuild.config.cjs',
4842
+ 'rsbuild.config.mts',
4843
+ 'rsbuild.config.cts'
4844
+ ]){
4845
+ let configFile = (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(root, file);
4846
+ if (__WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__.default.existsSync(configFile)) return configFile;
4847
+ }
4848
+ return null;
4849
+ };
4850
+ async function loadConfig_loadConfig({ cwd = process.cwd(), path, envMode, meta, loader = 'jiti' } = {}) {
4851
+ let configExport, configFilePath = resolveConfigPath(cwd, path);
4852
+ if (!configFilePath) return __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.debug('no config file found.'), {
4853
+ content: {},
4854
+ filePath: configFilePath
4855
+ };
4856
+ let applyMetaInfo = (config)=>(config._privateMeta = {
4857
+ configFilePath
4858
+ }, config);
4859
+ if ('native' === loader || /\.(?:js|mjs|cjs)$/.test(configFilePath)) try {
4860
+ let configFileURL = (0, __WEBPACK_EXTERNAL_MODULE_node_url_e96de089__.pathToFileURL)(configFilePath).href, exportModule = await import(`${configFileURL}?t=${Date.now()}`);
4861
+ configExport = exportModule.default ? exportModule.default : exportModule;
4862
+ } catch (err) {
4863
+ 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;
4864
+ __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)}`);
4865
+ }
4866
+ try {
4867
+ if (void 0 === configExport) {
4868
+ let { createJiti } = await import("jiti"), jiti = createJiti(constants_filename, {
4869
+ moduleCache: !1,
4870
+ interopDefault: !0,
4871
+ nativeModules: [
4872
+ '@rspack/core',
4873
+ "typescript"
4874
+ ]
4875
+ });
4876
+ configExport = await jiti.import(configFilePath, {
4877
+ default: !0
4878
+ });
4879
+ }
4880
+ } catch (err) {
4881
+ 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;
4882
+ }
4883
+ if ('function' == typeof configExport) {
4884
+ let command = process.argv[2], nodeEnv = getNodeEnv(), result = await configExport({
4885
+ env: nodeEnv,
4886
+ command,
4887
+ envMode: envMode || nodeEnv,
4888
+ meta
4889
+ });
4890
+ 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.`);
4891
+ return {
4892
+ content: applyMetaInfo(result),
4893
+ filePath: configFilePath
4894
+ };
4895
+ }
4896
+ 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)}`);
4897
+ return __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.debug('loaded config file:', configFilePath), {
4898
+ content: applyMetaInfo(configExport),
4899
+ filePath: configFilePath
4900
+ };
4901
+ }
4901
4902
  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
4903
  var _config_server;
4903
- let { content: config, filePath } = await config_loadConfig({
4904
+ let { content: config, filePath } = await loadConfig_loadConfig({
4904
4905
  cwd: root,
4905
4906
  path: commonOpts.config,
4906
4907
  envMode: commonOpts.envMode,
@@ -5061,7 +5062,7 @@ async function watchFilesForRestart({ files, rsbuild, isBuildWatch, watchOptions
5061
5062
  watcher.on('add', onChange), watcher.on('change', onChange), watcher.on('unlink', onChange);
5062
5063
  }
5063
5064
  let isCliShortcutsEnabled = (devConfig)=>devConfig.cliShortcuts && isTTY('stdin');
5064
- function setupCliShortcuts({ help = !0, openPage, closeServer, printUrls, restartServer, customShortcuts }) {
5065
+ async function setupCliShortcuts({ help = !0, openPage, closeServer, printUrls, restartServer, customShortcuts }) {
5065
5066
  let shortcuts = [
5066
5067
  {
5067
5068
  key: 'c',
@@ -5097,9 +5098,9 @@ function setupCliShortcuts({ help = !0, openPage, closeServer, printUrls, restar
5097
5098
  action: printUrls
5098
5099
  }
5099
5100
  ].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({
5101
+ 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.`);
5102
+ 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`);
5103
+ let { createInterface } = await import("node:readline"), rl = createInterface({
5103
5104
  input: process.stdin
5104
5105
  });
5105
5106
  return rl.on('line', (input)=>{
@@ -5114,9 +5115,9 @@ function setupCliShortcuts({ help = !0, openPage, closeServer, printUrls, restar
5114
5115
  };
5115
5116
  }
5116
5117
  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', {
5118
+ let { promises: dns } = await import("node:dns"), [defaultLookup, explicitLookup] = await Promise.all([
5119
+ dns.lookup('localhost'),
5120
+ dns.lookup('localhost', {
5120
5121
  verbatim: !0
5121
5122
  })
5122
5123
  ]);
@@ -5229,7 +5230,7 @@ class SocketServer {
5229
5230
  __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.error(err);
5230
5231
  }), this.heartbeatTimer = setTimeout(this.checkSockets, 30000).unref(), this.wsServer.on('connection', (socket, req)=>{
5231
5232
  let queryStr = req.url ? req.url.split('?')[1] : '';
5232
- this.onConnect(socket, queryStr ? (0, __WEBPACK_EXTERNAL_MODULE_node_querystring_aeb3c0b4__.parse)(queryStr) : {});
5233
+ this.onConnect(socket, queryStr ? Object.fromEntries(new URLSearchParams(queryStr)) : {});
5233
5234
  });
5234
5235
  }
5235
5236
  updateStats(stats) {
@@ -5478,7 +5479,7 @@ class SocketServer {
5478
5479
  <pre class="content">${htmlItems.join('\n\n').trim()}</pre>
5479
5480
  <footer class="footer">
5480
5481
  <p><span>Fix error</span>, click outside, or press Esc to close the overlay.</p>
5481
- <p>Disable overlay by setting Rsbuild's <span><a class="config-link" target="_blank" rel="noopener noreferrer" href="https://rsbuild.dev/config/dev/client">dev.client.overlay</a></span> config to false.<p>
5482
+ <p>Disable overlay by setting Rsbuild's <span><a class="config-link" target="_blank" rel="noopener noreferrer" href="https://rsbuild.rs/config/dev/client">dev.client.overlay</a></span> config to false.<p>
5482
5483
  </footer>
5483
5484
  </div>
5484
5485
  </div>
@@ -5814,7 +5815,7 @@ let ENCODING_REGEX = /\bgzip\b/, CONTENT_TYPE_REGEX = /text|javascript|\/json|xm
5814
5815
  }
5815
5816
  if (server.compress && middlewares.push(gzipMiddleware()), 'dev' === context.action && 'rspack' === context.bundlerType && dev.lazyCompilation && compilationManager) {
5816
5817
  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));
5818
+ '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
5819
  }
5819
5820
  server.base && '/' !== server.base && middlewares.push(getBaseMiddleware({
5820
5821
  base: server.base
@@ -5869,13 +5870,14 @@ let ENCODING_REGEX = /\bgzip\b/, CONTENT_TYPE_REGEX = /text|javascript|\/json|xm
5869
5870
  middlewares
5870
5871
  };
5871
5872
  }, asModule = async (something, context, unlinked)=>{
5872
- if (something instanceof __WEBPACK_EXTERNAL_MODULE_node_vm_bd3d9cea__.default.Module) return something;
5873
+ let { Module, SyntheticModule } = await import("node:vm");
5874
+ if (something instanceof Module) return something;
5873
5875
  let exports = [
5874
5876
  ...new Set([
5875
5877
  'default',
5876
5878
  ...Object.keys(something)
5877
5879
  ])
5878
- ], m = new __WEBPACK_EXTERNAL_MODULE_node_vm_bd3d9cea__.default.SyntheticModule(exports, ()=>{
5880
+ ], m = new SyntheticModule(exports, ()=>{
5879
5881
  for (let name of exports)m.setExport(name, 'default' === name ? something : something[name]);
5880
5882
  }, {
5881
5883
  context
@@ -5928,7 +5930,7 @@ class BasicRunner {
5928
5930
  postExecute(_m, _file) {}
5929
5931
  createRunner() {
5930
5932
  this.requirers.set('entry', (_currentDirectory, _modulePath, _context = {})=>{
5931
- throw Error('[rsbuild:runner] Not implement');
5933
+ throw Error(`${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim('[rsbuild:runner]')} Not implemented`);
5932
5934
  });
5933
5935
  }
5934
5936
  constructor(_options){
@@ -5986,7 +5988,7 @@ class CommonJsRunner extends BasicRunner {
5986
5988
  };
5987
5989
  }
5988
5990
  createCjsRequirer() {
5989
- let requireCache = Object.create(null);
5991
+ let requireCache = Object.create(null), vm = cjs_require('node:vm');
5990
5992
  return (currentDirectory, modulePath, context = {})=>{
5991
5993
  let file = context.file || this.getFile(modulePath, currentDirectory);
5992
5994
  if (!file) return this.requirers.get('miss')(currentDirectory, modulePath);
@@ -6000,7 +6002,7 @@ class CommonJsRunner extends BasicRunner {
6000
6002
  })`;
6001
6003
  this.preExecute(code, file);
6002
6004
  let dynamicImport = Function('specifier', 'return import(specifier)');
6003
- return __WEBPACK_EXTERNAL_MODULE_node_vm_bd3d9cea__.default.runInThisContext(code, {
6005
+ return vm.runInThisContext(code, {
6004
6006
  filename: file.path,
6005
6007
  importModuleDynamically: async (specifier)=>await dynamicImport(specifier)
6006
6008
  }).call(m.exports, ...argValues), this.postExecute(m, file), m.exports;
@@ -6008,6 +6010,7 @@ class CommonJsRunner extends BasicRunner {
6008
6010
  }
6009
6011
  }
6010
6012
  var type_EsmMode = ((EsmMode = {})[EsmMode.Unknown = 0] = "Unknown", EsmMode[EsmMode.Evaluated = 1] = "Evaluated", EsmMode[EsmMode.Unlinked = 2] = "Unlinked", EsmMode);
6013
+ let esm_require = (0, __WEBPACK_EXTERNAL_MODULE_node_module_ab9f2194__.createRequire)(import.meta.url);
6011
6014
  class EsmRunner extends CommonJsRunner {
6012
6015
  createRunner() {
6013
6016
  var _this__options_compilerOptions_experiments;
@@ -6025,13 +6028,13 @@ class EsmRunner extends CommonJsRunner {
6025
6028
  });
6026
6029
  }
6027
6030
  createEsmRequirer() {
6028
- let esmCache = new Map(), esmIdentifier = this._options.name;
6031
+ let esmCache = new Map(), esmIdentifier = this._options.name, vm = esm_require('node:vm');
6029
6032
  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".');
6033
+ 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
6034
  let _require = this.getRequire(), file = context.file || this.getFile(modulePath, currentDirectory);
6032
6035
  if (!file) return this.requirers.get('miss')(currentDirectory, modulePath);
6033
6036
  let esm = esmCache.get(file.path);
6034
- return (esm || (esm = new __WEBPACK_EXTERNAL_MODULE_node_vm_bd3d9cea__.default.SourceTextModule(file.content, {
6037
+ return (esm || (esm = new vm.SourceTextModule(file.content, {
6035
6038
  identifier: `${esmIdentifier}-${file.path}`,
6036
6039
  url: `${(0, __WEBPACK_EXTERNAL_MODULE_node_url_e96de089__.pathToFileURL)(file.path).href}?${esmIdentifier}`,
6037
6040
  initializeImportMeta: (meta, _)=>{
@@ -6062,7 +6065,7 @@ class BasicRunnerFactory {
6062
6065
  name: this.name,
6063
6066
  ...options
6064
6067
  }, { compilerOptions } = options;
6065
- if ('web' === compilerOptions.target || 'webworker' === compilerOptions.target) throw Error(`[rsbuild:runner] Not support run "${compilerOptions.target}" resource in Rsbuild server`);
6068
+ 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
6069
  return new EsmRunner(runnerOptions);
6067
6070
  }
6068
6071
  constructor(name){
@@ -6082,7 +6085,7 @@ let runner_run = async ({ bundlePath, ...runnerFactoryOptions })=>new BasicRunne
6082
6085
  entrypoints: !0,
6083
6086
  outputPath: !0
6084
6087
  });
6085
- if (!(null == entrypoints ? void 0 : entrypoints[entryName])) throw Error(`[rsbuild:loadBundle] Can't find entry: "${entryName}"`);
6088
+ 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
6089
  let { chunks: entryChunks = [] } = entrypoints[entryName], files = entryChunks.reduce((prev, entryChunkName)=>{
6087
6090
  let chunk = null == chunks ? void 0 : chunks.find((chunk)=>{
6088
6091
  var _chunk_names;
@@ -6090,8 +6093,8 @@ let runner_run = async ({ bundlePath, ...runnerFactoryOptions })=>new BasicRunne
6090
6093
  });
6091
6094
  return (null == chunk ? void 0 : chunk.files) ? prev.concat(chunk.files.filter((file)=>!file.endsWith('.css'))) : prev;
6092
6095
  }, []);
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(',')}`);
6096
+ 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)}`);
6097
+ 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
6098
  let allChunkFiles = (null == chunks ? void 0 : chunks.flatMap((c)=>c.files).map((file)=>(0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(outputPath, file))) || [];
6096
6099
  return await runner_run({
6097
6100
  bundlePath: files[0],
@@ -6102,7 +6105,7 @@ let runner_run = async ({ bundlePath, ...runnerFactoryOptions })=>new BasicRunne
6102
6105
  });
6103
6106
  }, getTransformedHtml = async (entryName, utils)=>{
6104
6107
  let { htmlPaths, distPath } = utils.environment, htmlPath = htmlPaths[entryName];
6105
- if (!htmlPath) throw Error(`[rsbuild:getTransformedHtml] Failed to get HTML file by entryName: "${entryName}"`);
6108
+ 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
6109
  let fileName = (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(distPath, htmlPath);
6107
6110
  return utils.readFileSync(fileName);
6108
6111
  }, createCacheableFunction = (getter)=>{
@@ -6175,7 +6178,7 @@ async function devServer_createDevServer(options, createCompiler, config, { comp
6175
6178
  });
6176
6179
  }) : Promise.resolve(), startCompile = async ()=>{
6177
6180
  let compiler = customCompiler || await createCompiler();
6178
- if (!compiler) throw Error('[rsbuild:server] Failed to get compiler instance.');
6181
+ if (!compiler) throw Error(`${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim('[rsbuild:server]')} Failed to get compiler instance.`);
6179
6182
  let publicPaths = helpers_isMultiCompiler(compiler) ? compiler.compilers.map(getPublicPathFromCompiler) : [
6180
6183
  getPublicPathFromCompiler(compiler)
6181
6184
  ], compilationManager = new CompilationManager({
@@ -6189,7 +6192,7 @@ async function devServer_createDevServer(options, createCompiler, config, { comp
6189
6192
  environments: context.environments
6190
6193
  });
6191
6194
  return await compilationManager.init(), compilationManager;
6192
- }, protocol = https ? 'https' : 'http', urls = getAddressUrls({
6195
+ }, protocol = https ? 'https' : 'http', urls = await getAddressUrls({
6193
6196
  protocol,
6194
6197
  port,
6195
6198
  host
@@ -6213,9 +6216,9 @@ async function devServer_createDevServer(options, createCompiler, config, { comp
6213
6216
  ]);
6214
6217
  };
6215
6218
  middlewareMode || registerCleanup(closeServer);
6216
- let beforeCreateCompiler = ()=>{
6219
+ let beforeCreateCompiler = async ()=>{
6217
6220
  if (printUrls(), cliShortcutsEnabled) {
6218
- let shortcutsOptions = 'boolean' == typeof devConfig.cliShortcuts ? {} : devConfig.cliShortcuts, cleanup = setupCliShortcuts({
6221
+ let shortcutsOptions = 'boolean' == typeof devConfig.cliShortcuts ? {} : devConfig.cliShortcuts, cleanup = await setupCliShortcuts({
6219
6222
  openPage,
6220
6223
  closeServer,
6221
6224
  printUrls,
@@ -6232,18 +6235,19 @@ async function devServer_createDevServer(options, createCompiler, config, { comp
6232
6235
  name,
6233
6236
  {
6234
6237
  getStats: async ()=>{
6235
- if (!compilationManager) throw Error('[rsbuild:server] Can not call `getStats` when `runCompile` is false');
6238
+ 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
6239
  return await waitFirstCompileDone, lastStats[environment.index];
6237
6240
  },
6241
+ context: environment,
6238
6242
  loadBundle: async (entryName)=>{
6239
- if (!compilationManager) throw Error('[rsbuild:server] Can not call `loadBundle` when `runCompile` is false');
6243
+ 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
6244
  return await waitFirstCompileDone, cacheableLoadBundle(lastStats[environment.index], entryName, {
6241
6245
  readFileSync: compilationManager.readFileSync,
6242
6246
  environment
6243
6247
  });
6244
6248
  },
6245
6249
  getTransformedHtml: async (entryName)=>{
6246
- if (!compilationManager) throw Error('[rsbuild:server] Can not call `getTransformedHtml` when `runCompile` is false');
6250
+ 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
6251
  return await waitFirstCompileDone, cacheableTransformedHtml(lastStats[environment.index], entryName, {
6248
6252
  readFileSync: compilationManager.readFileSync,
6249
6253
  environment
@@ -6263,7 +6267,7 @@ async function devServer_createDevServer(options, createCompiler, config, { comp
6263
6267
  data
6264
6268
  }),
6265
6269
  listen: async ()=>{
6266
- if (!httpServer) throw Error('[rsbuild:server] Can not listen dev server as `server.middlewareMode` is enabled.');
6270
+ 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
6271
  let serverTerminator = getServerTerminator(httpServer);
6268
6272
  return __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.debug('listen dev server'), context.hooks.onCloseDevServer.tap(serverTerminator), new Promise((resolve)=>{
6269
6273
  httpServer.listen({
@@ -6298,7 +6302,7 @@ async function devServer_createDevServer(options, createCompiler, config, { comp
6298
6302
  server: devServerAPI,
6299
6303
  environments: context.environments
6300
6304
  })).filter((item)=>'function' == typeof item);
6301
- runCompile ? context.hooks.onBeforeCreateCompiler.tap(beforeCreateCompiler) : beforeCreateCompiler();
6305
+ runCompile ? context.hooks.onBeforeCreateCompiler.tap(beforeCreateCompiler) : await beforeCreateCompiler();
6302
6306
  let compilationManager = runCompile ? await startCompile() : void 0;
6303
6307
  for (let item of (fileWatcher = await setupWatchFiles({
6304
6308
  dev: devConfig,
@@ -6338,7 +6342,7 @@ async function createCompiler_createCompiler(options) {
6338
6342
  if (await context.hooks.onBeforeCreateCompiler.callBatch({
6339
6343
  bundlerConfigs: rspackConfigs,
6340
6344
  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)}`);
6345
+ }), !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
6346
  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
6347
  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
6348
  };
@@ -6358,7 +6362,9 @@ async function createCompiler_createCompiler(options) {
6358
6362
  }
6359
6363
  __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.start('build started...');
6360
6364
  }(compiler, context), isCompiling = !0;
6361
- }), 'build' === context.action && compiler.hooks.run.tap('rsbuild:run', logRspackVersion);
6365
+ }), 'build' === context.action && compiler.hooks.run.tap('rsbuild:run', ()=>{
6366
+ __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.info('build started...'), logRspackVersion();
6367
+ });
6362
6368
  let done = (stats)=>{
6363
6369
  let statsOptions = getStatsOptions(compiler), statsJson = stats.toJson({
6364
6370
  children: !0,
@@ -6575,7 +6581,7 @@ async function startProdServer(context, config, { getPortSilently } = {}) {
6575
6581
  routes,
6576
6582
  environments: context.environments
6577
6583
  });
6578
- let protocol = https ? 'https' : 'http', urls = getAddressUrls({
6584
+ let protocol = https ? 'https' : 'http', urls = await getAddressUrls({
6579
6585
  protocol,
6580
6586
  port,
6581
6587
  host
@@ -6602,7 +6608,7 @@ async function startProdServer(context, config, { getPortSilently } = {}) {
6602
6608
  });
6603
6609
  if (printUrls(), cliShortcutsEnabled) {
6604
6610
  let shortcutsOptions = 'boolean' == typeof config.dev.cliShortcuts ? {} : config.dev.cliShortcuts;
6605
- setupCliShortcuts({
6611
+ await setupCliShortcuts({
6606
6612
  openPage,
6607
6613
  closeServer,
6608
6614
  printUrls,
@@ -6754,7 +6760,7 @@ async function createRsbuild(options = {}) {
6754
6760
  let { before, environment = RSBUILD_ALL_ENVIRONMENT_SYMBOL } = options || {};
6755
6761
  for (let newPlugin of newPlugins)if (newPlugin) {
6756
6762
  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}.`);
6763
+ 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
6764
  if (!isFunction(newPlugin.setup)) {
6759
6765
  if (isFunction(newPlugin.apply)) {
6760
6766
  let { name = 'SomeWebpackPlugin' } = newPlugin.constructor || {};
@@ -6772,7 +6778,7 @@ async function createRsbuild(options = {}) {
6772
6778
  `)
6773
6779
  ].join('\n'));
6774
6780
  }
6775
- throw Error(`[rsbuild:plugin] Expect the setup function of Rsbuild plugin to be a function, but got ${type}.`);
6781
+ 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
6782
  }
6777
6783
  if (before) {
6778
6784
  let index = plugins.findIndex((item)=>item.instance.name === before);
@@ -6818,12 +6824,12 @@ async function createRsbuild(options = {}) {
6818
6824
  if (context.normalizedConfig) {
6819
6825
  if (null == options ? void 0 : options.environment) {
6820
6826
  let config = context.normalizedConfig.environments[options.environment];
6821
- if (!config) throw Error(`[rsbuild] Cannot find normalized config by environment: ${options.environment}.`);
6827
+ if (!config) throw Error(`${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.dim('[rsbuild]')} Cannot find normalized config by environment: ${options.environment}.`);
6822
6828
  return config;
6823
6829
  }
6824
6830
  return context.normalizedConfig;
6825
6831
  }
6826
- throw Error('[rsbuild] Cannot access normalized config until modifyRsbuildConfig is called.');
6832
+ 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
6833
  }
6828
6834
  let getRsbuildConfig = (type = 'current')=>{
6829
6835
  switch(type){
@@ -6834,7 +6840,7 @@ async function createRsbuild(options = {}) {
6834
6840
  case 'normalized':
6835
6841
  return getNormalizedConfig();
6836
6842
  }
6837
- throw Error('[rsbuild] `getRsbuildConfig` get an invalid type param.');
6843
+ 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
6844
  }, exposed = [], expose = (id, api)=>{
6839
6845
  exposed.push({
6840
6846
  id,
@@ -7017,11 +7023,11 @@ async function createRsbuild(options = {}) {
7017
7023
  pluginManager
7018
7024
  }), { distPath } = context, { checkDistDir = !0 } = options;
7019
7025
  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.`);
7026
+ 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
7027
  if (function(path) {
7022
7028
  let files = __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__.default.readdirSync(path);
7023
7029
  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.`);
7030
+ }(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
7031
  }
7026
7032
  return startProdServer(context, config, options);
7027
7033
  },
@@ -7399,11 +7405,11 @@ async function runCLI() {
7399
7405
  }
7400
7406
  process.title = 'rsbuild-node';
7401
7407
  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`);
7408
+ (!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.4.0-beta.0\n`);
7403
7409
  try {
7404
7410
  !function() {
7405
7411
  let cli = cac_dist('rsbuild');
7406
- cli.help(), cli.version("1.3.21"), applyCommonOptions(cli);
7412
+ cli.help(), cli.version("1.4.0-beta.0"), applyCommonOptions(cli);
7407
7413
  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
7414
  applyServerOptions(devCommand), applyServerOptions(previewCommand), devCommand.action(async (options)=>{
7409
7415
  try {
@@ -7454,6 +7460,6 @@ async function runCLI() {
7454
7460
  __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
7461
  }
7456
7462
  }
7457
- let src_version = "1.3.21";
7463
+ let src_version = "1.4.0-beta.0";
7458
7464
  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 };
7465
+ 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 };