@rsbuild/core 1.3.21 → 1.3.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -979,6 +979,18 @@ var __webpack_modules__ = {
979
979
  return module;
980
980
  });
981
981
  },
982
+ "node:child_process": function(module) {
983
+ "use strict";
984
+ module.exports = import("node:child_process").then(function(module) {
985
+ return module;
986
+ });
987
+ },
988
+ "node:dns": function(module) {
989
+ "use strict";
990
+ module.exports = import("node:dns").then(function(module) {
991
+ return module;
992
+ });
993
+ },
982
994
  "node:http": function(module) {
983
995
  "use strict";
984
996
  module.exports = import("node:http").then(function(module) {
@@ -997,6 +1009,30 @@ var __webpack_modules__ = {
997
1009
  return module;
998
1010
  });
999
1011
  },
1012
+ "node:net": function(module) {
1013
+ "use strict";
1014
+ module.exports = import("node:net").then(function(module) {
1015
+ return module;
1016
+ });
1017
+ },
1018
+ "node:readline": function(module) {
1019
+ "use strict";
1020
+ module.exports = import("node:readline").then(function(module) {
1021
+ return module;
1022
+ });
1023
+ },
1024
+ "node:util": function(module) {
1025
+ "use strict";
1026
+ module.exports = import("node:util").then(function(module) {
1027
+ return module;
1028
+ });
1029
+ },
1030
+ "node:vm": function(module) {
1031
+ "use strict";
1032
+ module.exports = import("node:vm").then(function(module) {
1033
+ return module;
1034
+ });
1035
+ },
1000
1036
  "../../node_modules/.pnpm/dotenv@16.5.0/node_modules/dotenv/package.json": function(module) {
1001
1037
  "use strict";
1002
1038
  module.exports = JSON.parse('{"name":"dotenv","version":"16.5.0","description":"Loads environment variables from .env file","main":"lib/main.js","types":"lib/main.d.ts","exports":{".":{"types":"./lib/main.d.ts","require":"./lib/main.js","default":"./lib/main.js"},"./config":"./config.js","./config.js":"./config.js","./lib/env-options":"./lib/env-options.js","./lib/env-options.js":"./lib/env-options.js","./lib/cli-options":"./lib/cli-options.js","./lib/cli-options.js":"./lib/cli-options.js","./package.json":"./package.json"},"scripts":{"dts-check":"tsc --project tests/types/tsconfig.json","lint":"standard","pretest":"npm run lint && npm run dts-check","test":"tap run --allow-empty-coverage --disable-coverage --timeout=60000","test:coverage":"tap run --show-full-coverage --timeout=60000 --coverage-report=lcov","prerelease":"npm test","release":"standard-version"},"repository":{"type":"git","url":"git://github.com/motdotla/dotenv.git"},"homepage":"https://github.com/motdotla/dotenv#readme","funding":"https://dotenvx.com","keywords":["dotenv","env",".env","environment","variables","config","settings"],"readmeFilename":"README.md","license":"BSD-2-Clause","devDependencies":{"@types/node":"^18.11.3","decache":"^4.6.2","sinon":"^14.0.1","standard":"^17.0.0","standard-version":"^9.5.0","tap":"^19.2.0","typescript":"^4.8.4"},"engines":{"node":">=12"},"browser":{"fs":false}}');
@@ -1043,7 +1079,7 @@ for(var __webpack_i__ in (()=>{
1043
1079
  PLUGIN_SWC_NAME: ()=>PLUGIN_SWC_NAME,
1044
1080
  PLUGIN_CSS_NAME: ()=>PLUGIN_CSS_NAME,
1045
1081
  ensureAssetPrefix: ()=>ensureAssetPrefix,
1046
- loadConfig: ()=>config_loadConfig,
1082
+ loadConfig: ()=>loadConfig_loadConfig,
1047
1083
  defaultAllowedOrigins: ()=>defaultAllowedOrigins
1048
1084
  });
1049
1085
  var provider_helpers_namespaceObject = {};
@@ -1063,9 +1099,7 @@ for(var __webpack_i__ in (()=>{
1063
1099
  setCssExtractPlugin: ()=>setCssExtractPlugin,
1064
1100
  setHTMLPlugin: ()=>setHTMLPlugin
1065
1101
  });
1066
- let core_namespaceObject = require("@rspack/core");
1067
- var core_default = __webpack_require__.n(core_namespaceObject);
1068
- let external_node_fs_namespaceObject = require("node:fs");
1102
+ let core_namespaceObject = require("@rspack/core"), external_node_fs_namespaceObject = require("node:fs");
1069
1103
  var external_node_fs_default = __webpack_require__.n(external_node_fs_namespaceObject);
1070
1104
  let external_node_path_namespaceObject = require("node:path");
1071
1105
  var external_node_path_default = __webpack_require__.n(external_node_path_namespaceObject), main = __webpack_require__("../../node_modules/.pnpm/dotenv@16.5.0/node_modules/dotenv/lib/main.js"), lib_main = __webpack_require__("../../node_modules/.pnpm/dotenv-expand@12.0.2/node_modules/dotenv-expand/lib/main.js");
@@ -1409,7 +1443,7 @@ for(var __webpack_i__ in (()=>{
1409
1443
  case 'assets':
1410
1444
  return filename.assets ?? `[name]${hash}[ext]`;
1411
1445
  default:
1412
- throw Error(`[rsbuild:config] unknown key ${type} in "output.filename"`);
1446
+ throw Error(`${index_js_default().dim('[rsbuild:config]')} unknown key ${index_js_default().yellow(type)} in ${index_js_default().yellow('output.filename')}`);
1413
1447
  }
1414
1448
  }
1415
1449
  let applyToCompiler = (compiler, apply)=>{
@@ -1433,7 +1467,7 @@ for(var __webpack_i__ in (()=>{
1433
1467
  function loadEnv({ cwd = process.cwd(), mode = getNodeEnv(), prefixes = [
1434
1468
  'PUBLIC_'
1435
1469
  ], processEnv = process.env } = {}) {
1436
- 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.");
1470
+ if ('local' === mode) throw Error(`${index_js_default().dim('[rsbuild:loadEnv]')} ${index_js_default().yellow('local')} cannot be used as a value for env mode, because ${index_js_default().yellow('.env.local')} represents a temporary local file. Please use another value.`);
1437
1471
  let filePaths = [
1438
1472
  '.env',
1439
1473
  '.env.local',
@@ -1576,7 +1610,7 @@ for(var __webpack_i__ in (()=>{
1576
1610
  merged[key] = merge(x[key], y[key], childPath);
1577
1611
  }
1578
1612
  return merged;
1579
- }, 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, external_node_module_namespaceObject.createRequire)(__rslib_import_meta_url__), getDefaultDevConfig = ()=>({
1613
+ }, 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, external_node_module_namespaceObject.createRequire)(__rslib_import_meta_url__), getDefaultDevConfig = ()=>({
1580
1614
  hmr: !0,
1581
1615
  liveReload: !0,
1582
1616
  watchFiles: [],
@@ -1604,7 +1638,6 @@ for(var __webpack_i__ in (()=>{
1604
1638
  },
1605
1639
  middlewareMode: !1
1606
1640
  }), getDefaultSourceConfig = ()=>({
1607
- alias: {},
1608
1641
  define: {},
1609
1642
  preEntry: [],
1610
1643
  decorators: {
@@ -1686,7 +1719,7 @@ for(var __webpack_i__ in (()=>{
1686
1719
  exportLocalsConvention: 'camelCase'
1687
1720
  },
1688
1721
  emitAssets: !0
1689
- }), getDefaultResolveConfig = ()=>(swcHelpersPath || (swcHelpersPath = (0, external_node_path_namespaceObject.dirname)(config_require.resolve('@swc/helpers/package.json'))), {
1722
+ }), getDefaultResolveConfig = ()=>(swcHelpersPath || (swcHelpersPath = (0, external_node_path_namespaceObject.dirname)(defaultConfig_require.resolve('@swc/helpers/package.json'))), {
1690
1723
  alias: {
1691
1724
  '@swc/helpers': swcHelpersPath
1692
1725
  },
@@ -1730,82 +1763,7 @@ for(var __webpack_i__ in (()=>{
1730
1763
  return Array.isArray(watchFiles) || (mergedConfig.dev.watchFiles = [
1731
1764
  watchFiles
1732
1765
  ]), mergedConfig;
1733
- };
1734
- function defineConfig(config) {
1735
- return config;
1736
- }
1737
- let resolveConfigPath = (root, customConfig)=>{
1738
- if (customConfig) {
1739
- let customConfigPath = (0, external_node_path_namespaceObject.isAbsolute)(customConfig) ? customConfig : (0, external_node_path_namespaceObject.join)(root, customConfig);
1740
- if (external_node_fs_default().existsSync(customConfigPath)) return customConfigPath;
1741
- rslog_index_js_namespaceObject.logger.warn(`Cannot find config file: ${index_js_default().dim(customConfigPath)}\n`);
1742
- }
1743
- for (let file of [
1744
- 'rsbuild.config.mjs',
1745
- 'rsbuild.config.ts',
1746
- 'rsbuild.config.js',
1747
- 'rsbuild.config.cjs',
1748
- 'rsbuild.config.mts',
1749
- 'rsbuild.config.cts'
1750
- ]){
1751
- let configFile = (0, external_node_path_namespaceObject.join)(root, file);
1752
- if (external_node_fs_default().existsSync(configFile)) return configFile;
1753
- }
1754
- return null;
1755
- };
1756
- async function config_loadConfig({ cwd = process.cwd(), path, envMode, meta, loader = 'jiti' } = {}) {
1757
- let configExport, configFilePath = resolveConfigPath(cwd, path);
1758
- if (!configFilePath) return rslog_index_js_namespaceObject.logger.debug('no config file found.'), {
1759
- content: {},
1760
- filePath: configFilePath
1761
- };
1762
- let applyMetaInfo = (config)=>(config._privateMeta = {
1763
- configFilePath
1764
- }, config);
1765
- if ('native' === loader || /\.(?:js|mjs|cjs)$/.test(configFilePath)) try {
1766
- let configFileURL = (0, external_node_url_namespaceObject.pathToFileURL)(configFilePath).href, exportModule = await import(`${configFileURL}?t=${Date.now()}`);
1767
- configExport = exportModule.default ? exportModule.default : exportModule;
1768
- } catch (err) {
1769
- if ('native' === loader) throw rslog_index_js_namespaceObject.logger.error(`Failed to load file with native loader: ${index_js_default().dim(configFilePath)}`), err;
1770
- rslog_index_js_namespaceObject.logger.debug(`failed to load file with dynamic import: ${index_js_default().dim(configFilePath)}`);
1771
- }
1772
- try {
1773
- if (void 0 === configExport) {
1774
- let { createJiti } = await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "jiti")), jiti = createJiti(constants_filename, {
1775
- moduleCache: !1,
1776
- interopDefault: !0,
1777
- nativeModules: [
1778
- '@rspack/core',
1779
- "typescript"
1780
- ]
1781
- });
1782
- configExport = await jiti.import(configFilePath, {
1783
- default: !0
1784
- });
1785
- }
1786
- } catch (err) {
1787
- throw rslog_index_js_namespaceObject.logger.error(`Failed to load file with jiti: ${index_js_default().dim(configFilePath)}`), err;
1788
- }
1789
- if ('function' == typeof configExport) {
1790
- let command = process.argv[2], nodeEnv = getNodeEnv(), result = await configExport({
1791
- env: nodeEnv,
1792
- command,
1793
- envMode: envMode || nodeEnv,
1794
- meta
1795
- });
1796
- if (void 0 === result) throw Error('[rsbuild:loadConfig] The config function must return a config object.');
1797
- return {
1798
- content: applyMetaInfo(result),
1799
- filePath: configFilePath
1800
- };
1801
- }
1802
- if (!isObject(configExport)) throw Error(`[rsbuild:loadConfig] The config must be an object or a function that returns an object, get ${index_js_default().yellow(configExport)}`);
1803
- return rslog_index_js_namespaceObject.logger.debug('loaded config file:', configFilePath), {
1804
- content: applyMetaInfo(configExport),
1805
- filePath: configFilePath
1806
- };
1807
- }
1808
- let normalizePublicDirs = (publicDir)=>{
1766
+ }, normalizePublicDirs = (publicDir)=>{
1809
1767
  if (!1 === publicDir) return [];
1810
1768
  let defaultConfig = {
1811
1769
  name: 'public',
@@ -1827,7 +1785,7 @@ for(var __webpack_i__ in (()=>{
1827
1785
  let allLines = [];
1828
1786
  function getPlugin(name) {
1829
1787
  let targets = plugins.filter((item)=>item.instance.name === name);
1830
- if (!targets.length) throw Error(`[rsbuild:plugin] Plugin "${name}" not existed`);
1788
+ if (!targets.length) throw Error(`${index_js_default().dim('[rsbuild:plugin]')} Plugin "${index_js_default().yellow(name)}" not existed`);
1831
1789
  return targets;
1832
1790
  }
1833
1791
  for (let plugin of plugins){
@@ -1848,7 +1806,7 @@ for(var __webpack_i__ in (()=>{
1848
1806
  if (allLines.length) {
1849
1807
  let restInRingPoints = {};
1850
1808
  for (let l of allLines)restInRingPoints[l[0]] = !0, restInRingPoints[l[1]] = !0;
1851
- throw Error(`[rsbuild:plugin] Plugins dependencies has loop: ${Object.keys(restInRingPoints).join(',')}`);
1809
+ throw Error(`${index_js_default().dim('[rsbuild:plugin]')} Plugins dependencies has loop: ${index_js_default().yellow(Object.keys(restInRingPoints).join(','))}`);
1852
1810
  }
1853
1811
  return sortedPoint;
1854
1812
  };
@@ -2113,7 +2071,7 @@ for(var __webpack_i__ in (()=>{
2113
2071
  case 'report':
2114
2072
  return Compilation.PROCESS_ASSETS_STAGE_REPORT;
2115
2073
  default:
2116
- throw Error(`[rsbuild] Invalid process assets stage: ${stage}`);
2074
+ throw Error(`${index_js_default().dim('[rsbuild]')} Invalid process assets stage: ${stage}`);
2117
2075
  }
2118
2076
  }, browsersListCache = new Map();
2119
2077
  async function getBrowserslist(path) {
@@ -2168,7 +2126,7 @@ for(var __webpack_i__ in (()=>{
2168
2126
  let filename;
2169
2127
  filename = config.output.filename.html ? config.output.filename.html.replace('[name]', entryName) : 'flat' === config.html.outputStructure ? `${entryName}.html` : `${entryName}/index.html`;
2170
2128
  let prefix = config.output.distPath.html;
2171
- return prefix.startsWith('/') && rslog_index_js_namespaceObject.logger.warn(`Absolute path is not recommended at \`output.distPath.html\`: "${prefix}", please use relative path instead.`), removeLeadingSlash(external_node_path_namespaceObject.posix.join(prefix, filename));
2129
+ return prefix.startsWith('/') && rslog_index_js_namespaceObject.logger.warn(`${index_js_default().dim('[rsbuild:config]')} Absolute path is not recommended at ${index_js_default().yellow(`output.distPath.html: "${prefix}"`)}, use relative path instead.`), removeLeadingSlash(external_node_path_namespaceObject.posix.join(prefix, filename));
2172
2130
  }(key, config)), prev;
2173
2131
  }, {});
2174
2132
  async function updateEnvironmentContext(context, configs) {
@@ -2195,7 +2153,7 @@ for(var __webpack_i__ in (()=>{
2195
2153
  async function createContext(options, userConfig) {
2196
2154
  let { cwd } = options, rootPath = userConfig.root ? ensureAbsolutePath(cwd, userConfig.root) : cwd, rsbuildConfig = await withDefaultConfig(rootPath, userConfig), cachePath = (0, external_node_path_namespaceObject.join)(rootPath, 'node_modules', '.cache'), specifiedEnvironments = options.environment && options.environment.length > 0 ? options.environment : void 0, bundlerType = userConfig.provider ? 'webpack' : 'rspack';
2197
2155
  return {
2198
- version: "1.3.21",
2156
+ version: "1.3.22",
2199
2157
  rootPath,
2200
2158
  distPath: '',
2201
2159
  cachePath,
@@ -2269,21 +2227,21 @@ for(var __webpack_i__ in (()=>{
2269
2227
  let distDir = config.output.distPath.image, manifestFile = appIcon.filename ?? 'manifest.webmanifest', publicPath = getPublicPathFromCompiler(compilation), icons = appIcon.icons.map((icon)=>formatIcon(icon, distDir, publicPath)), tags = [];
2270
2228
  for (let icon of icons){
2271
2229
  if ('web-app-manifest' === icon.target && !appIcon.name) {
2272
- addCompilationError(compilation, '[rsbuild:app-icon] "appIcon.name" is required when "target" is "web-app-manifest".');
2230
+ addCompilationError(compilation, `${index_js_default().dim('[rsbuild:app-icon]')} ${index_js_default().yellow('"appIcon.name"')} is required when ${index_js_default().yellow('"target"')} is ${index_js_default().yellow('"web-app-manifest"')}.`);
2273
2231
  continue;
2274
2232
  }
2275
2233
  if (!icon.isURL) {
2276
2234
  if (!compilation.inputFileSystem) {
2277
- addCompilationError(compilation, '[rsbuild:app-icon] Failed to read the icon file as "compilation.inputFileSystem" is not available.');
2235
+ addCompilationError(compilation, `${index_js_default().dim('[rsbuild:app-icon]')} Failed to read the icon file as ${index_js_default().yellow('"compilation.inputFileSystem"')} is not available.`);
2278
2236
  continue;
2279
2237
  }
2280
2238
  if (!await fileExistsByCompilation(compilation, icon.absolutePath)) {
2281
- addCompilationError(compilation, `[rsbuild:app-icon] Failed to find the icon file at "${index_js_default().cyan(icon.absolutePath)}".`);
2239
+ addCompilationError(compilation, `${index_js_default().dim('[rsbuild:app-icon]')} Failed to find the icon file at ${index_js_default().yellow(icon.absolutePath)}.`);
2282
2240
  continue;
2283
2241
  }
2284
2242
  let source = await (0, external_node_util_namespaceObject.promisify)(compilation.inputFileSystem.readFile)(icon.absolutePath);
2285
2243
  if (!source) {
2286
- addCompilationError(compilation, `[rsbuild:app-icon] Failed to read the icon file at "${index_js_default().cyan(icon.absolutePath)}".`);
2244
+ addCompilationError(compilation, `${index_js_default().dim('[rsbuild:app-icon]')} Failed to read the icon file at ${index_js_default().yellow(icon.absolutePath)}.`);
2287
2245
  continue;
2288
2246
  }
2289
2247
  compilation.emitAsset(icon.relativePath, new sources.RawSource(source));
@@ -2690,7 +2648,7 @@ for(var __webpack_i__ in (()=>{
2690
2648
  plugin && (pluginHelper_htmlPlugin = plugin);
2691
2649
  }, getHTMLPlugin = ()=>(pluginHelper_htmlPlugin || (pluginHelper_htmlPlugin = pluginHelper_require('../compiled/html-rspack-plugin/index.js')), pluginHelper_htmlPlugin), setCssExtractPlugin = (plugin)=>{
2692
2650
  cssExtractPlugin = plugin;
2693
- }, getCssExtractPlugin = ()=>cssExtractPlugin || core_default().CssExtractRspackPlugin, getSwcMinimizerOptions = (config, jsOptions)=>{
2651
+ }, getCssExtractPlugin = ()=>cssExtractPlugin || core_namespaceObject.rspack.CssExtractRspackPlugin, getSwcMinimizerOptions = (config, jsOptions)=>{
2694
2652
  let options = {};
2695
2653
  options.minimizerOptions ||= {}, options.minimizerOptions.format ||= {};
2696
2654
  let { removeConsole } = config.performance;
@@ -2714,26 +2672,27 @@ for(var __webpack_i__ in (()=>{
2714
2672
  options.minimizerOptions.format.comments = !1, options.extractComments = !1;
2715
2673
  }
2716
2674
  return (options.minimizerOptions.format.asciiOnly = 'ascii' === config.output.charset, jsOptions) ? cjs_default()(options, jsOptions) : options;
2717
- }, parseMinifyOptions = (config, isProd)=>{
2718
- let { minify } = config.output;
2719
- return !1 !== minify && isProd ? !0 === minify ? {
2720
- minifyJs: !0,
2721
- minifyCss: !0
2722
- } : {
2723
- minifyJs: !1 !== minify.js,
2724
- minifyCss: !1 !== minify.css,
2675
+ }, parseMinifyOptions = (config)=>{
2676
+ let isProd = 'production' === config.mode, { minify } = config.output;
2677
+ if ('boolean' == typeof minify) {
2678
+ let shouldMinify = !0 === minify && isProd;
2679
+ return {
2680
+ minifyJs: shouldMinify,
2681
+ minifyCss: shouldMinify
2682
+ };
2683
+ }
2684
+ return {
2685
+ minifyJs: !1 !== minify.js && ('always' === minify.js || isProd),
2686
+ minifyCss: !1 !== minify.css && ('always' === minify.css || isProd),
2725
2687
  jsOptions: minify.jsOptions,
2726
2688
  cssOptions: minify.cssOptions
2727
- } : {
2728
- minifyJs: !1,
2729
- minifyCss: !1
2730
2689
  };
2731
2690
  }, pluginMinimize = ()=>({
2732
2691
  name: 'rsbuild:minimize',
2733
2692
  setup (api) {
2734
2693
  let isRspack = 'rspack' === api.context.bundlerType;
2735
- api.modifyBundlerChain(async (chain, { isProd, environment, CHAIN_ID })=>{
2736
- let { config } = environment, { minifyJs, minifyCss, jsOptions, cssOptions } = parseMinifyOptions(config, isProd);
2694
+ api.modifyBundlerChain(async (chain, { environment, CHAIN_ID })=>{
2695
+ let { config } = environment, { minifyJs, minifyCss, jsOptions, cssOptions } = parseMinifyOptions(config);
2737
2696
  if (chain.optimization.minimize(minifyJs || minifyCss), minifyJs && isRspack && chain.optimization.minimizer(CHAIN_ID.MINIMIZER.JS).use(core_namespaceObject.rspack.SwcJsMinimizerRspackPlugin, [
2738
2697
  getSwcMinimizerOptions(config, jsOptions)
2739
2698
  ]).end(), minifyCss && isRspack) {
@@ -2823,7 +2782,7 @@ for(var __webpack_i__ in (()=>{
2823
2782
  if ('function' == typeof postcssOptions) {
2824
2783
  let postcssOptionsWrapper = (loaderContext)=>{
2825
2784
  let options = postcssOptions(loaderContext);
2826
- if ('object' != typeof options || null === options) throw Error(`[rsbuild:css] \`postcssOptions\` function must return a PostCSSOptions object, got "${typeof options}".`);
2785
+ if ('object' != typeof options || null === options) throw Error(`${index_js_default().dim('[rsbuild:css]')} \`postcssOptions\` function must return a PostCSSOptions object, got ${index_js_default().yellow(typeof options)}.`);
2827
2786
  return updatePostcssOptions({
2828
2787
  ...userOptions,
2829
2788
  ...options,
@@ -2884,9 +2843,9 @@ for(var __webpack_i__ in (()=>{
2884
2843
  var _postcssLoaderOptions_postcssOptions_plugins, _postcssLoaderOptions_postcssOptions;
2885
2844
  if ('rspack' === api.context.bundlerType && !1 !== config.tools.lightningcssLoader) {
2886
2845
  importLoaders++;
2887
- let { minifyCss } = parseMinifyOptions(config, isProd);
2846
+ let { minifyCss } = parseMinifyOptions(config);
2888
2847
  updateRules((rule, type)=>{
2889
- let minify = ('inline' === type || config.output.injectStyles) && isProd && minifyCss, lightningcssOptions = getLightningCSSLoaderOptions(config, environment.browserslist, minify);
2848
+ let inlineStyle = 'inline' === type || config.output.injectStyles, lightningcssOptions = getLightningCSSLoaderOptions(config, environment.browserslist, inlineStyle && minifyCss);
2890
2849
  rule.use(CHAIN_ID.USE.LIGHTNINGCSS).loader('builtin:lightningcss-loader').options(lightningcssOptions);
2891
2850
  });
2892
2851
  }
@@ -2957,7 +2916,7 @@ for(var __webpack_i__ in (()=>{
2957
2916
  if (!value) return;
2958
2917
  let check = (value)=>{
2959
2918
  let pathKey = Object.keys(value).find((key)=>'path' === key.toLowerCase() && value[key] === process.env[key]);
2960
- pathKey && rslog_index_js_namespaceObject.logger.warn(index_js_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.`));
2919
+ pathKey && rslog_index_js_namespaceObject.logger.warn(`${index_js_default().dim('[rsbuild:config]')} The ${index_js_default().yellow('"source.define"')} option includes an object with the key ${index_js_default().yellow(JSON.stringify(pathKey))} under ${index_js_default().yellow('"process.env"')}, indicating potential exposure of all environment variables. This can lead to security risks and should be avoided.`);
2961
2920
  };
2962
2921
  if ('object' == typeof value) return check(value);
2963
2922
  if ('string' == typeof value) try {
@@ -2983,7 +2942,7 @@ for(var __webpack_i__ in (()=>{
2983
2942
  preEntry.forEach(addEntry), injectCoreJsEntry && addEntry(createVirtualModule('import "core-js";')), castArray(entry[entryName]).forEach(addEntry);
2984
2943
  }
2985
2944
  }), api.onBeforeCreateCompiler(({ bundlerConfigs })=>{
2986
- if (bundlerConfigs.every((config)=>!config.entry)) throw Error(`[rsbuild:config] Could not find any entry module, please make sure that ${index_js_default().cyan('src/index.(ts|js|tsx|jsx|mts|cts|mjs|cjs)')} exists, or customize entry through the ${index_js_default().cyan('source.entry')} configuration.`);
2945
+ if (bundlerConfigs.every((config)=>!config.entry)) throw Error(`${index_js_default().dim('[rsbuild:config]')} Could not find any entry module, please make sure that ${index_js_default().yellow('src/index.(ts|js|tsx|jsx|mts|cts|mjs|cjs)')} exists, or customize entry through the ${index_js_default().yellow('source.entry')} configuration.`);
2987
2946
  });
2988
2947
  }
2989
2948
  }), external_node_zlib_namespaceObject = require("node:zlib");
@@ -3209,12 +3168,12 @@ for(var __webpack_i__ in (()=>{
3209
3168
  let emitFavicon = async (compilation, favicon)=>{
3210
3169
  let buffer, name = external_node_path_default().basename(favicon);
3211
3170
  if (compilation.assets[name]) return name;
3212
- if (!compilation.inputFileSystem) return addCompilationError(compilation, '[rsbuild:html] Failed to read the favicon file as "compilation.inputFileSystem" is not available.'), null;
3171
+ if (!compilation.inputFileSystem) return addCompilationError(compilation, `${index_js_default().dim('[rsbuild:html]')} Failed to read the favicon file as ${index_js_default().yellow('compilation.inputFileSystem')} is not available.`), null;
3213
3172
  let filename = external_node_path_default().isAbsolute(favicon) ? favicon : external_node_path_default().join(compilation.compiler.context, favicon);
3214
3173
  try {
3215
3174
  if (!(buffer = await (0, external_node_util_namespaceObject.promisify)(compilation.inputFileSystem.readFile)(filename))) throw Error('Buffer is undefined');
3216
3175
  } catch (error) {
3217
- return rslog_index_js_namespaceObject.logger.debug(`read favicon error: ${error}`), addCompilationError(compilation, `[rsbuild:html] Failed to read the favicon file at "${index_js_default().cyan(filename)}".`), null;
3176
+ return rslog_index_js_namespaceObject.logger.debug(`read favicon error: ${error}`), addCompilationError(compilation, `${index_js_default().dim('[rsbuild:html]')} Failed to read the favicon file at ${index_js_default().yellow(filename)}.`), null;
3218
3177
  }
3219
3178
  let source = new compiler.webpack.sources.RawSource(buffer, !1);
3220
3179
  return compilation.emitAsset(name, source), name;
@@ -3312,7 +3271,7 @@ for(var __webpack_i__ in (()=>{
3312
3271
  };
3313
3272
  let absolutePath = (0, external_node_path_namespaceObject.isAbsolute)(templatePath) ? templatePath : external_node_path_default().join(rootPath, templatePath);
3314
3273
  if (!existTemplatePath.has(absolutePath)) {
3315
- if (!await isFileExists(absolutePath)) throw Error(`[rsbuild:html] Failed to resolve HTML template, please check if the file exists: ${index_js_default().cyan(absolutePath)}`);
3274
+ if (!await isFileExists(absolutePath)) throw Error(`${index_js_default().dim('[rsbuild:html]')} Failed to resolve HTML template, check if the file exists: ${index_js_default().yellow(absolutePath)}`);
3316
3275
  existTemplatePath.add(absolutePath);
3317
3276
  }
3318
3277
  let templateContent = await external_node_fs_default().promises.readFile(absolutePath, 'utf-8');
@@ -3608,7 +3567,7 @@ for(var __webpack_i__ in (()=>{
3608
3567
  manifestData
3609
3568
  });
3610
3569
  if (isObject(generatedManifest)) return environment.manifest = generatedManifest, generatedManifest;
3611
- throw Error('[rsbuild:manifest] `manifest.generate` function must return a valid manifest object.');
3570
+ throw Error(`${index_js_default().dim('[rsbuild:manifest]')} \`manifest.generate\` function must return a valid manifest object.`);
3612
3571
  }
3613
3572
  return environment.manifest = manifestData, manifestData;
3614
3573
  }, pluginManifest = ()=>({
@@ -3641,7 +3600,7 @@ for(var __webpack_i__ in (()=>{
3641
3600
  }), api.onAfterCreateCompiler(()=>{
3642
3601
  if (manifestFilenames.size <= 1) return void manifestFilenames.clear();
3643
3602
  let environmentNames = Array.from(manifestFilenames.keys()), filenames = Array.from(manifestFilenames.values());
3644
- new Set(filenames).size !== filenames.length && rslog_index_js_namespaceObject.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();
3603
+ new Set(filenames).size !== filenames.length && rslog_index_js_namespaceObject.logger.warn(`${index_js_default().dim('[rsbuild:manifest]')} The ${index_js_default().yellow('"manifest.filename"')} option must be unique when there are multiple environments (${environmentNames.join(', ')}), otherwise the manifest file will be overwritten.`), manifestFilenames.clear();
3645
3604
  });
3646
3605
  }
3647
3606
  });
@@ -3713,7 +3672,7 @@ for(var __webpack_i__ in (()=>{
3713
3672
  raw: !0
3714
3673
  }, ({ code, emitFile, resourcePath })=>{
3715
3674
  let name = nodeAddons_getFilename(resourcePath);
3716
- if (null === name) throw Error(`[rsbuild:node-addons] Failed to load Node.js addon: "${resourcePath}"`);
3675
+ if (null === name) throw Error(`${index_js_default().dim('[rsbuild:node-addons]')} Failed to load Node.js addon: ${index_js_default().yellow(resourcePath)}`);
3717
3676
  return emitFile(name, code), `
3718
3677
  try {
3719
3678
  const path = require("path");
@@ -3760,9 +3719,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
3760
3719
  }
3761
3720
  });
3762
3721
  }
3763
- }), external_node_child_process_namespaceObject = require("node:child_process"), external_node_net_namespaceObject = require("node:net");
3764
- var external_node_net_default = __webpack_require__.n(external_node_net_namespaceObject);
3765
- let normalizeUrl = (url)=>url.replace(/([^:]\/)\/+/g, '$1'), formatPrefix = (input)=>{
3722
+ }), normalizeUrl = (url)=>url.replace(/([^:]\/)\/+/g, '$1'), formatPrefix = (input)=>{
3766
3723
  let prefix = input;
3767
3724
  if ((null == prefix ? void 0 : prefix.startsWith('./')) && (prefix = prefix.replace('./', '')), !prefix) return '/';
3768
3725
  let hasLeadingSlash = prefix.startsWith('/'), hasTailSlash = prefix.endsWith('/');
@@ -3792,7 +3749,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
3792
3749
  protocol
3793
3750
  });
3794
3751
  if (!newUrls) return null;
3795
- if (!Array.isArray(newUrls)) throw Error(`[rsbuild:config] "server.printUrls" must return an array, but got ${typeof newUrls}.`);
3752
+ if (!Array.isArray(newUrls)) throw Error(`${index_js_default().dim('[rsbuild:config]')} "server.printUrls" must return an array, but got ${typeof newUrls}.`);
3796
3753
  urls = newUrls.map((url)=>({
3797
3754
  url,
3798
3755
  label: getUrlLabel(url)
@@ -3816,10 +3773,10 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
3816
3773
  }
3817
3774
  let getPort = async ({ host, port, strictPort, tryLimits = 20 })=>{
3818
3775
  'string' == typeof port && (port = Number.parseInt(port, 10)), strictPort && (tryLimits = 1);
3819
- let original = port, found = !1, attempts = 0;
3776
+ let { createServer } = await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "node:net")), original = port, found = !1, attempts = 0;
3820
3777
  for(; !found && attempts <= tryLimits;)try {
3821
3778
  await new Promise((resolve, reject)=>{
3822
- let server = external_node_net_default().createServer();
3779
+ let server = createServer();
3823
3780
  server.unref(), server.on('error', reject), server.listen({
3824
3781
  port,
3825
3782
  host
@@ -3831,7 +3788,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
3831
3788
  if ('EADDRINUSE' !== e.code) throw e;
3832
3789
  port++, attempts++;
3833
3790
  }
3834
- if (port !== original && strictPort) throw Error(`[rsbuild:server] Port "${original}" is occupied, please choose another one.`);
3791
+ if (port !== original && strictPort) throw Error(`${index_js_default().dim('[rsbuild:server]')} Port ${index_js_default().yellow(original)} is occupied, please choose another one.`);
3835
3792
  return port;
3836
3793
  }, getServerConfig = async ({ config })=>{
3837
3794
  let { host, port: originalPort, strictPort } = config.server, port = await getPort({
@@ -3861,24 +3818,31 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
3861
3818
  '127.0.0.1',
3862
3819
  '::1',
3863
3820
  '0000:0000:0000:0000:0000:0000:0000:0001'
3864
- ]).has(host), getHostInUrl = (host)=>host === DEFAULT_DEV_HOST ? 'localhost' : external_node_net_default().isIPv6(host) ? '::' === host ? '[::1]' : `[${host}]` : host, concatUrl = ({ host, port, protocol })=>`${protocol}://${host}:${port}`, LOCAL_LABEL = 'Local: ', NETWORK_LABEL = 'Network: ', getUrlLabel = (url)=>{
3821
+ ]).has(host), getHostInUrl = async (host)=>{
3822
+ if (host === DEFAULT_DEV_HOST) return 'localhost';
3823
+ let { isIPv6 } = await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "node:net"));
3824
+ return isIPv6(host) ? '::' === host ? '[::1]' : `[${host}]` : host;
3825
+ }, concatUrl = ({ host, port, protocol })=>`${protocol}://${host}:${port}`, LOCAL_LABEL = 'Local: ', NETWORK_LABEL = 'Network: ', getUrlLabel = (url)=>{
3865
3826
  try {
3866
3827
  let { host } = new URL(url);
3867
3828
  return isLoopbackHost(host) ? LOCAL_LABEL : NETWORK_LABEL;
3868
3829
  } catch (err) {
3869
3830
  return NETWORK_LABEL;
3870
3831
  }
3871
- }, getAddressUrls = ({ protocol = 'http', port, host })=>{
3872
- if (host && host !== DEFAULT_DEV_HOST) return [
3873
- {
3874
- label: isLoopbackHost(host) ? LOCAL_LABEL : NETWORK_LABEL,
3875
- url: concatUrl({
3876
- port,
3877
- host: getHostInUrl(host),
3878
- protocol
3879
- })
3880
- }
3881
- ];
3832
+ }, getAddressUrls = async ({ protocol = 'http', port, host })=>{
3833
+ if (host && host !== DEFAULT_DEV_HOST) {
3834
+ let url = concatUrl({
3835
+ port,
3836
+ host: await getHostInUrl(host),
3837
+ protocol
3838
+ });
3839
+ return [
3840
+ {
3841
+ label: isLoopbackHost(host) ? LOCAL_LABEL : NETWORK_LABEL,
3842
+ url
3843
+ }
3844
+ ];
3845
+ }
3882
3846
  let ipv4Interfaces = getIpv4Interfaces(), addressUrls = [], hasLocalUrl = !1;
3883
3847
  for (let detail of ipv4Interfaces)if (isLoopbackHost(detail.address) || detail.internal) {
3884
3848
  if (hasLocalUrl) continue;
@@ -3916,7 +3880,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
3916
3880
  listened ? server.close((err)=>err ? reject(err) : resolve()) : resolve();
3917
3881
  });
3918
3882
  }
3919
- let execAsync = (0, external_node_util_namespaceObject.promisify)(external_node_child_process_namespaceObject.exec), supportedChromiumBrowsers = [
3883
+ let supportedChromiumBrowsers = [
3920
3884
  'Google Chrome Canary',
3921
3885
  'Google Chrome Dev',
3922
3886
  'Google Chrome Beta',
@@ -3925,20 +3889,23 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
3925
3889
  'Brave Browser',
3926
3890
  'Vivaldi',
3927
3891
  'Chromium'
3928
- ], getDefaultBrowserForAppleScript = async ()=>{
3929
- let { stdout: ps } = await execAsync('ps cax');
3930
- return supportedChromiumBrowsers.find((b)=>ps.includes(b));
3931
- }, mapChromiumBrowserName = (browser)=>'chrome' === browser || 'google chrome' === browser ? 'Google Chrome' : browser, shouldTryAppleScript = (browser, browserArgs)=>'darwin' === process.platform && (!browser || !browserArgs) && (!browser || supportedChromiumBrowsers.includes(mapChromiumBrowserName(browser)));
3892
+ ], mapChromiumBrowserName = (browser)=>'chrome' === browser || 'google chrome' === browser ? 'Google Chrome' : browser, shouldTryAppleScript = (browser, browserArgs)=>'darwin' === process.platform && (!browser || !browserArgs) && (!browser || supportedChromiumBrowsers.includes(mapChromiumBrowserName(browser)));
3932
3893
  async function openBrowser(url) {
3933
3894
  let browser = process.env.BROWSER, browserArgs = process.env.BROWSER_ARGS;
3934
- if (shouldTryAppleScript(browser, browserArgs)) try {
3935
- let chromiumBrowser = browser ? mapChromiumBrowserName(browser) : await getDefaultBrowserForAppleScript();
3936
- if (chromiumBrowser) return await execAsync(`osascript openChrome.applescript "${encodeURI(url)}" "${chromiumBrowser}"`, {
3937
- cwd: STATIC_PATH
3938
- }), !0;
3939
- rslog_index_js_namespaceObject.logger.debug('failed to find the target browser.');
3940
- } catch (err) {
3941
- rslog_index_js_namespaceObject.logger.debug("failed to open start URL with apple script."), rslog_index_js_namespaceObject.logger.debug(err);
3895
+ if (shouldTryAppleScript(browser, browserArgs)) {
3896
+ let { exec } = await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "node:child_process")), { promisify } = await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "node:util")), execAsync = promisify(exec), getDefaultBrowserForAppleScript = async ()=>{
3897
+ let { stdout: ps } = await execAsync('ps cax');
3898
+ return supportedChromiumBrowsers.find((b)=>ps.includes(b));
3899
+ };
3900
+ try {
3901
+ let chromiumBrowser = browser ? mapChromiumBrowserName(browser) : await getDefaultBrowserForAppleScript();
3902
+ if (chromiumBrowser) return await execAsync(`osascript openChrome.applescript "${encodeURI(url)}" "${chromiumBrowser}"`, {
3903
+ cwd: STATIC_PATH
3904
+ }), !0;
3905
+ rslog_index_js_namespaceObject.logger.debug('failed to find the target browser.');
3906
+ } catch (err) {
3907
+ rslog_index_js_namespaceObject.logger.debug("failed to open start URL with apple script."), rslog_index_js_namespaceObject.logger.debug(err);
3908
+ }
3942
3909
  }
3943
3910
  try {
3944
3911
  let { default: open } = await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "../../compiled/open/index.js")), { apps } = open, options = browser ? {
@@ -3973,13 +3940,13 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
3973
3940
  let { targets, before } = normalizeOpenConfig(config);
3974
3941
  if ('true' === process.env.CSB) return;
3975
3942
  clearCache && clearOpenedURLs();
3976
- let urls = [], host = getHostInUrl(config.server.host), baseUrl = `${https ? 'https' : 'http'}://${host}:${port}`;
3943
+ let urls = [], host = await getHostInUrl(config.server.host), baseUrl = `${https ? 'https' : 'http'}://${host}:${port}`;
3977
3944
  for (let url of (targets.length ? urls.push(...targets.map((target)=>(function(str, base) {
3978
3945
  if (canParse(str)) return str;
3979
3946
  try {
3980
3947
  return new URL(str, base).href;
3981
3948
  } catch (e) {
3982
- throw Error('[rsbuild:open]: Invalid input: not a valid URL or pathname');
3949
+ throw Error(`${index_js_default().dim('[rsbuild:open]')} Invalid input: ${index_js_default().yellow(str)} is not a valid URL or pathname`);
3983
3950
  }
3984
3951
  })(replacePortPlaceholder(target, port), baseUrl))) : routes.length && urls.push(`${baseUrl}${routes[0].pathname}`), before && await before(), urls))openedURLs.includes(url) || (openBrowser(url), openedURLs.push(url));
3985
3952
  }
@@ -4083,13 +4050,13 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
4083
4050
  initial: {},
4084
4051
  config: config.resolve.alias
4085
4052
  });
4086
- if (mergedAlias = reduceConfigs({
4053
+ if (config.source.alias && (rslog_index_js_namespaceObject.logger.warn(`${index_js_default().dim('[rsbuild:config]')} The ${index_js_default().yellow('"source.alias"')} config is deprecated, use ${index_js_default().yellow('"resolve.alias"')} instead.`), mergedAlias = reduceConfigs({
4087
4054
  initial: mergedAlias,
4088
4055
  config: config.source.alias
4089
- }), config.resolve.dedupe) for (let pkgName of config.resolve.dedupe){
4056
+ })), config.resolve.dedupe) for (let pkgName of config.resolve.dedupe){
4090
4057
  let pkgPath;
4091
4058
  if (mergedAlias[pkgName]) {
4092
- rslog_index_js_namespaceObject.logger.debug(`[rsbuild:resolve] The package "${pkgName}" is already in the alias config, dedupe option for "${pkgName}" will be ignored.`);
4059
+ rslog_index_js_namespaceObject.logger.debug(`${index_js_default().dim('[rsbuild:resolve]')} The package ${index_js_default().yellow(pkgName)} is already in the alias config, dedupe option for ${index_js_default().yellow(pkgName)} will be ignored.`);
4093
4060
  continue;
4094
4061
  }
4095
4062
  try {
@@ -4111,7 +4078,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
4111
4078
  ].join(external_node_path_namespaceObject.sep);
4112
4079
  for(; !pkgPath.endsWith(trailing) && pkgPath.includes('node_modules');)pkgPath = (0, external_node_path_namespaceObject.dirname)(pkgPath);
4113
4080
  } catch (e) {
4114
- rslog_index_js_namespaceObject.logger.debug(`[rsbuild:resolve] The package "${pkgName}" is not resolved in the project, dedupe option for "${pkgName}" will be ignored.`);
4081
+ rslog_index_js_namespaceObject.logger.debug(`${index_js_default().dim('[rsbuild:resolve]')} The package ${index_js_default().yellow(pkgName)} is not resolved in the project, dedupe option for ${index_js_default().yellow(pkgName)} will be ignored.`);
4115
4082
  continue;
4116
4083
  }
4117
4084
  mergedAlias[pkgName] = pkgPath;
@@ -4124,7 +4091,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
4124
4091
  chain,
4125
4092
  config,
4126
4093
  rootPath: api.context.rootPath
4127
- }), chain.module.rule(CHAIN_ID.RULE.MJS).test(/\.m?js/).resolve.set('fullySpecified', !1);
4094
+ }), chain.module.rule(CHAIN_ID.RULE.MJS).test(/\.m?js/).resolve.set('fullySpecified', !1), config.source.aliasStrategy && rslog_index_js_namespaceObject.logger.warn(`${index_js_default().dim('[rsbuild:config]')} The ${index_js_default().yellow('"source.aliasStrategy"')} config is deprecated, use ${index_js_default().yellow('"resolve.aliasStrategy"')} instead.`);
4128
4095
  let aliasStrategy = config.source.aliasStrategy ?? config.resolve.aliasStrategy;
4129
4096
  tsconfigPath && 'rspack' === api.context.bundlerType && 'prefer-tsconfig' === aliasStrategy && chain.resolve.tsConfig({
4130
4097
  configFile: tsconfigPath,
@@ -4359,7 +4326,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
4359
4326
  traceOutput = 'chrome' === traceLayer ? defaultRustTraceChromeOutput : 'stdout';
4360
4327
  }
4361
4328
  let filter = "OVERVIEW" === (value = filterValue) ? 'info' : "ALL" === value ? 'trace' : value;
4362
- return await ensureFileDir(traceOutput), await core_default().experiments.globalTrace.register(filter, traceLayer, traceOutput), traceOutput;
4329
+ return await ensureFileDir(traceOutput), await core_namespaceObject.rspack.experiments.globalTrace.register(filter, traceLayer, traceOutput), traceOutput;
4363
4330
  }
4364
4331
  let pluginRspackProfile = ()=>({
4365
4332
  name: 'rsbuild:rspack-profile',
@@ -4374,7 +4341,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
4374
4341
  api.onBeforeBuild(({ isFirstCompile })=>{
4375
4342
  isFirstCompile && onStart();
4376
4343
  }), api.onBeforeStartDevServer(onStart), api.onExit(()=>{
4377
- traceOutput && (core_default().experiments.globalTrace.cleanup(), rslog_index_js_namespaceObject.logger.info(`profile file saved to ${index_js_default().cyan(traceOutput)}`));
4344
+ traceOutput && (core_namespaceObject.rspack.experiments.globalTrace.cleanup(), rslog_index_js_namespaceObject.logger.info(`profile file saved to ${index_js_default().cyan(traceOutput)}`));
4378
4345
  });
4379
4346
  }
4380
4347
  }), pluginServer = ()=>({
@@ -4410,9 +4377,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
4410
4377
  }
4411
4378
  });
4412
4379
  }
4413
- }), external_node_assert_namespaceObject = require("node:assert");
4414
- var external_node_assert_default = __webpack_require__.n(external_node_assert_namespaceObject);
4415
- let MODULE_PATH_REGEX = /.*[\\/]node_modules[\\/](?!\.pnpm[\\/])(?:(@[^\\/]+)[\\/])?([^\\/]+)/, SPLIT_STRATEGY_DISPATCHER = {
4380
+ }), MODULE_PATH_REGEX = /.*[\\/]node_modules[\\/](?!\.pnpm[\\/])(?:(@[^\\/]+)[\\/])?([^\\/]+)/, SPLIT_STRATEGY_DISPATCHER = {
4416
4381
  'split-by-experience': function(ctx) {
4417
4382
  let { override, polyfill, defaultConfig, forceSplittingGroups } = ctx, experienceCacheGroup = {}, packageRegExps = {
4418
4383
  axios: /node_modules[\\/]axios(-.+)?[\\/]/
@@ -4466,7 +4431,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
4466
4431
  },
4467
4432
  'split-by-size': function(ctx) {
4468
4433
  let { override, forceSplittingGroups, defaultConfig, userConfig } = ctx;
4469
- return external_node_assert_default()('split-by-size' === userConfig.strategy), {
4434
+ return {
4470
4435
  ...defaultConfig,
4471
4436
  minSize: userConfig.minSize ?? 0,
4472
4437
  maxSize: userConfig.maxSize ?? Number.POSITIVE_INFINITY,
@@ -4643,7 +4608,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
4643
4608
  swcConfig.jsc.transform.legacyDecorator = !1, swcConfig.jsc.transform.decoratorVersion = '2022-03';
4644
4609
  break;
4645
4610
  default:
4646
- throw Error(`[rsbuild:swc] Unknown decorators version: ${version}`);
4611
+ throw Error(`${index_js_default().dim('[rsbuild:swc]')} Unknown decorators version: ${index_js_default().yellow(version)}`);
4647
4612
  }
4648
4613
  }(swcConfig, config), castArray(target1 = target).includes('web') || target1.includes('web-worker')) {
4649
4614
  let polyfillMode = config.output.polyfill;
@@ -4897,17 +4862,18 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
4897
4862
  if (config.plugins) {
4898
4863
  for (let plugin of config.plugins)if (plugin && void 0 === plugin.apply && 'name' in plugin && 'setup' in plugin) {
4899
4864
  let name = index_js_default().bold(index_js_default().yellow(plugin.name));
4900
- throw Error(`[rsbuild:plugin] "${name}" appears to be an Rsbuild plugin. It cannot be used as an Rspack plugin.`);
4865
+ throw Error(`${index_js_default().dim('[rsbuild:plugin]')} "${index_js_default().yellow(name)}" appears to be an Rsbuild plugin. It cannot be used as an Rspack plugin.`);
4901
4866
  }
4902
4867
  }
4903
- return config.devServer && rslog_index_js_namespaceObject.logger.warn(`[rsbuild:config] Find invalid Rspack config: "${index_js_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;
4868
+ return config.devServer && rslog_index_js_namespaceObject.logger.warn(`${index_js_default().dim('[rsbuild:config]')} Find invalid Rspack config: "${index_js_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;
4904
4869
  }
4905
4870
  async function modifyRsbuildConfig(context) {
4871
+ var _context_config_plugins, _modified_plugins;
4906
4872
  rslog_index_js_namespaceObject.logger.debug('modify Rsbuild config');
4907
- let [modified] = await context.hooks.modifyRsbuildConfig.callChain(context.config, {
4873
+ let pluginsCount = (null == (_context_config_plugins = context.config.plugins) ? void 0 : _context_config_plugins.length) ?? 0, [modified] = await context.hooks.modifyRsbuildConfig.callChain(context.config, {
4908
4874
  mergeRsbuildConfig: mergeRsbuildConfig
4909
4875
  });
4910
- context.config = modified, rslog_index_js_namespaceObject.logger.debug('modify Rsbuild config done');
4876
+ context.config = modified, ((null == (_modified_plugins = modified.plugins) ? void 0 : _modified_plugins.length) ?? 0) !== pluginsCount && rslog_index_js_namespaceObject.logger.warn(`${index_js_default().dim('[rsbuild]')} Cannot change plugins via ${index_js_default().yellow('modifyRsbuildConfig')} as plugins are already initialized when it executes.`), rslog_index_js_namespaceObject.logger.debug('modify Rsbuild config done');
4911
4877
  }
4912
4878
  async function modifyEnvironmentConfig(context, config, name) {
4913
4879
  rslog_index_js_namespaceObject.logger.debug(`modify Rsbuild environment(${name}) config`);
@@ -4959,11 +4925,11 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
4959
4925
  }, config)
4960
4926
  })
4961
4927
  ]));
4962
- if (!Object.keys(resolvedEnvironments).length) throw Error(`[rsbuild:config] The current build is specified to run only in the ${index_js_default().yellow(null == specifiedEnvironments ? void 0 : specifiedEnvironments.join(','))} environment, but the configuration of the specified environment was not found.`);
4928
+ if (!Object.keys(resolvedEnvironments).length) throw Error(`${index_js_default().dim('[rsbuild:config]')} The current build is specified to run only in the ${index_js_default().yellow(null == specifiedEnvironments ? void 0 : specifiedEnvironments.join(','))} environment, but the configuration of the specified environment was not found.`);
4963
4929
  return resolvedEnvironments;
4964
4930
  }
4965
4931
  let defaultEnvironmentName = camelCase(rsbuildSharedConfig.output.target);
4966
- if (!isEnvironmentEnabled(defaultEnvironmentName)) throw Error(`[rsbuild:config] The current build is specified to run only in the ${index_js_default().yellow(null == specifiedEnvironments ? void 0 : specifiedEnvironments.join(','))} environment, but the configuration of the specified environment was not found.`);
4932
+ if (!isEnvironmentEnabled(defaultEnvironmentName)) throw Error(`${index_js_default().dim('[rsbuild:config]')} The current build is specified to run only in the ${index_js_default().yellow(null == specifiedEnvironments ? void 0 : specifiedEnvironments.join(','))} environment, but the configuration of the specified environment was not found.`);
4967
4933
  return {
4968
4934
  [defaultEnvironmentName]: applyEnvironmentDefaultConfig({
4969
4935
  ...rsbuildSharedConfig,
@@ -4977,7 +4943,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
4977
4943
  })
4978
4944
  };
4979
4945
  }, validateRsbuildConfig = (config)=>{
4980
- if (config.server.base && !config.server.base.startsWith('/')) throw Error('[rsbuild:config] The "server.base" option should start with a slash, for example: "/base"');
4946
+ if (config.server.base && !config.server.base.startsWith('/')) throw Error(`${index_js_default().dim('[rsbuild:config]')} The ${index_js_default().yellow('"server.base"')} option should start with a slash, for example: "/base"`);
4981
4947
  };
4982
4948
  async function initRsbuildConfig({ context, pluginManager }) {
4983
4949
  if (context.normalizedConfig) return context.normalizedConfig;
@@ -5054,9 +5020,83 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
5054
5020
  rspackConfigs
5055
5021
  };
5056
5022
  }
5023
+ function defineConfig(config) {
5024
+ return config;
5025
+ }
5026
+ let resolveConfigPath = (root, customConfig)=>{
5027
+ if (customConfig) {
5028
+ let customConfigPath = (0, external_node_path_namespaceObject.isAbsolute)(customConfig) ? customConfig : (0, external_node_path_namespaceObject.join)(root, customConfig);
5029
+ if (external_node_fs_default().existsSync(customConfigPath)) return customConfigPath;
5030
+ rslog_index_js_namespaceObject.logger.warn(`Cannot find config file: ${index_js_default().dim(customConfigPath)}\n`);
5031
+ }
5032
+ for (let file of [
5033
+ 'rsbuild.config.mjs',
5034
+ 'rsbuild.config.ts',
5035
+ 'rsbuild.config.js',
5036
+ 'rsbuild.config.cjs',
5037
+ 'rsbuild.config.mts',
5038
+ 'rsbuild.config.cts'
5039
+ ]){
5040
+ let configFile = (0, external_node_path_namespaceObject.join)(root, file);
5041
+ if (external_node_fs_default().existsSync(configFile)) return configFile;
5042
+ }
5043
+ return null;
5044
+ };
5045
+ async function loadConfig_loadConfig({ cwd = process.cwd(), path, envMode, meta, loader = 'jiti' } = {}) {
5046
+ let configExport, configFilePath = resolveConfigPath(cwd, path);
5047
+ if (!configFilePath) return rslog_index_js_namespaceObject.logger.debug('no config file found.'), {
5048
+ content: {},
5049
+ filePath: configFilePath
5050
+ };
5051
+ let applyMetaInfo = (config)=>(config._privateMeta = {
5052
+ configFilePath
5053
+ }, config);
5054
+ if ('native' === loader || /\.(?:js|mjs|cjs)$/.test(configFilePath)) try {
5055
+ let configFileURL = (0, external_node_url_namespaceObject.pathToFileURL)(configFilePath).href, exportModule = await import(`${configFileURL}?t=${Date.now()}`);
5056
+ configExport = exportModule.default ? exportModule.default : exportModule;
5057
+ } catch (err) {
5058
+ if ('native' === loader) throw rslog_index_js_namespaceObject.logger.error(`Failed to load file with native loader: ${index_js_default().dim(configFilePath)}`), err;
5059
+ rslog_index_js_namespaceObject.logger.debug(`failed to load file with dynamic import: ${index_js_default().dim(configFilePath)}`);
5060
+ }
5061
+ try {
5062
+ if (void 0 === configExport) {
5063
+ let { createJiti } = await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "jiti")), jiti = createJiti(constants_filename, {
5064
+ moduleCache: !1,
5065
+ interopDefault: !0,
5066
+ nativeModules: [
5067
+ '@rspack/core',
5068
+ "typescript"
5069
+ ]
5070
+ });
5071
+ configExport = await jiti.import(configFilePath, {
5072
+ default: !0
5073
+ });
5074
+ }
5075
+ } catch (err) {
5076
+ throw rslog_index_js_namespaceObject.logger.error(`Failed to load file with jiti: ${index_js_default().dim(configFilePath)}`), err;
5077
+ }
5078
+ if ('function' == typeof configExport) {
5079
+ let command = process.argv[2], nodeEnv = getNodeEnv(), result = await configExport({
5080
+ env: nodeEnv,
5081
+ command,
5082
+ envMode: envMode || nodeEnv,
5083
+ meta
5084
+ });
5085
+ if (void 0 === result) throw Error(`${index_js_default().dim('[rsbuild:loadConfig]')} The config function must return a config object.`);
5086
+ return {
5087
+ content: applyMetaInfo(result),
5088
+ filePath: configFilePath
5089
+ };
5090
+ }
5091
+ if (!isObject(configExport)) throw Error(`${index_js_default().dim('[rsbuild:loadConfig]')} The config must be an object or a function that returns an object, get ${index_js_default().yellow(configExport)}`);
5092
+ return rslog_index_js_namespaceObject.logger.debug('loaded config file:', configFilePath), {
5093
+ content: applyMetaInfo(configExport),
5094
+ filePath: configFilePath
5095
+ };
5096
+ }
5057
5097
  let commonOpts = {}, getEnvDir = (cwd, envDir)=>envDir ? external_node_path_default().isAbsolute(envDir) ? envDir : external_node_path_default().join(cwd, envDir) : cwd, init_loadConfig = async (root)=>{
5058
5098
  var _config_server;
5059
- let { content: config, filePath } = await config_loadConfig({
5099
+ let { content: config, filePath } = await loadConfig_loadConfig({
5060
5100
  cwd: root,
5061
5101
  path: commonOpts.config,
5062
5102
  envMode: commonOpts.envMode,
@@ -5216,10 +5256,8 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
5216
5256
  };
5217
5257
  watcher.on('add', onChange), watcher.on('change', onChange), watcher.on('unlink', onChange);
5218
5258
  }
5219
- let external_node_readline_namespaceObject = require("node:readline");
5220
- var external_node_readline_default = __webpack_require__.n(external_node_readline_namespaceObject);
5221
5259
  let isCliShortcutsEnabled = (devConfig)=>devConfig.cliShortcuts && isTTY('stdin');
5222
- function setupCliShortcuts({ help = !0, openPage, closeServer, printUrls, restartServer, customShortcuts }) {
5260
+ async function setupCliShortcuts({ help = !0, openPage, closeServer, printUrls, restartServer, customShortcuts }) {
5223
5261
  let shortcuts = [
5224
5262
  {
5225
5263
  key: 'c',
@@ -5255,9 +5293,9 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
5255
5293
  action: printUrls
5256
5294
  }
5257
5295
  ].filter(Boolean);
5258
- if (customShortcuts && !Array.isArray(shortcuts = customShortcuts(shortcuts))) throw Error('[rsbuild:config] `dev.cliShortcuts` must return an array of shortcuts.');
5259
- help && rslog_index_js_namespaceObject.logger.log(` \u{279C} ${index_js_default().dim('press')} ${index_js_default().bold('h + enter')} ${index_js_default().dim('to show shortcuts')}\n`);
5260
- let rl = external_node_readline_default().createInterface({
5296
+ if (customShortcuts && !Array.isArray(shortcuts = customShortcuts(shortcuts))) throw Error(`${index_js_default().dim('[rsbuild:config]')} ${index_js_default().yellow('dev.cliShortcuts')} option must return an array of shortcuts.`);
5297
+ help && rslog_index_js_namespaceObject.logger.log(!0 === help ? ` \u{279C} ${index_js_default().dim('press')} ${index_js_default().bold('h + enter')} ${index_js_default().dim('to show shortcuts')}\n` : ` \u{279C} ${help}\n`);
5298
+ let { createInterface } = await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "node:readline")), rl = createInterface({
5261
5299
  input: process.stdin
5262
5300
  });
5263
5301
  return rl.on('line', (input)=>{
@@ -5271,11 +5309,10 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
5271
5309
  rl.close();
5272
5310
  };
5273
5311
  }
5274
- let external_node_dns_namespaceObject = require("node:dns");
5275
5312
  async function getLocalhostResolvedAddress() {
5276
- let [defaultLookup, explicitLookup] = await Promise.all([
5277
- external_node_dns_namespaceObject.promises.lookup('localhost'),
5278
- external_node_dns_namespaceObject.promises.lookup('localhost', {
5313
+ let { promises: dns } = await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "node:dns")), [defaultLookup, explicitLookup] = await Promise.all([
5314
+ dns.lookup('localhost'),
5315
+ dns.lookup('localhost', {
5279
5316
  verbatim: !0
5280
5317
  })
5281
5318
  ]);
@@ -5335,7 +5372,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
5335
5372
  serverSideRender: !0,
5336
5373
  writeToDisk: devConfig.writeToDisk
5337
5374
  });
5338
- }, external_node_querystring_namespaceObject = require("node:querystring"), styles = {
5375
+ }, styles = {
5339
5376
  1: 'font-weight:bold',
5340
5377
  2: 'opacity:0.5',
5341
5378
  3: 'font-style:italic',
@@ -5388,7 +5425,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
5388
5425
  rslog_index_js_namespaceObject.logger.error(err);
5389
5426
  }), this.heartbeatTimer = setTimeout(this.checkSockets, 30000).unref(), this.wsServer.on('connection', (socket, req)=>{
5390
5427
  let queryStr = req.url ? req.url.split('?')[1] : '';
5391
- this.onConnect(socket, queryStr ? (0, external_node_querystring_namespaceObject.parse)(queryStr) : {});
5428
+ this.onConnect(socket, queryStr ? Object.fromEntries(new URLSearchParams(queryStr)) : {});
5392
5429
  });
5393
5430
  }
5394
5431
  updateStats(stats) {
@@ -5974,7 +6011,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
5974
6011
  }
5975
6012
  if (server.compress && middlewares.push(gzipMiddleware()), 'dev' === context.action && 'rspack' === context.bundlerType && dev.lazyCompilation && compilationManager) {
5976
6013
  let { compiler } = compilationManager;
5977
- 'object' == typeof dev.lazyCompilation && 'string' == typeof dev.lazyCompilation.serverUrl && context.devServer && (dev.lazyCompilation.serverUrl = replacePortPlaceholder(dev.lazyCompilation.serverUrl, context.devServer.port)), middlewares.push(core_default().experiments.lazyCompilationMiddleware(helpers_isMultiCompiler(compiler) ? compiler.compilers[0] : compiler, dev.lazyCompilation));
6014
+ 'object' == typeof dev.lazyCompilation && 'string' == typeof dev.lazyCompilation.serverUrl && context.devServer && (dev.lazyCompilation.serverUrl = replacePortPlaceholder(dev.lazyCompilation.serverUrl, context.devServer.port)), middlewares.push(core_namespaceObject.rspack.experiments.lazyCompilationMiddleware(helpers_isMultiCompiler(compiler) ? compiler.compilers[0] : compiler, dev.lazyCompilation));
5978
6015
  }
5979
6016
  server.base && '/' !== server.base && middlewares.push(getBaseMiddleware({
5980
6017
  base: server.base
@@ -6028,16 +6065,15 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
6028
6065
  onUpgrade,
6029
6066
  middlewares
6030
6067
  };
6031
- }, external_node_vm_namespaceObject = require("node:vm");
6032
- var external_node_vm_default = __webpack_require__.n(external_node_vm_namespaceObject);
6033
- let asModule = async (something, context, unlinked)=>{
6034
- if (something instanceof external_node_vm_default().Module) return something;
6068
+ }, asModule = async (something, context, unlinked)=>{
6069
+ let { Module, SyntheticModule } = await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "node:vm"));
6070
+ if (something instanceof Module) return something;
6035
6071
  let exports1 = [
6036
6072
  ...new Set([
6037
6073
  'default',
6038
6074
  ...Object.keys(something)
6039
6075
  ])
6040
- ], m = new (external_node_vm_default()).SyntheticModule(exports1, ()=>{
6076
+ ], m = new SyntheticModule(exports1, ()=>{
6041
6077
  for (let name of exports1)m.setExport(name, 'default' === name ? something : something[name]);
6042
6078
  }, {
6043
6079
  context
@@ -6090,7 +6126,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
6090
6126
  postExecute(_m, _file) {}
6091
6127
  createRunner() {
6092
6128
  this.requirers.set('entry', (_currentDirectory, _modulePath, _context = {})=>{
6093
- throw Error('[rsbuild:runner] Not implement');
6129
+ throw Error(`${index_js_default().dim('[rsbuild:runner]')} Not implemented`);
6094
6130
  });
6095
6131
  }
6096
6132
  constructor(_options){
@@ -6148,7 +6184,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
6148
6184
  };
6149
6185
  }
6150
6186
  createCjsRequirer() {
6151
- let requireCache = Object.create(null);
6187
+ let requireCache = Object.create(null), vm = cjs_require('node:vm');
6152
6188
  return (currentDirectory, modulePath, context = {})=>{
6153
6189
  let file = context.file || this.getFile(modulePath, currentDirectory);
6154
6190
  if (!file) return this.requirers.get('miss')(currentDirectory, modulePath);
@@ -6162,7 +6198,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
6162
6198
  })`;
6163
6199
  this.preExecute(code, file);
6164
6200
  let dynamicImport = Function('specifier', 'return import(specifier)');
6165
- return external_node_vm_default().runInThisContext(code, {
6201
+ return vm.runInThisContext(code, {
6166
6202
  filename: file.path,
6167
6203
  importModuleDynamically: async (specifier)=>await dynamicImport(specifier)
6168
6204
  }).call(m.exports, ...argValues), this.postExecute(m, file), m.exports;
@@ -6172,6 +6208,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
6172
6208
  var type_EsmMode = function(EsmMode) {
6173
6209
  return EsmMode[EsmMode.Unknown = 0] = "Unknown", EsmMode[EsmMode.Evaluated = 1] = "Evaluated", EsmMode[EsmMode.Unlinked = 2] = "Unlinked", EsmMode;
6174
6210
  }({});
6211
+ let esm_require = (0, external_node_module_namespaceObject.createRequire)(__rslib_import_meta_url__);
6175
6212
  class EsmRunner extends CommonJsRunner {
6176
6213
  createRunner() {
6177
6214
  var _this__options_compilerOptions_experiments;
@@ -6189,13 +6226,13 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
6189
6226
  });
6190
6227
  }
6191
6228
  createEsmRequirer() {
6192
- let esmCache = new Map(), esmIdentifier = this._options.name;
6229
+ let esmCache = new Map(), esmIdentifier = this._options.name, vm = esm_require('node:vm');
6193
6230
  return (currentDirectory, modulePath, context = {})=>{
6194
- if (!external_node_vm_default().SourceTextModule) throw Error('[rsbuild:runner] Running ESM bundle needs add Node.js option "--experimental-vm-modules".');
6231
+ if (!vm.SourceTextModule) throw Error(`${index_js_default().dim('[rsbuild:runner]')} Running ESM bundle needs add Node.js option ${index_js_default().yellow('--experimental-vm-modules')}.`);
6195
6232
  let _require = this.getRequire(), file = context.file || this.getFile(modulePath, currentDirectory);
6196
6233
  if (!file) return this.requirers.get('miss')(currentDirectory, modulePath);
6197
6234
  let esm = esmCache.get(file.path);
6198
- return (esm || (esm = new (external_node_vm_default()).SourceTextModule(file.content, {
6235
+ return (esm || (esm = new vm.SourceTextModule(file.content, {
6199
6236
  identifier: `${esmIdentifier}-${file.path}`,
6200
6237
  url: `${(0, external_node_url_namespaceObject.pathToFileURL)(file.path).href}?${esmIdentifier}`,
6201
6238
  initializeImportMeta: (meta, _)=>{
@@ -6226,7 +6263,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
6226
6263
  name: this.name,
6227
6264
  ...options
6228
6265
  }, { compilerOptions } = options;
6229
- if ('web' === compilerOptions.target || 'webworker' === compilerOptions.target) throw Error(`[rsbuild:runner] Not support run "${compilerOptions.target}" resource in Rsbuild server`);
6266
+ if ('web' === compilerOptions.target || 'webworker' === compilerOptions.target) throw Error(`${index_js_default().dim('[rsbuild:runner]')} Not support run ${index_js_default().yellow(compilerOptions.target)} resource in Rsbuild server`);
6230
6267
  return new EsmRunner(runnerOptions);
6231
6268
  }
6232
6269
  constructor(name){
@@ -6247,7 +6284,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
6247
6284
  entrypoints: !0,
6248
6285
  outputPath: !0
6249
6286
  });
6250
- if (!(null == entrypoints ? void 0 : entrypoints[entryName])) throw Error(`[rsbuild:loadBundle] Can't find entry: "${entryName}"`);
6287
+ if (!(null == entrypoints ? void 0 : entrypoints[entryName])) throw Error(`${index_js_default().dim('[rsbuild:loadBundle]')} Can't find entry: ${index_js_default().yellow(entryName)}`);
6251
6288
  let { chunks: entryChunks = [] } = entrypoints[entryName], files = entryChunks.reduce((prev, entryChunkName)=>{
6252
6289
  let chunk = null == chunks ? void 0 : chunks.find((chunk)=>{
6253
6290
  var _chunk_names;
@@ -6255,8 +6292,8 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
6255
6292
  });
6256
6293
  return (null == chunk ? void 0 : chunk.files) ? prev.concat(chunk.files.filter((file)=>!file.endsWith('.css'))) : prev;
6257
6294
  }, []);
6258
- if (0 === files.length) throw Error(`[rsbuild:loadBundle] Failed to get bundle by entryName: "${entryName}"`);
6259
- if (files.length > 1) throw Error(`[rsbuild:loadBundle] Only support load single entry chunk, but got ${files.length}: ${files.join(',')}`);
6295
+ if (0 === files.length) throw Error(`${index_js_default().dim('[rsbuild:loadBundle]')} Failed to get bundle by entryName: ${index_js_default().yellow(entryName)}`);
6296
+ if (files.length > 1) throw Error(`${index_js_default().dim('[rsbuild:loadBundle]')} Only support load single entry chunk, but got ${index_js_default().yellow(files.length)}: ${files.join(',')}`);
6260
6297
  let allChunkFiles = (null == chunks ? void 0 : chunks.flatMap((c)=>c.files).map((file)=>(0, external_node_path_namespaceObject.join)(outputPath, file))) || [];
6261
6298
  return await runner_run({
6262
6299
  bundlePath: files[0],
@@ -6267,7 +6304,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
6267
6304
  });
6268
6305
  }, getTransformedHtml = async (entryName, utils)=>{
6269
6306
  let { htmlPaths, distPath } = utils.environment, htmlPath = htmlPaths[entryName];
6270
- if (!htmlPath) throw Error(`[rsbuild:getTransformedHtml] Failed to get HTML file by entryName: "${entryName}"`);
6307
+ if (!htmlPath) throw Error(`${index_js_default().dim('[rsbuild:getTransformedHtml]')} Failed to get HTML file by entryName: ${index_js_default().yellow(entryName)}`);
6271
6308
  let fileName = (0, external_node_path_namespaceObject.join)(distPath, htmlPath);
6272
6309
  return utils.readFileSync(fileName);
6273
6310
  }, createCacheableFunction = (getter)=>{
@@ -6340,7 +6377,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
6340
6377
  });
6341
6378
  }) : Promise.resolve(), startCompile = async ()=>{
6342
6379
  let compiler = customCompiler || await createCompiler();
6343
- if (!compiler) throw Error('[rsbuild:server] Failed to get compiler instance.');
6380
+ if (!compiler) throw Error(`${index_js_default().dim('[rsbuild:server]')} Failed to get compiler instance.`);
6344
6381
  let publicPaths = helpers_isMultiCompiler(compiler) ? compiler.compilers.map(getPublicPathFromCompiler) : [
6345
6382
  getPublicPathFromCompiler(compiler)
6346
6383
  ], compilationManager = new CompilationManager({
@@ -6354,7 +6391,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
6354
6391
  environments: context.environments
6355
6392
  });
6356
6393
  return await compilationManager.init(), compilationManager;
6357
- }, protocol = https ? 'https' : 'http', urls = getAddressUrls({
6394
+ }, protocol = https ? 'https' : 'http', urls = await getAddressUrls({
6358
6395
  protocol,
6359
6396
  port,
6360
6397
  host
@@ -6378,9 +6415,9 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
6378
6415
  ]);
6379
6416
  };
6380
6417
  middlewareMode || registerCleanup(closeServer);
6381
- let beforeCreateCompiler = ()=>{
6418
+ let beforeCreateCompiler = async ()=>{
6382
6419
  if (printUrls(), cliShortcutsEnabled) {
6383
- let shortcutsOptions = 'boolean' == typeof devConfig.cliShortcuts ? {} : devConfig.cliShortcuts, cleanup = setupCliShortcuts({
6420
+ let shortcutsOptions = 'boolean' == typeof devConfig.cliShortcuts ? {} : devConfig.cliShortcuts, cleanup = await setupCliShortcuts({
6384
6421
  openPage,
6385
6422
  closeServer,
6386
6423
  printUrls,
@@ -6397,18 +6434,18 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
6397
6434
  name,
6398
6435
  {
6399
6436
  getStats: async ()=>{
6400
- if (!compilationManager) throw Error('[rsbuild:server] Can not call `getStats` when `runCompile` is false');
6437
+ if (!compilationManager) throw Error(`${index_js_default().dim('[rsbuild:server]')} Can not call ${index_js_default().yellow('getStats')} when ${index_js_default().yellow('runCompile')} is false`);
6401
6438
  return await waitFirstCompileDone, lastStats[environment.index];
6402
6439
  },
6403
6440
  loadBundle: async (entryName)=>{
6404
- if (!compilationManager) throw Error('[rsbuild:server] Can not call `loadBundle` when `runCompile` is false');
6441
+ if (!compilationManager) throw Error(`${index_js_default().dim('[rsbuild:server]')} Can not call ${index_js_default().yellow('loadBundle')} when ${index_js_default().yellow('runCompile')} is false`);
6405
6442
  return await waitFirstCompileDone, cacheableLoadBundle(lastStats[environment.index], entryName, {
6406
6443
  readFileSync: compilationManager.readFileSync,
6407
6444
  environment
6408
6445
  });
6409
6446
  },
6410
6447
  getTransformedHtml: async (entryName)=>{
6411
- if (!compilationManager) throw Error('[rsbuild:server] Can not call `getTransformedHtml` when `runCompile` is false');
6448
+ if (!compilationManager) throw Error(`${index_js_default().dim('[rsbuild:server]')} Can not call ${index_js_default().yellow('getTransformedHtml')} when ${index_js_default().yellow('runCompile')} is false`);
6412
6449
  return await waitFirstCompileDone, cacheableTransformedHtml(lastStats[environment.index], entryName, {
6413
6450
  readFileSync: compilationManager.readFileSync,
6414
6451
  environment
@@ -6428,7 +6465,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
6428
6465
  data
6429
6466
  }),
6430
6467
  listen: async ()=>{
6431
- if (!httpServer) throw Error('[rsbuild:server] Can not listen dev server as `server.middlewareMode` is enabled.');
6468
+ if (!httpServer) throw Error(`${index_js_default().dim('[rsbuild:server]')} Can not listen dev server as ${index_js_default().yellow('server.middlewareMode')} is enabled.`);
6432
6469
  let serverTerminator = getServerTerminator(httpServer);
6433
6470
  return rslog_index_js_namespaceObject.logger.debug('listen dev server'), context.hooks.onCloseDevServer.tap(serverTerminator), new Promise((resolve)=>{
6434
6471
  httpServer.listen({
@@ -6463,7 +6500,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
6463
6500
  server: devServerAPI,
6464
6501
  environments: context.environments
6465
6502
  })).filter((item)=>'function' == typeof item);
6466
- runCompile ? context.hooks.onBeforeCreateCompiler.tap(beforeCreateCompiler) : beforeCreateCompiler();
6503
+ runCompile ? context.hooks.onBeforeCreateCompiler.tap(beforeCreateCompiler) : await beforeCreateCompiler();
6467
6504
  let compilationManager = runCompile ? await startCompile() : void 0;
6468
6505
  for (let item of (fileWatcher = await setupWatchFiles({
6469
6506
  dev: devConfig,
@@ -6503,7 +6540,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
6503
6540
  if (await context.hooks.onBeforeCreateCompiler.callBatch({
6504
6541
  bundlerConfigs: rspackConfigs,
6505
6542
  environments: context.environments
6506
- }), !await isSatisfyRspackVersion(core_namespaceObject.rspack.rspackVersion)) throw Error(`[rsbuild] The current Rspack version does not meet the requirements, the minimum supported version of Rspack is ${index_js_default().green(rspackMinVersion)}`);
6543
+ }), !await isSatisfyRspackVersion(core_namespaceObject.rspack.rspackVersion)) throw Error(`${index_js_default().dim('[rsbuild]')} The current Rspack version does not meet the requirements, the minimum supported version of Rspack is ${index_js_default().green(rspackMinVersion)}`);
6507
6544
  let isMultiCompiler = rspackConfigs.length > 1, compiler = isMultiCompiler ? (0, core_namespaceObject.rspack)(rspackConfigs) : (0, core_namespaceObject.rspack)(rspackConfigs[0]), isVersionLogged = !1, isCompiling = !1, logRspackVersion = ()=>{
6508
6545
  isVersionLogged || (rslog_index_js_namespaceObject.logger.debug(`use Rspack v${core_namespaceObject.rspack.rspackVersion}`), isVersionLogged = !0);
6509
6546
  };
@@ -6740,7 +6777,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
6740
6777
  routes,
6741
6778
  environments: context.environments
6742
6779
  });
6743
- let protocol = https ? 'https' : 'http', urls = getAddressUrls({
6780
+ let protocol = https ? 'https' : 'http', urls = await getAddressUrls({
6744
6781
  protocol,
6745
6782
  port,
6746
6783
  host
@@ -6767,7 +6804,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
6767
6804
  });
6768
6805
  if (printUrls(), cliShortcutsEnabled) {
6769
6806
  let shortcutsOptions = 'boolean' == typeof config.dev.cliShortcuts ? {} : config.dev.cliShortcuts;
6770
- setupCliShortcuts({
6807
+ await setupCliShortcuts({
6771
6808
  openPage,
6772
6809
  closeServer,
6773
6810
  printUrls,
@@ -6920,7 +6957,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
6920
6957
  for (let newPlugin of newPlugins)if (newPlugin) {
6921
6958
  var plugin = newPlugin;
6922
6959
  let type = typeof plugin;
6923
- if ('object' !== type || null === plugin) throw Error(`[rsbuild:plugin] Expect Rsbuild plugin instance to be an object, but got ${type}.`);
6960
+ if ('object' !== type || null === plugin) throw Error(`${index_js_default().dim('[rsbuild:plugin]')} Expect Rsbuild plugin instance to be an object, but got ${index_js_default().yellow(type)}.`);
6924
6961
  if (!isFunction(plugin.setup)) {
6925
6962
  if (isFunction(plugin.apply)) {
6926
6963
  let { name = 'SomeWebpackPlugin' } = plugin.constructor || {};
@@ -6938,7 +6975,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
6938
6975
  `)
6939
6976
  ].join('\n'));
6940
6977
  }
6941
- throw Error(`[rsbuild:plugin] Expect the setup function of Rsbuild plugin to be a function, but got ${type}.`);
6978
+ throw Error(`${index_js_default().dim('[rsbuild:plugin]')} Expect the setup function of Rsbuild plugin to be a function, but got ${index_js_default().yellow(type)}.`);
6942
6979
  }
6943
6980
  if (before) {
6944
6981
  let index = plugins.findIndex((item)=>item.instance.name === before);
@@ -6984,12 +7021,12 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
6984
7021
  if (context.normalizedConfig) {
6985
7022
  if (null == options ? void 0 : options.environment) {
6986
7023
  let config = context.normalizedConfig.environments[options.environment];
6987
- if (!config) throw Error(`[rsbuild] Cannot find normalized config by environment: ${options.environment}.`);
7024
+ if (!config) throw Error(`${index_js_default().dim('[rsbuild]')} Cannot find normalized config by environment: ${options.environment}.`);
6988
7025
  return config;
6989
7026
  }
6990
7027
  return context.normalizedConfig;
6991
7028
  }
6992
- throw Error('[rsbuild] Cannot access normalized config until modifyRsbuildConfig is called.');
7029
+ throw Error(`${index_js_default().dim('[rsbuild]')} Cannot access normalized config until ${index_js_default().yellow('modifyRsbuildConfig')} is called.`);
6993
7030
  }
6994
7031
  let getRsbuildConfig = (type = 'current')=>{
6995
7032
  switch(type){
@@ -7000,7 +7037,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
7000
7037
  case 'normalized':
7001
7038
  return getNormalizedConfig();
7002
7039
  }
7003
- throw Error('[rsbuild] `getRsbuildConfig` get an invalid type param.');
7040
+ throw Error(`${index_js_default().dim('[rsbuild]')} ${index_js_default().yellow('getRsbuildConfig')} get an invalid type param.`);
7004
7041
  }, exposed = [], expose = (id, api)=>{
7005
7042
  exposed.push({
7006
7043
  id,
@@ -7172,11 +7209,11 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
7172
7209
  pluginManager
7173
7210
  }), { distPath } = context, { checkDistDir = !0 } = options;
7174
7211
  if (checkDistDir) {
7175
- if (!(0, external_node_fs_namespaceObject.existsSync)(distPath)) throw Error(`[rsbuild:preview] The output directory ${index_js_default().yellow(distPath)} does not exist, please build the project before previewing.`);
7212
+ if (!(0, external_node_fs_namespaceObject.existsSync)(distPath)) throw Error(`${index_js_default().dim('[rsbuild:preview]')} The output directory ${index_js_default().yellow(distPath)} does not exist, please build the project before previewing.`);
7176
7213
  if (function(path) {
7177
7214
  let files = external_node_fs_default().readdirSync(path);
7178
7215
  return 0 === files.length || 1 === files.length && '.git' === files[0];
7179
- }(distPath)) throw Error(`[rsbuild:preview] The output directory ${index_js_default().yellow(distPath)} is empty, please build the project before previewing.`);
7216
+ }(distPath)) throw Error(`${index_js_default().dim('[rsbuild:preview]')} The output directory ${index_js_default().yellow(distPath)} is empty, please build the project before previewing.`);
7180
7217
  }
7181
7218
  return startProdServer(context, config, options);
7182
7219
  }, build = async (...args)=>{
@@ -7566,11 +7603,11 @@ ${section.body}` : section.body).join("\n\n"));
7566
7603
  }
7567
7604
  process.title = 'rsbuild-node';
7568
7605
  let { npm_execpath } = process.env;
7569
- (!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) && console.log(), rslog_index_js_namespaceObject.logger.greet(` Rsbuild v1.3.21\n`);
7606
+ (!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) && console.log(), rslog_index_js_namespaceObject.logger.greet(` Rsbuild v1.3.22\n`);
7570
7607
  try {
7571
7608
  !function() {
7572
7609
  let cli = cac_dist('rsbuild');
7573
- cli.help(), cli.version("1.3.21"), applyCommonOptions(cli);
7610
+ cli.help(), cli.version("1.3.22"), applyCommonOptions(cli);
7574
7611
  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');
7575
7612
  applyServerOptions(devCommand), applyServerOptions(previewCommand), devCommand.action(async (options)=>{
7576
7613
  try {
@@ -7621,7 +7658,7 @@ ${section.body}` : section.body).join("\n\n"));
7621
7658
  rslog_index_js_namespaceObject.logger.error('Failed to start Rsbuild CLI.'), rslog_index_js_namespaceObject.logger.error(err);
7622
7659
  }
7623
7660
  }
7624
- let src_version = "1.3.21";
7661
+ let src_version = "1.3.22";
7625
7662
  })(), exports.PLUGIN_CSS_NAME = __webpack_exports__.PLUGIN_CSS_NAME, exports.PLUGIN_SWC_NAME = __webpack_exports__.PLUGIN_SWC_NAME, exports.createRsbuild = __webpack_exports__.createRsbuild, exports.defaultAllowedOrigins = __webpack_exports__.defaultAllowedOrigins, exports.defineConfig = __webpack_exports__.defineConfig, exports.ensureAssetPrefix = __webpack_exports__.ensureAssetPrefix, exports.loadConfig = __webpack_exports__.loadConfig, exports.loadEnv = __webpack_exports__.loadEnv, exports.logger = __webpack_exports__.logger, exports.mergeRsbuildConfig = __webpack_exports__.mergeRsbuildConfig, exports.rspack = __webpack_exports__.rspack, exports.runCLI = __webpack_exports__.runCLI, exports.version = __webpack_exports__.version, __webpack_exports__)-1 === [
7626
7663
  "PLUGIN_CSS_NAME",
7627
7664
  "PLUGIN_SWC_NAME",