@rsbuild/core 1.3.20 → 1.3.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.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 = {};
@@ -1053,24 +1089,22 @@ for(var __webpack_i__ in (()=>{
1053
1089
  getChainUtils: ()=>getChainUtils,
1054
1090
  getConfigUtils: ()=>getConfigUtils,
1055
1091
  getHTMLPlugin: ()=>getHTMLPlugin,
1056
- getRsbuildInspectConfig: ()=>getRsbuildInspectConfig,
1057
1092
  getStatsOptions: ()=>getStatsOptions,
1058
1093
  initRsbuildConfig: ()=>initRsbuildConfig,
1094
+ inspectConfig: ()=>inspectConfig,
1059
1095
  modifyBundlerChain: ()=>modifyBundlerChain,
1060
- outputInspectConfigFiles: ()=>outputInspectConfigFiles,
1061
1096
  prettyTime: ()=>prettyTime,
1062
1097
  registerBuildHook: ()=>registerBuildHook,
1063
1098
  registerDevHook: ()=>registerDevHook,
1064
1099
  setCssExtractPlugin: ()=>setCssExtractPlugin,
1065
- setHTMLPlugin: ()=>setHTMLPlugin,
1066
- stringifyConfig: ()=>stringifyConfig
1100
+ setHTMLPlugin: ()=>setHTMLPlugin
1067
1101
  });
1068
- let core_namespaceObject = require("@rspack/core");
1069
- var core_default = __webpack_require__.n(core_namespaceObject);
1070
- let external_node_fs_namespaceObject = require("node:fs");
1102
+ let core_namespaceObject = require("@rspack/core"), external_node_fs_namespaceObject = require("node:fs");
1071
1103
  var external_node_fs_default = __webpack_require__.n(external_node_fs_namespaceObject);
1072
1104
  let external_node_path_namespaceObject = require("node:path");
1073
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");
1106
+ let external_node_crypto_namespaceObject = require("node:crypto");
1107
+ var external_node_crypto_default = __webpack_require__.n(external_node_crypto_namespaceObject);
1074
1108
  let external_node_url_namespaceObject = require("node:url");
1075
1109
  var cjs = __webpack_require__("../../node_modules/.pnpm/deepmerge@4.3.1/node_modules/deepmerge/dist/cjs.js"), cjs_default = __webpack_require__.n(cjs);
1076
1110
  let index_js_namespaceObject = require("../compiled/picocolors/index.js");
@@ -1130,9 +1164,6 @@ for(var __webpack_i__ in (()=>{
1130
1164
  '*'
1131
1165
  ].some((key)=>values.includes(key));
1132
1166
  };
1133
- function getAbsolutePath(base, filepath) {
1134
- return (0, external_node_path_namespaceObject.isAbsolute)(filepath) ? filepath : (0, external_node_path_namespaceObject.join)(base, filepath);
1135
- }
1136
1167
  isDebug() && (rslog_index_js_namespaceObject.logger.level = 'verbose'), rslog_index_js_namespaceObject.logger.override({
1137
1168
  debug: (message, ...args)=>{
1138
1169
  if ('verbose' !== rslog_index_js_namespaceObject.logger.level) return;
@@ -1143,7 +1174,7 @@ for(var __webpack_i__ in (()=>{
1143
1174
  console.log(` ${index_js_default().magenta('rsbuild')} ${time} ${message}`, ...args);
1144
1175
  }
1145
1176
  });
1146
- let getCompiledPath = (packageName)=>(0, external_node_path_namespaceObject.join)(COMPILED_PATH, packageName, 'index.js'), ensureAbsolutePath = (base, filePath)=>(0, external_node_path_namespaceObject.isAbsolute)(filePath) ? filePath : (0, external_node_path_namespaceObject.resolve)(base, filePath), pathnameParse = (publicPath)=>{
1177
+ let getCompiledPath = (packageName)=>(0, external_node_path_namespaceObject.join)(COMPILED_PATH, packageName, 'index.js'), ensureAbsolutePath = (base, filePath)=>(0, external_node_path_namespaceObject.isAbsolute)(filePath) ? filePath : (0, external_node_path_namespaceObject.join)(base, filePath), getPathnameFromUrl = (publicPath)=>{
1147
1178
  try {
1148
1179
  return publicPath ? new URL(publicPath).pathname : publicPath;
1149
1180
  } catch (err) {
@@ -1361,7 +1392,7 @@ for(var __webpack_i__ in (()=>{
1361
1392
  }
1362
1393
  return {};
1363
1394
  }
1364
- let rspackMinVersion = '1.0.0', getNodeEnv = ()=>process.env.NODE_ENV, setNodeEnv = (env)=>{
1395
+ let rspackMinVersion = '1.2.4', getNodeEnv = ()=>process.env.NODE_ENV, setNodeEnv = (env)=>{
1365
1396
  process.env.NODE_ENV = env;
1366
1397
  }, isFunction = (func)=>'function' == typeof func, isObject = (obj)=>'[object Object]' === Object.prototype.toString.call(obj), isPlainObject = (obj)=>null !== obj && 'object' == typeof obj && Object.getPrototypeOf(obj) === Object.prototype, castArray = (arr)=>void 0 === arr ? [] : Array.isArray(arr) ? arr : [
1367
1398
  arr
@@ -1412,7 +1443,7 @@ for(var __webpack_i__ in (()=>{
1412
1443
  case 'assets':
1413
1444
  return filename.assets ?? `[name]${hash}[ext]`;
1414
1445
  default:
1415
- 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')}`);
1416
1447
  }
1417
1448
  }
1418
1449
  let applyToCompiler = (compiler, apply)=>{
@@ -1436,7 +1467,7 @@ for(var __webpack_i__ in (()=>{
1436
1467
  function loadEnv({ cwd = process.cwd(), mode = getNodeEnv(), prefixes = [
1437
1468
  'PUBLIC_'
1438
1469
  ], processEnv = process.env } = {}) {
1439
- 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.`);
1440
1471
  let filePaths = [
1441
1472
  '.env',
1442
1473
  '.env.local',
@@ -1535,9 +1566,7 @@ for(var __webpack_i__ in (()=>{
1535
1566
  if (void 0 !== result) return result;
1536
1567
  }while (loc !== (loc = external_node_path_namespaceObject.dirname(loc)));
1537
1568
  }
1538
- let configCache = {}, external_node_module_namespaceObject = require("node:module"), rspack_chain_index_js_namespaceObject = require("../compiled/rspack-chain/index.js");
1539
- var rspack_chain_index_js_default = __webpack_require__.n(rspack_chain_index_js_namespaceObject);
1540
- let OVERRIDE_PATHS = [
1569
+ let configCache = {}, external_node_module_namespaceObject = require("node:module"), OVERRIDE_PATHS = [
1541
1570
  'performance.removeConsole',
1542
1571
  'output.inlineScripts',
1543
1572
  'output.inlineStyles',
@@ -1581,9 +1610,10 @@ for(var __webpack_i__ in (()=>{
1581
1610
  merged[key] = merge(x[key], y[key], childPath);
1582
1611
  }
1583
1612
  return merged;
1584
- }, 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 = ()=>({
1585
1614
  hmr: !0,
1586
1615
  liveReload: !0,
1616
+ watchFiles: [],
1587
1617
  assetPrefix: DEFAULT_ASSET_PREFIX,
1588
1618
  writeToDisk: !1,
1589
1619
  cliShortcuts: !1,
@@ -1608,7 +1638,6 @@ for(var __webpack_i__ in (()=>{
1608
1638
  },
1609
1639
  middlewareMode: !1
1610
1640
  }), getDefaultSourceConfig = ()=>({
1611
- alias: {},
1612
1641
  define: {},
1613
1642
  preEntry: [],
1614
1643
  decorators: {
@@ -1690,7 +1719,7 @@ for(var __webpack_i__ in (()=>{
1690
1719
  exportLocalsConvention: 'camelCase'
1691
1720
  },
1692
1721
  emitAssets: !0
1693
- }), 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'))), {
1694
1723
  alias: {
1695
1724
  '@swc/helpers': swcHelpersPath
1696
1725
  },
@@ -1722,154 +1751,19 @@ for(var __webpack_i__ in (()=>{
1722
1751
  await isFileExists(tsconfigPath) && (merged.source.tsconfigPath = tsconfigPath);
1723
1752
  }
1724
1753
  return merged;
1725
- }, normalizeConfig = (config)=>mergeRsbuildConfig({
1754
+ }, normalizeConfig = (config)=>{
1755
+ let mergedConfig = mergeRsbuildConfig({
1726
1756
  ...createDefaultConfig(),
1727
1757
  mode: (()=>{
1728
1758
  if (config.mode) return config.mode;
1729
1759
  let nodeEnv = getNodeEnv();
1730
1760
  return 'production' === nodeEnv || 'development' === nodeEnv ? nodeEnv : 'none';
1731
1761
  })()
1732
- }, config);
1733
- function defineConfig(config) {
1734
- return config;
1735
- }
1736
- let resolveConfigPath = (root, customConfig)=>{
1737
- if (customConfig) {
1738
- let customConfigPath = (0, external_node_path_namespaceObject.isAbsolute)(customConfig) ? customConfig : (0, external_node_path_namespaceObject.join)(root, customConfig);
1739
- if (external_node_fs_default().existsSync(customConfigPath)) return customConfigPath;
1740
- rslog_index_js_namespaceObject.logger.warn(`Cannot find config file: ${index_js_default().dim(customConfigPath)}\n`);
1741
- }
1742
- for (let file of [
1743
- 'rsbuild.config.mjs',
1744
- 'rsbuild.config.ts',
1745
- 'rsbuild.config.js',
1746
- 'rsbuild.config.cjs',
1747
- 'rsbuild.config.mts',
1748
- 'rsbuild.config.cts'
1749
- ]){
1750
- let configFile = (0, external_node_path_namespaceObject.join)(root, file);
1751
- if (external_node_fs_default().existsSync(configFile)) return configFile;
1752
- }
1753
- return null;
1754
- };
1755
- async function config_loadConfig({ cwd = process.cwd(), path, envMode, meta, loader = 'jiti' } = {}) {
1756
- let configExport, configFilePath = resolveConfigPath(cwd, path);
1757
- if (!configFilePath) return rslog_index_js_namespaceObject.logger.debug('no config file found.'), {
1758
- content: {},
1759
- filePath: configFilePath
1760
- };
1761
- let applyMetaInfo = (config)=>(config._privateMeta = {
1762
- configFilePath
1763
- }, config);
1764
- if ('native' === loader || /\.(?:js|mjs|cjs)$/.test(configFilePath)) try {
1765
- let configFileURL = (0, external_node_url_namespaceObject.pathToFileURL)(configFilePath).href, exportModule = await import(`${configFileURL}?t=${Date.now()}`);
1766
- configExport = exportModule.default ? exportModule.default : exportModule;
1767
- } catch (err) {
1768
- if ('native' === loader) throw rslog_index_js_namespaceObject.logger.error(`Failed to load file with native loader: ${index_js_default().dim(configFilePath)}`), err;
1769
- rslog_index_js_namespaceObject.logger.debug(`failed to load file with dynamic import: ${index_js_default().dim(configFilePath)}`);
1770
- }
1771
- try {
1772
- if (void 0 === configExport) {
1773
- let { createJiti } = await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "jiti")), jiti = createJiti(constants_filename, {
1774
- moduleCache: !1,
1775
- interopDefault: !0,
1776
- nativeModules: [
1777
- '@rspack/core',
1778
- "typescript"
1779
- ]
1780
- });
1781
- configExport = await jiti.import(configFilePath, {
1782
- default: !0
1783
- });
1784
- }
1785
- } catch (err) {
1786
- throw rslog_index_js_namespaceObject.logger.error(`Failed to load file with jiti: ${index_js_default().dim(configFilePath)}`), err;
1787
- }
1788
- if ('function' == typeof configExport) {
1789
- let command = process.argv[2], nodeEnv = getNodeEnv(), result = await configExport({
1790
- env: nodeEnv,
1791
- command,
1792
- envMode: envMode || nodeEnv,
1793
- meta
1794
- });
1795
- if (void 0 === result) throw Error('[rsbuild:loadConfig] The config function must return a config object.');
1796
- return {
1797
- content: applyMetaInfo(result),
1798
- filePath: configFilePath
1799
- };
1800
- }
1801
- 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)}`);
1802
- return rslog_index_js_namespaceObject.logger.debug('loaded config file:', configFilePath), {
1803
- content: applyMetaInfo(configExport),
1804
- filePath: configFilePath
1805
- };
1806
- }
1807
- let normalizePluginObject = (plugin)=>{
1808
- let { setup: _, ...rest } = plugin;
1809
- return {
1810
- ...rest,
1811
- setup () {}
1812
- };
1813
- }, getRsbuildInspectConfig = ({ normalizedConfig, inspectOptions, pluginManager })=>{
1814
- let { environments, ...rsbuildConfig } = normalizedConfig, rawRsbuildConfig = stringifyConfig({
1815
- ...rsbuildConfig,
1816
- plugins: pluginManager.getPlugins().map(normalizePluginObject)
1817
- }, inspectOptions.verbose), environmentConfigs = {}, rawEnvironmentConfigs = [];
1818
- for (let [name, config] of Object.entries(environments)){
1819
- let debugConfig = {
1820
- ...config,
1821
- plugins: pluginManager.getPlugins({
1822
- environment: name
1823
- }).map(normalizePluginObject)
1824
- };
1825
- rawEnvironmentConfigs.push({
1826
- name,
1827
- content: stringifyConfig(debugConfig, inspectOptions.verbose)
1828
- }), environmentConfigs[name] = debugConfig;
1829
- }
1830
- return {
1831
- rsbuildConfig,
1832
- rawRsbuildConfig,
1833
- environmentConfigs: environments,
1834
- rawEnvironmentConfigs
1835
- };
1836
- };
1837
- async function outputInspectConfigFiles({ rawBundlerConfigs, rawEnvironmentConfigs, inspectOptions, configType }) {
1838
- let { outputPath } = inspectOptions, files = [
1839
- ...rawEnvironmentConfigs.map(({ name, content })=>{
1840
- if (1 === rawEnvironmentConfigs.length) return {
1841
- path: (0, external_node_path_namespaceObject.join)(outputPath, 'rsbuild.config.mjs'),
1842
- label: 'Rsbuild config',
1843
- content
1844
- };
1845
- let outputFile = `rsbuild.config.${name}.mjs`;
1846
- return {
1847
- path: (0, external_node_path_namespaceObject.join)(outputPath, outputFile),
1848
- label: `Rsbuild config (${name})`,
1849
- content
1850
- };
1851
- }),
1852
- ...rawBundlerConfigs.map(({ name, content })=>{
1853
- let outputFile = `${configType}.config.${name}.mjs`, outputFilePath = (0, external_node_path_namespaceObject.join)(outputPath, outputFile);
1854
- return external_node_fs_default().existsSync(outputFilePath) && (outputFilePath = outputFilePath.replace(/\.mjs$/, `.${Date.now()}.mjs`)), {
1855
- path: outputFilePath,
1856
- label: `${upperFirst(configType)} Config (${name})`,
1857
- content
1858
- };
1859
- })
1860
- ];
1861
- await external_node_fs_default().promises.mkdir(outputPath, {
1862
- recursive: !0
1863
- }), await Promise.all(files.map(async (item)=>external_node_fs_default().promises.writeFile(item.path, `export default ${item.content}`)));
1864
- let fileInfos = files.map((item)=>` - ${index_js_default().bold(index_js_default().yellow(item.label))}: ${index_js_default().underline(item.path)}`).join('\n');
1865
- rslog_index_js_namespaceObject.logger.success(`config inspection completed, generated files: \n\n${fileInfos}\n`);
1866
- }
1867
- function stringifyConfig(config, verbose) {
1868
- return (0, rspack_chain_index_js_default().toString)(config, {
1869
- verbose
1870
- });
1871
- }
1872
- let normalizePublicDirs = (publicDir)=>{
1762
+ }, config), { watchFiles } = mergedConfig.dev;
1763
+ return Array.isArray(watchFiles) || (mergedConfig.dev.watchFiles = [
1764
+ watchFiles
1765
+ ]), mergedConfig;
1766
+ }, normalizePublicDirs = (publicDir)=>{
1873
1767
  if (!1 === publicDir) return [];
1874
1768
  let defaultConfig = {
1875
1769
  name: 'public',
@@ -1891,7 +1785,7 @@ for(var __webpack_i__ in (()=>{
1891
1785
  let allLines = [];
1892
1786
  function getPlugin(name) {
1893
1787
  let targets = plugins.filter((item)=>item.instance.name === name);
1894
- 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`);
1895
1789
  return targets;
1896
1790
  }
1897
1791
  for (let plugin of plugins){
@@ -1912,7 +1806,7 @@ for(var __webpack_i__ in (()=>{
1912
1806
  if (allLines.length) {
1913
1807
  let restInRingPoints = {};
1914
1808
  for (let l of allLines)restInRingPoints[l[0]] = !0, restInRingPoints[l[1]] = !0;
1915
- 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(','))}`);
1916
1810
  }
1917
1811
  return sortedPoint;
1918
1812
  };
@@ -2177,7 +2071,7 @@ for(var __webpack_i__ in (()=>{
2177
2071
  case 'report':
2178
2072
  return Compilation.PROCESS_ASSETS_STAGE_REPORT;
2179
2073
  default:
2180
- throw Error(`[rsbuild] Invalid process assets stage: ${stage}`);
2074
+ throw Error(`${index_js_default().dim('[rsbuild]')} Invalid process assets stage: ${stage}`);
2181
2075
  }
2182
2076
  }, browsersListCache = new Map();
2183
2077
  async function getBrowserslist(path) {
@@ -2232,17 +2126,17 @@ for(var __webpack_i__ in (()=>{
2232
2126
  let filename;
2233
2127
  filename = config.output.filename.html ? config.output.filename.html.replace('[name]', entryName) : 'flat' === config.html.outputStructure ? `${entryName}.html` : `${entryName}/index.html`;
2234
2128
  let prefix = config.output.distPath.html;
2235
- 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));
2236
2130
  }(key, config)), prev;
2237
2131
  }, {});
2238
2132
  async function updateEnvironmentContext(context, configs) {
2239
2133
  for (let [index, [name, config]] of (context.environments ||= {}, Object.entries(configs).entries())){
2240
- let tsconfigPath = config.source.tsconfigPath ? getAbsolutePath(context.rootPath, config.source.tsconfigPath) : void 0, browserslist = await getBrowserslistByEnvironment(context.rootPath, config), entry = config.source.entry ?? {}, htmlPaths = getEnvironmentHTMLPaths(entry, config), environmentContext = {
2134
+ let browserslist = await getBrowserslistByEnvironment(context.rootPath, config), { entry = {}, tsconfigPath } = config.source, htmlPaths = getEnvironmentHTMLPaths(entry, config), environmentContext = {
2241
2135
  index,
2242
2136
  name,
2243
2137
  distPath: function(cwd, config) {
2244
2138
  var _config_output_distPath, _config_output;
2245
- return getAbsolutePath(cwd, (null == (_config_output = config.output) || null == (_config_output_distPath = _config_output.distPath) ? void 0 : _config_output_distPath.root) ?? ROOT_DIST_DIR);
2139
+ return ensureAbsolutePath(cwd, (null == (_config_output = config.output) || null == (_config_output_distPath = _config_output.distPath) ? void 0 : _config_output_distPath.root) ?? ROOT_DIST_DIR);
2246
2140
  }(context.rootPath, config),
2247
2141
  entry,
2248
2142
  browserslist,
@@ -2257,9 +2151,9 @@ for(var __webpack_i__ in (()=>{
2257
2151
  }
2258
2152
  }
2259
2153
  async function createContext(options, userConfig) {
2260
- let { cwd } = options, rootPath = userConfig.root ? getAbsolutePath(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';
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';
2261
2155
  return {
2262
- version: "1.3.20",
2156
+ version: "1.3.22",
2263
2157
  rootPath,
2264
2158
  distPath: '',
2265
2159
  cachePath,
@@ -2333,21 +2227,21 @@ for(var __webpack_i__ in (()=>{
2333
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 = [];
2334
2228
  for (let icon of icons){
2335
2229
  if ('web-app-manifest' === icon.target && !appIcon.name) {
2336
- 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"')}.`);
2337
2231
  continue;
2338
2232
  }
2339
2233
  if (!icon.isURL) {
2340
2234
  if (!compilation.inputFileSystem) {
2341
- 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.`);
2342
2236
  continue;
2343
2237
  }
2344
2238
  if (!await fileExistsByCompilation(compilation, icon.absolutePath)) {
2345
- 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)}.`);
2346
2240
  continue;
2347
2241
  }
2348
2242
  let source = await (0, external_node_util_namespaceObject.promisify)(compilation.inputFileSystem.readFile)(icon.absolutePath);
2349
2243
  if (!source) {
2350
- 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)}.`);
2351
2245
  continue;
2352
2246
  }
2353
2247
  compilation.emitAsset(icon.relativePath, new sources.RawSource(source));
@@ -2396,7 +2290,8 @@ for(var __webpack_i__ in (()=>{
2396
2290
  };
2397
2291
  api.onCloseDevServer(clean), api.onCloseBuild(clean);
2398
2292
  }
2399
- });
2293
+ }), rspack_chain_index_js_namespaceObject = require("../compiled/rspack-chain/index.js");
2294
+ var rspack_chain_index_js_default = __webpack_require__.n(rspack_chain_index_js_namespaceObject);
2400
2295
  async function modifyBundlerChain(context, utils) {
2401
2296
  var _utils_environment_config_tools;
2402
2297
  rslog_index_js_namespaceObject.logger.debug('modify bundler chain');
@@ -2582,8 +2477,7 @@ for(var __webpack_i__ in (()=>{
2582
2477
  }), isUseAnalyzer = (config)=>{
2583
2478
  var _config_performance;
2584
2479
  return process.env.BUNDLE_ANALYZE || (null == (_config_performance = config.performance) ? void 0 : _config_performance.bundleAnalyze);
2585
- }, external_node_crypto_namespaceObject = require("node:crypto");
2586
- var external_node_crypto_default = __webpack_require__.n(external_node_crypto_namespaceObject);
2480
+ };
2587
2481
  async function validateWebpackCache(cacheDirectory, buildDependencies) {
2588
2482
  let configFile = (0, external_node_path_namespaceObject.join)(cacheDirectory, 'buildDependencies.json');
2589
2483
  if (await isFileExists(configFile)) {
@@ -2635,7 +2529,7 @@ for(var __webpack_i__ in (()=>{
2635
2529
  setup (api) {
2636
2530
  let cacheEnabled = !1;
2637
2531
  api.modifyBundlerChain(async (chain, { environment, env })=>{
2638
- var digest;
2532
+ var data;
2639
2533
  let { config } = environment, { bundlerType } = api.context, buildCache = config.performance.buildCache ?? 'webpack' === bundlerType;
2640
2534
  if (!1 === buildCache) return;
2641
2535
  cacheEnabled = !0;
@@ -2645,7 +2539,7 @@ for(var __webpack_i__ in (()=>{
2645
2539
  userBuildDependencies: cacheConfig.buildDependencies
2646
2540
  } : {});
2647
2541
  'webpack' === bundlerType && await validateWebpackCache(cacheDirectory, buildDependencies);
2648
- let cacheVersion = Array.isArray(cacheConfig.cacheDigest) && cacheConfig.cacheDigest.length ? `${environment.name}-${env}-${digest = cacheConfig.cacheDigest, external_node_crypto_default().createHash('md5').update(JSON.stringify(digest)).digest('hex').slice(0, 8)}` : `${environment.name}-${env}`;
2542
+ let cacheVersion = Array.isArray(cacheConfig.cacheDigest) && cacheConfig.cacheDigest.length ? `${environment.name}-${env}-${data = JSON.stringify(cacheConfig.cacheDigest), external_node_crypto_default().hash ? external_node_crypto_default().hash('sha256', data, 'hex').slice(0, 16) : external_node_crypto_default().createHash('sha256').update(data).digest('hex').slice(0, 16)}` : `${environment.name}-${env}`;
2649
2543
  'rspack' === bundlerType ? (chain.cache(!0), chain.experiments({
2650
2544
  ...chain.get('experiments'),
2651
2545
  cache: {
@@ -2754,7 +2648,7 @@ for(var __webpack_i__ in (()=>{
2754
2648
  plugin && (pluginHelper_htmlPlugin = plugin);
2755
2649
  }, getHTMLPlugin = ()=>(pluginHelper_htmlPlugin || (pluginHelper_htmlPlugin = pluginHelper_require('../compiled/html-rspack-plugin/index.js')), pluginHelper_htmlPlugin), setCssExtractPlugin = (plugin)=>{
2756
2650
  cssExtractPlugin = plugin;
2757
- }, getCssExtractPlugin = ()=>cssExtractPlugin || core_default().CssExtractRspackPlugin, getSwcMinimizerOptions = (config, jsOptions)=>{
2651
+ }, getCssExtractPlugin = ()=>cssExtractPlugin || core_namespaceObject.rspack.CssExtractRspackPlugin, getSwcMinimizerOptions = (config, jsOptions)=>{
2758
2652
  let options = {};
2759
2653
  options.minimizerOptions ||= {}, options.minimizerOptions.format ||= {};
2760
2654
  let { removeConsole } = config.performance;
@@ -2778,26 +2672,27 @@ for(var __webpack_i__ in (()=>{
2778
2672
  options.minimizerOptions.format.comments = !1, options.extractComments = !1;
2779
2673
  }
2780
2674
  return (options.minimizerOptions.format.asciiOnly = 'ascii' === config.output.charset, jsOptions) ? cjs_default()(options, jsOptions) : options;
2781
- }, parseMinifyOptions = (config, isProd)=>{
2782
- let { minify } = config.output;
2783
- return !1 !== minify && isProd ? !0 === minify ? {
2784
- minifyJs: !0,
2785
- minifyCss: !0
2786
- } : {
2787
- minifyJs: !1 !== minify.js,
2788
- 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),
2789
2687
  jsOptions: minify.jsOptions,
2790
2688
  cssOptions: minify.cssOptions
2791
- } : {
2792
- minifyJs: !1,
2793
- minifyCss: !1
2794
2689
  };
2795
2690
  }, pluginMinimize = ()=>({
2796
2691
  name: 'rsbuild:minimize',
2797
2692
  setup (api) {
2798
2693
  let isRspack = 'rspack' === api.context.bundlerType;
2799
- api.modifyBundlerChain(async (chain, { isProd, environment, CHAIN_ID })=>{
2800
- 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);
2801
2696
  if (chain.optimization.minimize(minifyJs || minifyCss), minifyJs && isRspack && chain.optimization.minimizer(CHAIN_ID.MINIMIZER.JS).use(core_namespaceObject.rspack.SwcJsMinimizerRspackPlugin, [
2802
2697
  getSwcMinimizerOptions(config, jsOptions)
2803
2698
  ]).end(), minifyCss && isRspack) {
@@ -2887,7 +2782,7 @@ for(var __webpack_i__ in (()=>{
2887
2782
  if ('function' == typeof postcssOptions) {
2888
2783
  let postcssOptionsWrapper = (loaderContext)=>{
2889
2784
  let options = postcssOptions(loaderContext);
2890
- 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)}.`);
2891
2786
  return updatePostcssOptions({
2892
2787
  ...userOptions,
2893
2788
  ...options,
@@ -2948,9 +2843,9 @@ for(var __webpack_i__ in (()=>{
2948
2843
  var _postcssLoaderOptions_postcssOptions_plugins, _postcssLoaderOptions_postcssOptions;
2949
2844
  if ('rspack' === api.context.bundlerType && !1 !== config.tools.lightningcssLoader) {
2950
2845
  importLoaders++;
2951
- let { minifyCss } = parseMinifyOptions(config, isProd);
2846
+ let { minifyCss } = parseMinifyOptions(config);
2952
2847
  updateRules((rule, type)=>{
2953
- 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);
2954
2849
  rule.use(CHAIN_ID.USE.LIGHTNINGCSS).loader('builtin:lightningcss-loader').options(lightningcssOptions);
2955
2850
  });
2956
2851
  }
@@ -3021,7 +2916,7 @@ for(var __webpack_i__ in (()=>{
3021
2916
  if (!value) return;
3022
2917
  let check = (value)=>{
3023
2918
  let pathKey = Object.keys(value).find((key)=>'path' === key.toLowerCase() && value[key] === process.env[key]);
3024
- 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.`);
3025
2920
  };
3026
2921
  if ('object' == typeof value) return check(value);
3027
2922
  if ('string' == typeof value) try {
@@ -3047,7 +2942,7 @@ for(var __webpack_i__ in (()=>{
3047
2942
  preEntry.forEach(addEntry), injectCoreJsEntry && addEntry(createVirtualModule('import "core-js";')), castArray(entry[entryName]).forEach(addEntry);
3048
2943
  }
3049
2944
  }), api.onBeforeCreateCompiler(({ bundlerConfigs })=>{
3050
- 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.`);
3051
2946
  });
3052
2947
  }
3053
2948
  }), external_node_zlib_namespaceObject = require("node:zlib");
@@ -3273,12 +3168,12 @@ for(var __webpack_i__ in (()=>{
3273
3168
  let emitFavicon = async (compilation, favicon)=>{
3274
3169
  let buffer, name = external_node_path_default().basename(favicon);
3275
3170
  if (compilation.assets[name]) return name;
3276
- 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;
3277
3172
  let filename = external_node_path_default().isAbsolute(favicon) ? favicon : external_node_path_default().join(compilation.compiler.context, favicon);
3278
3173
  try {
3279
3174
  if (!(buffer = await (0, external_node_util_namespaceObject.promisify)(compilation.inputFileSystem.readFile)(filename))) throw Error('Buffer is undefined');
3280
3175
  } catch (error) {
3281
- 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;
3282
3177
  }
3283
3178
  let source = new compiler.webpack.sources.RawSource(buffer, !1);
3284
3179
  return compilation.emitAsset(name, source), name;
@@ -3376,7 +3271,7 @@ for(var __webpack_i__ in (()=>{
3376
3271
  };
3377
3272
  let absolutePath = (0, external_node_path_namespaceObject.isAbsolute)(templatePath) ? templatePath : external_node_path_default().join(rootPath, templatePath);
3378
3273
  if (!existTemplatePath.has(absolutePath)) {
3379
- 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)}`);
3380
3275
  existTemplatePath.add(absolutePath);
3381
3276
  }
3382
3277
  let templateContent = await external_node_fs_default().promises.readFile(absolutePath, 'utf-8');
@@ -3672,7 +3567,7 @@ for(var __webpack_i__ in (()=>{
3672
3567
  manifestData
3673
3568
  });
3674
3569
  if (isObject(generatedManifest)) return environment.manifest = generatedManifest, generatedManifest;
3675
- 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.`);
3676
3571
  }
3677
3572
  return environment.manifest = manifestData, manifestData;
3678
3573
  }, pluginManifest = ()=>({
@@ -3705,7 +3600,7 @@ for(var __webpack_i__ in (()=>{
3705
3600
  }), api.onAfterCreateCompiler(()=>{
3706
3601
  if (manifestFilenames.size <= 1) return void manifestFilenames.clear();
3707
3602
  let environmentNames = Array.from(manifestFilenames.keys()), filenames = Array.from(manifestFilenames.values());
3708
- 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();
3709
3604
  });
3710
3605
  }
3711
3606
  });
@@ -3777,7 +3672,7 @@ for(var __webpack_i__ in (()=>{
3777
3672
  raw: !0
3778
3673
  }, ({ code, emitFile, resourcePath })=>{
3779
3674
  let name = nodeAddons_getFilename(resourcePath);
3780
- 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)}`);
3781
3676
  return emitFile(name, code), `
3782
3677
  try {
3783
3678
  const path = require("path");
@@ -3824,9 +3719,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
3824
3719
  }
3825
3720
  });
3826
3721
  }
3827
- }), external_node_child_process_namespaceObject = require("node:child_process"), external_node_net_namespaceObject = require("node:net");
3828
- var external_node_net_default = __webpack_require__.n(external_node_net_namespaceObject);
3829
- let normalizeUrl = (url)=>url.replace(/([^:]\/)\/+/g, '$1'), formatPrefix = (input)=>{
3722
+ }), normalizeUrl = (url)=>url.replace(/([^:]\/)\/+/g, '$1'), formatPrefix = (input)=>{
3830
3723
  let prefix = input;
3831
3724
  if ((null == prefix ? void 0 : prefix.startsWith('./')) && (prefix = prefix.replace('./', '')), !prefix) return '/';
3832
3725
  let hasLeadingSlash = prefix.startsWith('/'), hasTailSlash = prefix.endsWith('/');
@@ -3856,7 +3749,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
3856
3749
  protocol
3857
3750
  });
3858
3751
  if (!newUrls) return null;
3859
- 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}.`);
3860
3753
  urls = newUrls.map((url)=>({
3861
3754
  url,
3862
3755
  label: getUrlLabel(url)
@@ -3880,10 +3773,10 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
3880
3773
  }
3881
3774
  let getPort = async ({ host, port, strictPort, tryLimits = 20 })=>{
3882
3775
  'string' == typeof port && (port = Number.parseInt(port, 10)), strictPort && (tryLimits = 1);
3883
- 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;
3884
3777
  for(; !found && attempts <= tryLimits;)try {
3885
3778
  await new Promise((resolve, reject)=>{
3886
- let server = external_node_net_default().createServer();
3779
+ let server = createServer();
3887
3780
  server.unref(), server.on('error', reject), server.listen({
3888
3781
  port,
3889
3782
  host
@@ -3895,7 +3788,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
3895
3788
  if ('EADDRINUSE' !== e.code) throw e;
3896
3789
  port++, attempts++;
3897
3790
  }
3898
- 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.`);
3899
3792
  return port;
3900
3793
  }, getServerConfig = async ({ config })=>{
3901
3794
  let { host, port: originalPort, strictPort } = config.server, port = await getPort({
@@ -3925,24 +3818,31 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
3925
3818
  '127.0.0.1',
3926
3819
  '::1',
3927
3820
  '0000:0000:0000:0000:0000:0000:0000:0001'
3928
- ]).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)=>{
3929
3826
  try {
3930
3827
  let { host } = new URL(url);
3931
3828
  return isLoopbackHost(host) ? LOCAL_LABEL : NETWORK_LABEL;
3932
3829
  } catch (err) {
3933
3830
  return NETWORK_LABEL;
3934
3831
  }
3935
- }, getAddressUrls = ({ protocol = 'http', port, host })=>{
3936
- if (host && host !== DEFAULT_DEV_HOST) return [
3937
- {
3938
- label: isLoopbackHost(host) ? LOCAL_LABEL : NETWORK_LABEL,
3939
- url: concatUrl({
3940
- port,
3941
- host: getHostInUrl(host),
3942
- protocol
3943
- })
3944
- }
3945
- ];
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
+ }
3946
3846
  let ipv4Interfaces = getIpv4Interfaces(), addressUrls = [], hasLocalUrl = !1;
3947
3847
  for (let detail of ipv4Interfaces)if (isLoopbackHost(detail.address) || detail.internal) {
3948
3848
  if (hasLocalUrl) continue;
@@ -3980,7 +3880,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
3980
3880
  listened ? server.close((err)=>err ? reject(err) : resolve()) : resolve();
3981
3881
  });
3982
3882
  }
3983
- let execAsync = (0, external_node_util_namespaceObject.promisify)(external_node_child_process_namespaceObject.exec), supportedChromiumBrowsers = [
3883
+ let supportedChromiumBrowsers = [
3984
3884
  'Google Chrome Canary',
3985
3885
  'Google Chrome Dev',
3986
3886
  'Google Chrome Beta',
@@ -3989,20 +3889,23 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
3989
3889
  'Brave Browser',
3990
3890
  'Vivaldi',
3991
3891
  'Chromium'
3992
- ], getDefaultBrowserForAppleScript = async ()=>{
3993
- let { stdout: ps } = await execAsync('ps cax');
3994
- return supportedChromiumBrowsers.find((b)=>ps.includes(b));
3995
- }, 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)));
3996
3893
  async function openBrowser(url) {
3997
3894
  let browser = process.env.BROWSER, browserArgs = process.env.BROWSER_ARGS;
3998
- if (shouldTryAppleScript(browser, browserArgs)) try {
3999
- let chromiumBrowser = browser ? mapChromiumBrowserName(browser) : await getDefaultBrowserForAppleScript();
4000
- if (chromiumBrowser) return await execAsync(`osascript openChrome.applescript "${encodeURI(url)}" "${chromiumBrowser}"`, {
4001
- cwd: STATIC_PATH
4002
- }), !0;
4003
- rslog_index_js_namespaceObject.logger.debug('failed to find the target browser.');
4004
- } catch (err) {
4005
- 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
+ }
4006
3909
  }
4007
3910
  try {
4008
3911
  let { default: open } = await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "../../compiled/open/index.js")), { apps } = open, options = browser ? {
@@ -4037,13 +3940,13 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
4037
3940
  let { targets, before } = normalizeOpenConfig(config);
4038
3941
  if ('true' === process.env.CSB) return;
4039
3942
  clearCache && clearOpenedURLs();
4040
- 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}`;
4041
3944
  for (let url of (targets.length ? urls.push(...targets.map((target)=>(function(str, base) {
4042
3945
  if (canParse(str)) return str;
4043
3946
  try {
4044
3947
  return new URL(str, base).href;
4045
3948
  } catch (e) {
4046
- 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`);
4047
3950
  }
4048
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));
4049
3952
  }
@@ -4147,13 +4050,13 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
4147
4050
  initial: {},
4148
4051
  config: config.resolve.alias
4149
4052
  });
4150
- 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({
4151
4054
  initial: mergedAlias,
4152
4055
  config: config.source.alias
4153
- }), config.resolve.dedupe) for (let pkgName of config.resolve.dedupe){
4056
+ })), config.resolve.dedupe) for (let pkgName of config.resolve.dedupe){
4154
4057
  let pkgPath;
4155
4058
  if (mergedAlias[pkgName]) {
4156
- 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.`);
4157
4060
  continue;
4158
4061
  }
4159
4062
  try {
@@ -4175,7 +4078,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
4175
4078
  ].join(external_node_path_namespaceObject.sep);
4176
4079
  for(; !pkgPath.endsWith(trailing) && pkgPath.includes('node_modules');)pkgPath = (0, external_node_path_namespaceObject.dirname)(pkgPath);
4177
4080
  } catch (e) {
4178
- 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.`);
4179
4082
  continue;
4180
4083
  }
4181
4084
  mergedAlias[pkgName] = pkgPath;
@@ -4188,7 +4091,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
4188
4091
  chain,
4189
4092
  config,
4190
4093
  rootPath: api.context.rootPath
4191
- }), 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.`);
4192
4095
  let aliasStrategy = config.source.aliasStrategy ?? config.resolve.aliasStrategy;
4193
4096
  tsconfigPath && 'rspack' === api.context.bundlerType && 'prefer-tsconfig' === aliasStrategy && chain.resolve.tsConfig({
4194
4097
  configFile: tsconfigPath,
@@ -4423,7 +4326,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
4423
4326
  traceOutput = 'chrome' === traceLayer ? defaultRustTraceChromeOutput : 'stdout';
4424
4327
  }
4425
4328
  let filter = "OVERVIEW" === (value = filterValue) ? 'info' : "ALL" === value ? 'trace' : value;
4426
- 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;
4427
4330
  }
4428
4331
  let pluginRspackProfile = ()=>({
4429
4332
  name: 'rsbuild:rspack-profile',
@@ -4438,7 +4341,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
4438
4341
  api.onBeforeBuild(({ isFirstCompile })=>{
4439
4342
  isFirstCompile && onStart();
4440
4343
  }), api.onBeforeStartDevServer(onStart), api.onExit(()=>{
4441
- 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)}`));
4442
4345
  });
4443
4346
  }
4444
4347
  }), pluginServer = ()=>({
@@ -4474,9 +4377,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
4474
4377
  }
4475
4378
  });
4476
4379
  }
4477
- }), external_node_assert_namespaceObject = require("node:assert");
4478
- var external_node_assert_default = __webpack_require__.n(external_node_assert_namespaceObject);
4479
- let MODULE_PATH_REGEX = /.*[\\/]node_modules[\\/](?!\.pnpm[\\/])(?:(@[^\\/]+)[\\/])?([^\\/]+)/, SPLIT_STRATEGY_DISPATCHER = {
4380
+ }), MODULE_PATH_REGEX = /.*[\\/]node_modules[\\/](?!\.pnpm[\\/])(?:(@[^\\/]+)[\\/])?([^\\/]+)/, SPLIT_STRATEGY_DISPATCHER = {
4480
4381
  'split-by-experience': function(ctx) {
4481
4382
  let { override, polyfill, defaultConfig, forceSplittingGroups } = ctx, experienceCacheGroup = {}, packageRegExps = {
4482
4383
  axios: /node_modules[\\/]axios(-.+)?[\\/]/
@@ -4530,7 +4431,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
4530
4431
  },
4531
4432
  'split-by-size': function(ctx) {
4532
4433
  let { override, forceSplittingGroups, defaultConfig, userConfig } = ctx;
4533
- return external_node_assert_default()('split-by-size' === userConfig.strategy), {
4434
+ return {
4534
4435
  ...defaultConfig,
4535
4436
  minSize: userConfig.minSize ?? 0,
4536
4437
  maxSize: userConfig.maxSize ?? Number.POSITIVE_INFINITY,
@@ -4707,7 +4608,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
4707
4608
  swcConfig.jsc.transform.legacyDecorator = !1, swcConfig.jsc.transform.decoratorVersion = '2022-03';
4708
4609
  break;
4709
4610
  default:
4710
- 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)}`);
4711
4612
  }
4712
4613
  }(swcConfig, config), castArray(target1 = target).includes('web') || target1.includes('web-worker')) {
4713
4614
  let polyfillMode = config.output.polyfill;
@@ -4785,14 +4686,75 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
4785
4686
  });
4786
4687
  });
4787
4688
  }
4788
- }), getInspectOutputPath = (context, inspectOptions)=>inspectOptions.outputPath ? (0, external_node_path_namespaceObject.isAbsolute)(inspectOptions.outputPath) ? inspectOptions.outputPath : (0, external_node_path_namespaceObject.join)(context.distPath, inspectOptions.outputPath) : (0, external_node_path_namespaceObject.join)(context.distPath, RSBUILD_OUTPUTS_PATH);
4789
- async function inspectConfig({ context, pluginManager, rsbuildOptions, bundlerConfigs, inspectOptions = {} }) {
4689
+ }), normalizePluginObject = (plugin)=>{
4690
+ let { setup: _, ...rest } = plugin;
4691
+ return {
4692
+ ...rest,
4693
+ setup () {}
4694
+ };
4695
+ }, getRsbuildInspectConfig = ({ normalizedConfig, inspectOptions, pluginManager })=>{
4696
+ let { environments, ...rsbuildConfig } = normalizedConfig, rawRsbuildConfig = stringifyConfig({
4697
+ ...rsbuildConfig,
4698
+ plugins: pluginManager.getPlugins().map(normalizePluginObject)
4699
+ }, inspectOptions.verbose), environmentConfigs = {}, rawEnvironmentConfigs = [];
4700
+ for (let [name, config] of Object.entries(environments)){
4701
+ let debugConfig = {
4702
+ ...config,
4703
+ plugins: pluginManager.getPlugins({
4704
+ environment: name
4705
+ }).map(normalizePluginObject)
4706
+ };
4707
+ rawEnvironmentConfigs.push({
4708
+ name,
4709
+ content: stringifyConfig(debugConfig, inspectOptions.verbose)
4710
+ }), environmentConfigs[name] = debugConfig;
4711
+ }
4712
+ return {
4713
+ rsbuildConfig,
4714
+ rawRsbuildConfig,
4715
+ environmentConfigs: environments,
4716
+ rawEnvironmentConfigs
4717
+ };
4718
+ };
4719
+ async function outputInspectConfigFiles({ rawBundlerConfigs, rawEnvironmentConfigs, inspectOptions, configType }) {
4720
+ let { outputPath } = inspectOptions, files = [
4721
+ ...rawEnvironmentConfigs.map(({ name, content })=>{
4722
+ if (1 === rawEnvironmentConfigs.length) return {
4723
+ path: (0, external_node_path_namespaceObject.join)(outputPath, 'rsbuild.config.mjs'),
4724
+ label: 'Rsbuild config',
4725
+ content
4726
+ };
4727
+ let outputFile = `rsbuild.config.${name}.mjs`;
4728
+ return {
4729
+ path: (0, external_node_path_namespaceObject.join)(outputPath, outputFile),
4730
+ label: `Rsbuild config (${name})`,
4731
+ content
4732
+ };
4733
+ }),
4734
+ ...rawBundlerConfigs.map(({ name, content })=>{
4735
+ let outputFile = `${configType}.config.${name}.mjs`, outputFilePath = (0, external_node_path_namespaceObject.join)(outputPath, outputFile);
4736
+ return external_node_fs_default().existsSync(outputFilePath) && (outputFilePath = outputFilePath.replace(/\.mjs$/, `.${Date.now()}.mjs`)), {
4737
+ path: outputFilePath,
4738
+ label: `${upperFirst(configType)} Config (${name})`,
4739
+ content
4740
+ };
4741
+ })
4742
+ ];
4743
+ await external_node_fs_default().promises.mkdir(outputPath, {
4744
+ recursive: !0
4745
+ }), await Promise.all(files.map(async (item)=>external_node_fs_default().promises.writeFile(item.path, `export default ${item.content}`)));
4746
+ let fileInfos = files.map((item)=>` - ${index_js_default().bold(index_js_default().yellow(item.label))}: ${index_js_default().underline(item.path)}`).join('\n');
4747
+ rslog_index_js_namespaceObject.logger.success(`config inspection completed, generated files: \n\n${fileInfos}\n`);
4748
+ }
4749
+ function stringifyConfig(config, verbose) {
4750
+ return (0, rspack_chain_index_js_default().toString)(config, {
4751
+ verbose
4752
+ });
4753
+ }
4754
+ let getInspectOutputPath = (context, inspectOptions)=>inspectOptions.outputPath ? (0, external_node_path_namespaceObject.isAbsolute)(inspectOptions.outputPath) ? inspectOptions.outputPath : (0, external_node_path_namespaceObject.join)(context.distPath, inspectOptions.outputPath) : (0, external_node_path_namespaceObject.join)(context.distPath, RSBUILD_OUTPUTS_PATH);
4755
+ async function inspectConfig({ context, pluginManager, bundlerConfigs, inspectOptions = {}, bundler = 'rspack' }) {
4790
4756
  inspectOptions.mode ? setNodeEnv(inspectOptions.mode) : getNodeEnv() || setNodeEnv('development');
4791
- let rspackConfigs = bundlerConfigs || (await initConfigs({
4792
- context,
4793
- pluginManager,
4794
- rsbuildOptions
4795
- })).rspackConfigs, rawBundlerConfigs = rspackConfigs.map((config, index)=>({
4757
+ let rawBundlerConfigs = bundlerConfigs.map((config, index)=>({
4796
4758
  name: config.name || String(index),
4797
4759
  content: stringifyConfig(config, inspectOptions.verbose)
4798
4760
  })), { rsbuildConfig, rawRsbuildConfig, environmentConfigs, rawEnvironmentConfigs } = getRsbuildInspectConfig({
@@ -4807,7 +4769,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
4807
4769
  ...inspectOptions,
4808
4770
  outputPath
4809
4771
  },
4810
- configType: 'rspack'
4772
+ configType: bundler
4811
4773
  }), {
4812
4774
  rsbuildConfig: rawRsbuildConfig,
4813
4775
  environmentConfigs: rawEnvironmentConfigs.map((r)=>r.content),
@@ -4815,7 +4777,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
4815
4777
  origin: {
4816
4778
  rsbuildConfig,
4817
4779
  environmentConfigs,
4818
- bundlerConfigs: rspackConfigs
4780
+ bundlerConfigs
4819
4781
  }
4820
4782
  };
4821
4783
  }
@@ -4900,17 +4862,18 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
4900
4862
  if (config.plugins) {
4901
4863
  for (let plugin of config.plugins)if (plugin && void 0 === plugin.apply && 'name' in plugin && 'setup' in plugin) {
4902
4864
  let name = index_js_default().bold(index_js_default().yellow(plugin.name));
4903
- 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.`);
4904
4866
  }
4905
4867
  }
4906
- 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;
4907
4869
  }
4908
4870
  async function modifyRsbuildConfig(context) {
4871
+ var _context_config_plugins, _modified_plugins;
4909
4872
  rslog_index_js_namespaceObject.logger.debug('modify Rsbuild config');
4910
- 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, {
4911
4874
  mergeRsbuildConfig: mergeRsbuildConfig
4912
4875
  });
4913
- 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');
4914
4877
  }
4915
4878
  async function modifyEnvironmentConfig(context, config, name) {
4916
4879
  rslog_index_js_namespaceObject.logger.debug(`modify Rsbuild environment(${name}) config`);
@@ -4962,11 +4925,11 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
4962
4925
  }, config)
4963
4926
  })
4964
4927
  ]));
4965
- 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.`);
4966
4929
  return resolvedEnvironments;
4967
4930
  }
4968
4931
  let defaultEnvironmentName = camelCase(rsbuildSharedConfig.output.target);
4969
- 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.`);
4970
4933
  return {
4971
4934
  [defaultEnvironmentName]: applyEnvironmentDefaultConfig({
4972
4935
  ...rsbuildSharedConfig,
@@ -4980,7 +4943,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
4980
4943
  })
4981
4944
  };
4982
4945
  }, validateRsbuildConfig = (config)=>{
4983
- 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"`);
4984
4947
  };
4985
4948
  async function initRsbuildConfig({ context, pluginManager }) {
4986
4949
  if (context.normalizedConfig) return context.normalizedConfig;
@@ -4988,19 +4951,26 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
4988
4951
  getPluginAPI: context.getPluginAPI,
4989
4952
  pluginManager
4990
4953
  }), await modifyRsbuildConfig(context);
4991
- let normalizedBaseConfig = normalizeConfig(context.config), environments = {}, mergedEnvironments = initEnvironmentConfigs(normalizedBaseConfig, context.rootPath, context.specifiedEnvironments), { dev: { hmr, assetPrefix, progressBar, lazyCompilation, writeToDisk, ...rsbuildSharedDev }, server } = normalizedBaseConfig;
4954
+ let normalizedBaseConfig = normalizeConfig(context.config), environments = {}, mergedEnvironments = initEnvironmentConfigs(normalizedBaseConfig, context.rootPath, context.specifiedEnvironments), { dev: { hmr, assetPrefix, progressBar, lazyCompilation, writeToDisk, ...rsbuildSharedDev }, server } = normalizedBaseConfig, tsconfigPaths = new Set();
4992
4955
  for (let [name, config] of Object.entries(mergedEnvironments)){
4993
- let environmentConfig = await modifyEnvironmentConfig(context, config, name);
4994
- environments[name] = {
4956
+ let environmentConfig = await modifyEnvironmentConfig(context, config, name), normalizedEnvironmentConfig = {
4995
4957
  ...environmentConfig,
4996
4958
  dev: {
4997
4959
  ...environmentConfig.dev,
4998
4960
  ...rsbuildSharedDev
4999
4961
  },
5000
4962
  server
5001
- };
4963
+ }, { tsconfigPath } = normalizedEnvironmentConfig.source;
4964
+ if (tsconfigPath) {
4965
+ let absoluteTsconfigPath = ensureAbsolutePath(context.rootPath, tsconfigPath);
4966
+ normalizedEnvironmentConfig.source.tsconfigPath = absoluteTsconfigPath, tsconfigPaths.add(absoluteTsconfigPath);
4967
+ }
4968
+ environments[name] = normalizedEnvironmentConfig;
5002
4969
  }
5003
- context.normalizedConfig = {
4970
+ tsconfigPaths.size && 'prefer-tsconfig' === normalizedBaseConfig.resolve.aliasStrategy && normalizedBaseConfig.dev.watchFiles.push({
4971
+ paths: Array.from(tsconfigPaths),
4972
+ type: 'reload-server'
4973
+ }), context.normalizedConfig = {
5004
4974
  ...normalizedBaseConfig,
5005
4975
  environments
5006
4976
  }, await updateEnvironmentContext(context, environments);
@@ -5050,9 +5020,83 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
5050
5020
  rspackConfigs
5051
5021
  };
5052
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
+ }
5053
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)=>{
5054
5098
  var _config_server;
5055
- let { content: config, filePath } = await config_loadConfig({
5099
+ let { content: config, filePath } = await loadConfig_loadConfig({
5056
5100
  cwd: root,
5057
5101
  path: commonOpts.config,
5058
5102
  envMode: commonOpts.envMode,
@@ -5069,7 +5113,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
5069
5113
  async function init({ cliOptions, isRestart, isBuildWatch = !1 }) {
5070
5114
  cliOptions && (commonOpts = cliOptions);
5071
5115
  try {
5072
- let cwd = process.cwd(), root = commonOpts.root ? getAbsolutePath(cwd, commonOpts.root) : cwd, rsbuild = await createRsbuild({
5116
+ let cwd = process.cwd(), root = commonOpts.root ? ensureAbsolutePath(cwd, commonOpts.root) : cwd, rsbuild = await createRsbuild({
5073
5117
  cwd: root,
5074
5118
  rsbuildConfig: ()=>init_loadConfig(root),
5075
5119
  environment: commonOpts.environment,
@@ -5079,17 +5123,16 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
5079
5123
  }
5080
5124
  });
5081
5125
  return rsbuild.onBeforeCreateCompiler(()=>{
5082
- var _config_dev;
5083
5126
  if ('dev' !== rsbuild.context.action && !isBuildWatch) return;
5084
5127
  let files = [], config = rsbuild.getNormalizedConfig();
5085
- if (null == (_config_dev = config.dev) ? void 0 : _config_dev.watchFiles) for (let watchFilesConfig of castArray(config.dev.watchFiles)){
5086
- if ('reload-server' !== watchFilesConfig.type) continue;
5087
- let paths = castArray(watchFilesConfig.paths);
5088
- watchFilesConfig.options ? watchFilesForRestart({
5128
+ if (config.dev.watchFiles) for (let watchConfig of config.dev.watchFiles){
5129
+ if ('reload-server' !== watchConfig.type) continue;
5130
+ let paths = castArray(watchConfig.paths);
5131
+ watchConfig.options ? watchFilesForRestart({
5089
5132
  files: paths,
5090
5133
  rsbuild,
5091
5134
  isBuildWatch,
5092
- watchOptions: watchFilesConfig.options
5135
+ watchOptions: watchConfig.options
5093
5136
  }) : files.push(...paths);
5094
5137
  }
5095
5138
  watchFilesForRestart({
@@ -5213,10 +5256,8 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
5213
5256
  };
5214
5257
  watcher.on('add', onChange), watcher.on('change', onChange), watcher.on('unlink', onChange);
5215
5258
  }
5216
- let external_node_readline_namespaceObject = require("node:readline");
5217
- var external_node_readline_default = __webpack_require__.n(external_node_readline_namespaceObject);
5218
5259
  let isCliShortcutsEnabled = (devConfig)=>devConfig.cliShortcuts && isTTY('stdin');
5219
- function setupCliShortcuts({ help = !0, openPage, closeServer, printUrls, restartServer, customShortcuts }) {
5260
+ async function setupCliShortcuts({ help = !0, openPage, closeServer, printUrls, restartServer, customShortcuts }) {
5220
5261
  let shortcuts = [
5221
5262
  {
5222
5263
  key: 'c',
@@ -5252,9 +5293,9 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
5252
5293
  action: printUrls
5253
5294
  }
5254
5295
  ].filter(Boolean);
5255
- if (customShortcuts && !Array.isArray(shortcuts = customShortcuts(shortcuts))) throw Error('[rsbuild:config] `dev.cliShortcuts` must return an array of shortcuts.');
5256
- 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`);
5257
- 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({
5258
5299
  input: process.stdin
5259
5300
  });
5260
5301
  return rl.on('line', (input)=>{
@@ -5268,11 +5309,10 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
5268
5309
  rl.close();
5269
5310
  };
5270
5311
  }
5271
- let external_node_dns_namespaceObject = require("node:dns");
5272
5312
  async function getLocalhostResolvedAddress() {
5273
- let [defaultLookup, explicitLookup] = await Promise.all([
5274
- external_node_dns_namespaceObject.promises.lookup('localhost'),
5275
- 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', {
5276
5316
  verbatim: !0
5277
5317
  })
5278
5318
  ]);
@@ -5332,7 +5372,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
5332
5372
  serverSideRender: !0,
5333
5373
  writeToDisk: devConfig.writeToDisk
5334
5374
  });
5335
- }, external_node_querystring_namespaceObject = require("node:querystring"), styles = {
5375
+ }, styles = {
5336
5376
  1: 'font-weight:bold',
5337
5377
  2: 'opacity:0.5',
5338
5378
  3: 'font-style:italic',
@@ -5385,7 +5425,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
5385
5425
  rslog_index_js_namespaceObject.logger.error(err);
5386
5426
  }), this.heartbeatTimer = setTimeout(this.checkSockets, 30000).unref(), this.wsServer.on('connection', (socket, req)=>{
5387
5427
  let queryStr = req.url ? req.url.split('?')[1] : '';
5388
- this.onConnect(socket, queryStr ? (0, external_node_querystring_namespaceObject.parse)(queryStr) : {});
5428
+ this.onConnect(socket, queryStr ? Object.fromEntries(new URLSearchParams(queryStr)) : {});
5389
5429
  });
5390
5430
  }
5391
5431
  updateStats(stats) {
@@ -5738,7 +5778,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
5738
5778
  clientPaths,
5739
5779
  devConfig,
5740
5780
  serverConfig
5741
- }), { base } = serverConfig, assetPrefixes = publicPaths.map(pathnameParse).map((prefix)=>base && '/' !== base ? stripBase(prefix, base) : prefix), wrapper = async (req, res, next)=>{
5781
+ }), { base } = serverConfig, assetPrefixes = publicPaths.map(getPathnameFromUrl).map((prefix)=>base && '/' !== base ? stripBase(prefix, base) : prefix), wrapper = async (req, res, next)=>{
5742
5782
  let { url } = req, assetPrefix = url && assetPrefixes.find((prefix)=>url.startsWith(prefix));
5743
5783
  assetPrefix && '/' !== assetPrefix ? (req.url = url.slice(assetPrefix.length - 1), middleware(req, res, (...args)=>{
5744
5784
  req.url = url, next(...args);
@@ -5971,7 +6011,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
5971
6011
  }
5972
6012
  if (server.compress && middlewares.push(gzipMiddleware()), 'dev' === context.action && 'rspack' === context.bundlerType && dev.lazyCompilation && compilationManager) {
5973
6013
  let { compiler } = compilationManager;
5974
- '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));
5975
6015
  }
5976
6016
  server.base && '/' !== server.base && middlewares.push(getBaseMiddleware({
5977
6017
  base: server.base
@@ -6025,16 +6065,15 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
6025
6065
  onUpgrade,
6026
6066
  middlewares
6027
6067
  };
6028
- }, external_node_vm_namespaceObject = require("node:vm");
6029
- var external_node_vm_default = __webpack_require__.n(external_node_vm_namespaceObject);
6030
- let asModule = async (something, context, unlinked)=>{
6031
- 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;
6032
6071
  let exports1 = [
6033
6072
  ...new Set([
6034
6073
  'default',
6035
6074
  ...Object.keys(something)
6036
6075
  ])
6037
- ], m = new (external_node_vm_default()).SyntheticModule(exports1, ()=>{
6076
+ ], m = new SyntheticModule(exports1, ()=>{
6038
6077
  for (let name of exports1)m.setExport(name, 'default' === name ? something : something[name]);
6039
6078
  }, {
6040
6079
  context
@@ -6087,7 +6126,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
6087
6126
  postExecute(_m, _file) {}
6088
6127
  createRunner() {
6089
6128
  this.requirers.set('entry', (_currentDirectory, _modulePath, _context = {})=>{
6090
- throw Error('[rsbuild:runner] Not implement');
6129
+ throw Error(`${index_js_default().dim('[rsbuild:runner]')} Not implemented`);
6091
6130
  });
6092
6131
  }
6093
6132
  constructor(_options){
@@ -6145,7 +6184,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
6145
6184
  };
6146
6185
  }
6147
6186
  createCjsRequirer() {
6148
- let requireCache = Object.create(null);
6187
+ let requireCache = Object.create(null), vm = cjs_require('node:vm');
6149
6188
  return (currentDirectory, modulePath, context = {})=>{
6150
6189
  let file = context.file || this.getFile(modulePath, currentDirectory);
6151
6190
  if (!file) return this.requirers.get('miss')(currentDirectory, modulePath);
@@ -6159,7 +6198,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
6159
6198
  })`;
6160
6199
  this.preExecute(code, file);
6161
6200
  let dynamicImport = Function('specifier', 'return import(specifier)');
6162
- return external_node_vm_default().runInThisContext(code, {
6201
+ return vm.runInThisContext(code, {
6163
6202
  filename: file.path,
6164
6203
  importModuleDynamically: async (specifier)=>await dynamicImport(specifier)
6165
6204
  }).call(m.exports, ...argValues), this.postExecute(m, file), m.exports;
@@ -6169,6 +6208,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
6169
6208
  var type_EsmMode = function(EsmMode) {
6170
6209
  return EsmMode[EsmMode.Unknown = 0] = "Unknown", EsmMode[EsmMode.Evaluated = 1] = "Evaluated", EsmMode[EsmMode.Unlinked = 2] = "Unlinked", EsmMode;
6171
6210
  }({});
6211
+ let esm_require = (0, external_node_module_namespaceObject.createRequire)(__rslib_import_meta_url__);
6172
6212
  class EsmRunner extends CommonJsRunner {
6173
6213
  createRunner() {
6174
6214
  var _this__options_compilerOptions_experiments;
@@ -6186,13 +6226,13 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
6186
6226
  });
6187
6227
  }
6188
6228
  createEsmRequirer() {
6189
- let esmCache = new Map(), esmIdentifier = this._options.name;
6229
+ let esmCache = new Map(), esmIdentifier = this._options.name, vm = esm_require('node:vm');
6190
6230
  return (currentDirectory, modulePath, context = {})=>{
6191
- 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')}.`);
6192
6232
  let _require = this.getRequire(), file = context.file || this.getFile(modulePath, currentDirectory);
6193
6233
  if (!file) return this.requirers.get('miss')(currentDirectory, modulePath);
6194
6234
  let esm = esmCache.get(file.path);
6195
- return (esm || (esm = new (external_node_vm_default()).SourceTextModule(file.content, {
6235
+ return (esm || (esm = new vm.SourceTextModule(file.content, {
6196
6236
  identifier: `${esmIdentifier}-${file.path}`,
6197
6237
  url: `${(0, external_node_url_namespaceObject.pathToFileURL)(file.path).href}?${esmIdentifier}`,
6198
6238
  initializeImportMeta: (meta, _)=>{
@@ -6223,7 +6263,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
6223
6263
  name: this.name,
6224
6264
  ...options
6225
6265
  }, { compilerOptions } = options;
6226
- 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`);
6227
6267
  return new EsmRunner(runnerOptions);
6228
6268
  }
6229
6269
  constructor(name){
@@ -6244,7 +6284,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
6244
6284
  entrypoints: !0,
6245
6285
  outputPath: !0
6246
6286
  });
6247
- 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)}`);
6248
6288
  let { chunks: entryChunks = [] } = entrypoints[entryName], files = entryChunks.reduce((prev, entryChunkName)=>{
6249
6289
  let chunk = null == chunks ? void 0 : chunks.find((chunk)=>{
6250
6290
  var _chunk_names;
@@ -6252,8 +6292,8 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
6252
6292
  });
6253
6293
  return (null == chunk ? void 0 : chunk.files) ? prev.concat(chunk.files.filter((file)=>!file.endsWith('.css'))) : prev;
6254
6294
  }, []);
6255
- if (0 === files.length) throw Error(`[rsbuild:loadBundle] Failed to get bundle by entryName: "${entryName}"`);
6256
- 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(',')}`);
6257
6297
  let allChunkFiles = (null == chunks ? void 0 : chunks.flatMap((c)=>c.files).map((file)=>(0, external_node_path_namespaceObject.join)(outputPath, file))) || [];
6258
6298
  return await runner_run({
6259
6299
  bundlePath: files[0],
@@ -6264,7 +6304,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
6264
6304
  });
6265
6305
  }, getTransformedHtml = async (entryName, utils)=>{
6266
6306
  let { htmlPaths, distPath } = utils.environment, htmlPath = htmlPaths[entryName];
6267
- 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)}`);
6268
6308
  let fileName = (0, external_node_path_namespaceObject.join)(distPath, htmlPath);
6269
6309
  return utils.readFileSync(fileName);
6270
6310
  }, createCacheableFunction = (getter)=>{
@@ -6337,7 +6377,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
6337
6377
  });
6338
6378
  }) : Promise.resolve(), startCompile = async ()=>{
6339
6379
  let compiler = customCompiler || await createCompiler();
6340
- 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.`);
6341
6381
  let publicPaths = helpers_isMultiCompiler(compiler) ? compiler.compilers.map(getPublicPathFromCompiler) : [
6342
6382
  getPublicPathFromCompiler(compiler)
6343
6383
  ], compilationManager = new CompilationManager({
@@ -6351,7 +6391,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
6351
6391
  environments: context.environments
6352
6392
  });
6353
6393
  return await compilationManager.init(), compilationManager;
6354
- }, protocol = https ? 'https' : 'http', urls = getAddressUrls({
6394
+ }, protocol = https ? 'https' : 'http', urls = await getAddressUrls({
6355
6395
  protocol,
6356
6396
  port,
6357
6397
  host
@@ -6375,9 +6415,9 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
6375
6415
  ]);
6376
6416
  };
6377
6417
  middlewareMode || registerCleanup(closeServer);
6378
- let beforeCreateCompiler = ()=>{
6418
+ let beforeCreateCompiler = async ()=>{
6379
6419
  if (printUrls(), cliShortcutsEnabled) {
6380
- let shortcutsOptions = 'boolean' == typeof devConfig.cliShortcuts ? {} : devConfig.cliShortcuts, cleanup = setupCliShortcuts({
6420
+ let shortcutsOptions = 'boolean' == typeof devConfig.cliShortcuts ? {} : devConfig.cliShortcuts, cleanup = await setupCliShortcuts({
6381
6421
  openPage,
6382
6422
  closeServer,
6383
6423
  printUrls,
@@ -6394,18 +6434,18 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
6394
6434
  name,
6395
6435
  {
6396
6436
  getStats: async ()=>{
6397
- 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`);
6398
6438
  return await waitFirstCompileDone, lastStats[environment.index];
6399
6439
  },
6400
6440
  loadBundle: async (entryName)=>{
6401
- 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`);
6402
6442
  return await waitFirstCompileDone, cacheableLoadBundle(lastStats[environment.index], entryName, {
6403
6443
  readFileSync: compilationManager.readFileSync,
6404
6444
  environment
6405
6445
  });
6406
6446
  },
6407
6447
  getTransformedHtml: async (entryName)=>{
6408
- 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`);
6409
6449
  return await waitFirstCompileDone, cacheableTransformedHtml(lastStats[environment.index], entryName, {
6410
6450
  readFileSync: compilationManager.readFileSync,
6411
6451
  environment
@@ -6425,7 +6465,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
6425
6465
  data
6426
6466
  }),
6427
6467
  listen: async ()=>{
6428
- 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.`);
6429
6469
  let serverTerminator = getServerTerminator(httpServer);
6430
6470
  return rslog_index_js_namespaceObject.logger.debug('listen dev server'), context.hooks.onCloseDevServer.tap(serverTerminator), new Promise((resolve)=>{
6431
6471
  httpServer.listen({
@@ -6460,7 +6500,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
6460
6500
  server: devServerAPI,
6461
6501
  environments: context.environments
6462
6502
  })).filter((item)=>'function' == typeof item);
6463
- runCompile ? context.hooks.onBeforeCreateCompiler.tap(beforeCreateCompiler) : beforeCreateCompiler();
6503
+ runCompile ? context.hooks.onBeforeCreateCompiler.tap(beforeCreateCompiler) : await beforeCreateCompiler();
6464
6504
  let compilationManager = runCompile ? await startCompile() : void 0;
6465
6505
  for (let item of (fileWatcher = await setupWatchFiles({
6466
6506
  dev: devConfig,
@@ -6500,7 +6540,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
6500
6540
  if (await context.hooks.onBeforeCreateCompiler.callBatch({
6501
6541
  bundlerConfigs: rspackConfigs,
6502
6542
  environments: context.environments
6503
- }), !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)}`);
6504
6544
  let isMultiCompiler = rspackConfigs.length > 1, compiler = isMultiCompiler ? (0, core_namespaceObject.rspack)(rspackConfigs) : (0, core_namespaceObject.rspack)(rspackConfigs[0]), isVersionLogged = !1, isCompiling = !1, logRspackVersion = ()=>{
6505
6545
  isVersionLogged || (rslog_index_js_namespaceObject.logger.debug(`use Rspack v${core_namespaceObject.rspack.rspackVersion}`), isVersionLogged = !0);
6506
6546
  };
@@ -6637,12 +6677,20 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
6637
6677
  });
6638
6678
  return rspackConfigs;
6639
6679
  },
6640
- inspectConfig: async (inspectOptions)=>inspectConfig({
6680
+ async inspectConfig (inspectOptions) {
6681
+ let bundlerConfigs = (await initConfigs({
6682
+ context,
6683
+ pluginManager,
6684
+ rsbuildOptions
6685
+ })).rspackConfigs;
6686
+ return inspectConfig({
6641
6687
  context,
6642
6688
  pluginManager,
6643
6689
  rsbuildOptions,
6644
- inspectOptions
6645
- })
6690
+ inspectOptions,
6691
+ bundlerConfigs
6692
+ });
6693
+ }
6646
6694
  };
6647
6695
  };
6648
6696
  function prodServer_define_property(obj, key, value) {
@@ -6709,7 +6757,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
6709
6757
  pwd: context.rootPath,
6710
6758
  output: {
6711
6759
  path: context.distPath,
6712
- assetPrefixes: Object.values(context.environments).map((e)=>pathnameParse(e.config.output.assetPrefix))
6760
+ assetPrefixes: Object.values(context.environments).map((e)=>getPathnameFromUrl(e.config.output.assetPrefix))
6713
6761
  },
6714
6762
  serverConfig
6715
6763
  }, middlewares);
@@ -6729,7 +6777,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
6729
6777
  routes,
6730
6778
  environments: context.environments
6731
6779
  });
6732
- let protocol = https ? 'https' : 'http', urls = getAddressUrls({
6780
+ let protocol = https ? 'https' : 'http', urls = await getAddressUrls({
6733
6781
  protocol,
6734
6782
  port,
6735
6783
  host
@@ -6756,7 +6804,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
6756
6804
  });
6757
6805
  if (printUrls(), cliShortcutsEnabled) {
6758
6806
  let shortcutsOptions = 'boolean' == typeof config.dev.cliShortcuts ? {} : config.dev.cliShortcuts;
6759
- setupCliShortcuts({
6807
+ await setupCliShortcuts({
6760
6808
  openPage,
6761
6809
  closeServer,
6762
6810
  printUrls,
@@ -6909,7 +6957,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
6909
6957
  for (let newPlugin of newPlugins)if (newPlugin) {
6910
6958
  var plugin = newPlugin;
6911
6959
  let type = typeof plugin;
6912
- 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)}.`);
6913
6961
  if (!isFunction(plugin.setup)) {
6914
6962
  if (isFunction(plugin.apply)) {
6915
6963
  let { name = 'SomeWebpackPlugin' } = plugin.constructor || {};
@@ -6927,7 +6975,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
6927
6975
  `)
6928
6976
  ].join('\n'));
6929
6977
  }
6930
- 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)}.`);
6931
6979
  }
6932
6980
  if (before) {
6933
6981
  let index = plugins.findIndex((item)=>item.instance.name === before);
@@ -6973,12 +7021,12 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
6973
7021
  if (context.normalizedConfig) {
6974
7022
  if (null == options ? void 0 : options.environment) {
6975
7023
  let config = context.normalizedConfig.environments[options.environment];
6976
- 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}.`);
6977
7025
  return config;
6978
7026
  }
6979
7027
  return context.normalizedConfig;
6980
7028
  }
6981
- 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.`);
6982
7030
  }
6983
7031
  let getRsbuildConfig = (type = 'current')=>{
6984
7032
  switch(type){
@@ -6989,7 +7037,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
6989
7037
  case 'normalized':
6990
7038
  return getNormalizedConfig();
6991
7039
  }
6992
- 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.`);
6993
7041
  }, exposed = [], expose = (id, api)=>{
6994
7042
  exposed.push({
6995
7043
  id,
@@ -7161,11 +7209,11 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
7161
7209
  pluginManager
7162
7210
  }), { distPath } = context, { checkDistDir = !0 } = options;
7163
7211
  if (checkDistDir) {
7164
- 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.`);
7165
7213
  if (function(path) {
7166
7214
  let files = external_node_fs_default().readdirSync(path);
7167
7215
  return 0 === files.length || 1 === files.length && '.git' === files[0];
7168
- }(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.`);
7169
7217
  }
7170
7218
  return startProdServer(context, config, options);
7171
7219
  }, build = async (...args)=>{
@@ -7555,11 +7603,11 @@ ${section.body}` : section.body).join("\n\n"));
7555
7603
  }
7556
7604
  process.title = 'rsbuild-node';
7557
7605
  let { npm_execpath } = process.env;
7558
- (!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) && console.log(), rslog_index_js_namespaceObject.logger.greet(` Rsbuild v1.3.20\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`);
7559
7607
  try {
7560
7608
  !function() {
7561
7609
  let cli = cac_dist('rsbuild');
7562
- cli.help(), cli.version("1.3.20"), applyCommonOptions(cli);
7610
+ cli.help(), cli.version("1.3.22"), applyCommonOptions(cli);
7563
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');
7564
7612
  applyServerOptions(devCommand), applyServerOptions(previewCommand), devCommand.action(async (options)=>{
7565
7613
  try {
@@ -7610,7 +7658,7 @@ ${section.body}` : section.body).join("\n\n"));
7610
7658
  rslog_index_js_namespaceObject.logger.error('Failed to start Rsbuild CLI.'), rslog_index_js_namespaceObject.logger.error(err);
7611
7659
  }
7612
7660
  }
7613
- let src_version = "1.3.20";
7661
+ let src_version = "1.3.22";
7614
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 === [
7615
7663
  "PLUGIN_CSS_NAME",
7616
7664
  "PLUGIN_SWC_NAME",