@rsbuild/core 1.3.19 → 1.3.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -7,17 +7,17 @@ import * as __WEBPACK_EXTERNAL_MODULE_path__ from "path";
7
7
  import * as __WEBPACK_EXTERNAL_MODULE__rspack_core_e0096ff7__ from "@rspack/core";
8
8
  import * as __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__ from "node:fs";
9
9
  import * as __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__ from "node:path";
10
+ import * as __WEBPACK_EXTERNAL_MODULE_node_crypto_9ba42079__ from "node:crypto";
10
11
  import * as __WEBPACK_EXTERNAL_MODULE_node_url_e96de089__ from "node:url";
11
12
  import * as __WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__ from "../compiled/picocolors/index.js";
12
13
  import * as __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__ from "../compiled/rslog/index.js";
13
14
  import * as __WEBPACK_EXTERNAL_MODULE_node_util_types_ce11fc49__ from "node:util/types";
14
15
  import * as __WEBPACK_EXTERNAL_MODULE_node_module_ab9f2194__ from "node:module";
15
- import * as __WEBPACK_EXTERNAL_MODULE__compiled_rspack_chain_index_js_b67fefbd__ from "../compiled/rspack-chain/index.js";
16
16
  import * as __WEBPACK_EXTERNAL_MODULE_node_os_74b4b876__ from "node:os";
17
17
  import * as __WEBPACK_EXTERNAL_MODULE_node_process_786449bf__ from "node:process";
18
18
  import * as __WEBPACK_EXTERNAL_MODULE_node_util_1b29d436__ from "node:util";
19
19
  import * as __WEBPACK_EXTERNAL_MODULE__compiled_mrmime_index_js_86f064ca__ from "../compiled/mrmime/index.js";
20
- import * as __WEBPACK_EXTERNAL_MODULE_node_crypto_9ba42079__ from "node:crypto";
20
+ import * as __WEBPACK_EXTERNAL_MODULE__compiled_rspack_chain_index_js_b67fefbd__ from "../compiled/rspack-chain/index.js";
21
21
  import * as __WEBPACK_EXTERNAL_MODULE_node_zlib_a5bb16fc__ from "node:zlib";
22
22
  import * as __WEBPACK_EXTERNAL_MODULE_node_child_process_27f17141__ from "node:child_process";
23
23
  import * as __WEBPACK_EXTERNAL_MODULE_node_net_0373943e__ from "node:net";
@@ -929,17 +929,15 @@ __webpack_require__.r(provider_helpers_namespaceObject), __webpack_require__.d(p
929
929
  getChainUtils: ()=>getChainUtils,
930
930
  getConfigUtils: ()=>getConfigUtils,
931
931
  getHTMLPlugin: ()=>getHTMLPlugin,
932
- getRsbuildInspectConfig: ()=>getRsbuildInspectConfig,
933
932
  getStatsOptions: ()=>getStatsOptions,
934
933
  initRsbuildConfig: ()=>initRsbuildConfig,
934
+ inspectConfig: ()=>inspectConfig,
935
935
  modifyBundlerChain: ()=>modifyBundlerChain,
936
- outputInspectConfigFiles: ()=>outputInspectConfigFiles,
937
936
  prettyTime: ()=>prettyTime,
938
937
  registerBuildHook: ()=>registerBuildHook,
939
938
  registerDevHook: ()=>registerDevHook,
940
939
  setCssExtractPlugin: ()=>setCssExtractPlugin,
941
- setHTMLPlugin: ()=>setHTMLPlugin,
942
- stringifyConfig: ()=>stringifyConfig
940
+ setHTMLPlugin: ()=>setHTMLPlugin
943
941
  });
944
942
  var main = __webpack_require__("../../node_modules/.pnpm/dotenv@16.5.0/node_modules/dotenv/lib/main.js"), lib_main = __webpack_require__("../../node_modules/.pnpm/dotenv-expand@12.0.2/node_modules/dotenv-expand/lib/main.js"), cjs = __webpack_require__("../../node_modules/.pnpm/deepmerge@4.3.1/node_modules/deepmerge/dist/cjs.js"), cjs_default = __webpack_require__.n(cjs);
945
943
  let constants_filename = (0, __WEBPACK_EXTERNAL_MODULE_node_url_e96de089__.fileURLToPath)(import.meta.url), constants_dirname = (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.dirname)(constants_filename), ROOT_DIST_DIR = 'dist', LOADER_PATH = (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(constants_dirname), STATIC_PATH = (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(constants_dirname, '../static'), COMPILED_PATH = (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(constants_dirname, '../compiled'), RSBUILD_OUTPUTS_PATH = '.rsbuild', DEFAULT_DEV_HOST = '0.0.0.0', DEFAULT_ASSET_PREFIX = '/', DEFAULT_WEB_BROWSERSLIST = [
@@ -997,9 +995,6 @@ let constants_filename = (0, __WEBPACK_EXTERNAL_MODULE_node_url_e96de089__.fileU
997
995
  '*'
998
996
  ].some((key)=>values.includes(key));
999
997
  };
1000
- function getAbsolutePath(base, filepath) {
1001
- return (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.isAbsolute)(filepath) ? filepath : (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(base, filepath);
1002
- }
1003
998
  isDebug() && (__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.level = 'verbose'), __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.override({
1004
999
  debug: (message, ...args)=>{
1005
1000
  if ('verbose' !== __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.level) return;
@@ -1010,7 +1005,7 @@ isDebug() && (__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logg
1010
1005
  console.log(` ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.magenta('rsbuild')} ${time} ${message}`, ...args);
1011
1006
  }
1012
1007
  });
1013
- let getCompiledPath = (packageName)=>(0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(COMPILED_PATH, packageName, 'index.js'), ensureAbsolutePath = (base, filePath)=>(0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.isAbsolute)(filePath) ? filePath : (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.resolve)(base, filePath), pathnameParse = (publicPath)=>{
1008
+ let getCompiledPath = (packageName)=>(0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(COMPILED_PATH, packageName, 'index.js'), ensureAbsolutePath = (base, filePath)=>(0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.isAbsolute)(filePath) ? filePath : (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(base, filePath), getPathnameFromUrl = (publicPath)=>{
1014
1009
  try {
1015
1010
  return publicPath ? new URL(publicPath).pathname : publicPath;
1016
1011
  } catch (err) {
@@ -1227,7 +1222,7 @@ function formatStats(statsData, hasErrors) {
1227
1222
  }
1228
1223
  return {};
1229
1224
  }
1230
- let rspackMinVersion = '1.0.0', getNodeEnv = ()=>process.env.NODE_ENV, setNodeEnv = (env)=>{
1225
+ let rspackMinVersion = '1.2.4', getNodeEnv = ()=>process.env.NODE_ENV, setNodeEnv = (env)=>{
1231
1226
  process.env.NODE_ENV = env;
1232
1227
  }, isFunction = (func)=>'function' == typeof func, isObject = (obj)=>'[object Object]' === Object.prototype.toString.call(obj), isPlainObject = (obj)=>null !== obj && 'object' == typeof obj && Object.getPrototypeOf(obj) === Object.prototype, castArray = (arr)=>void 0 === arr ? [] : Array.isArray(arr) ? arr : [
1233
1228
  arr
@@ -1445,6 +1440,7 @@ let configCache = {}, OVERRIDE_PATHS = [
1445
1440
  }, mergeRsbuildConfig = (...configs)=>2 === configs.length ? merge(configs[0], configs[1]) : configs.length < 2 ? configs[0] : configs.reduce((result, config)=>merge(result, config), {}), config_require = (0, __WEBPACK_EXTERNAL_MODULE_node_module_ab9f2194__.createRequire)(import.meta.url), getDefaultDevConfig = ()=>({
1446
1441
  hmr: !0,
1447
1442
  liveReload: !0,
1443
+ watchFiles: [],
1448
1444
  assetPrefix: DEFAULT_ASSET_PREFIX,
1449
1445
  writeToDisk: !1,
1450
1446
  cliShortcuts: !1,
@@ -1583,14 +1579,19 @@ let configCache = {}, OVERRIDE_PATHS = [
1583
1579
  await isFileExists(tsconfigPath) && (merged.source.tsconfigPath = tsconfigPath);
1584
1580
  }
1585
1581
  return merged;
1586
- }, normalizeConfig = (config)=>mergeRsbuildConfig({
1582
+ }, normalizeConfig = (config)=>{
1583
+ let mergedConfig = mergeRsbuildConfig({
1587
1584
  ...createDefaultConfig(),
1588
1585
  mode: (()=>{
1589
1586
  if (config.mode) return config.mode;
1590
1587
  let nodeEnv = getNodeEnv();
1591
1588
  return 'production' === nodeEnv || 'development' === nodeEnv ? nodeEnv : 'none';
1592
1589
  })()
1593
- }, config);
1590
+ }, config), { watchFiles } = mergedConfig.dev;
1591
+ return Array.isArray(watchFiles) || (mergedConfig.dev.watchFiles = [
1592
+ watchFiles
1593
+ ]), mergedConfig;
1594
+ };
1594
1595
  function defineConfig(config) {
1595
1596
  return config;
1596
1597
  }
@@ -1665,71 +1666,6 @@ async function config_loadConfig({ cwd = process.cwd(), path, envMode, meta, loa
1665
1666
  filePath: configFilePath
1666
1667
  };
1667
1668
  }
1668
- let normalizePluginObject = (plugin)=>{
1669
- let { setup: _, ...rest } = plugin;
1670
- return {
1671
- ...rest,
1672
- setup () {}
1673
- };
1674
- }, getRsbuildInspectConfig = ({ normalizedConfig, inspectOptions, pluginManager })=>{
1675
- let { environments, ...rsbuildConfig } = normalizedConfig, rawRsbuildConfig = stringifyConfig({
1676
- ...rsbuildConfig,
1677
- plugins: pluginManager.getPlugins().map(normalizePluginObject)
1678
- }, inspectOptions.verbose), environmentConfigs = {}, rawEnvironmentConfigs = [];
1679
- for (let [name, config] of Object.entries(environments)){
1680
- let debugConfig = {
1681
- ...config,
1682
- plugins: pluginManager.getPlugins({
1683
- environment: name
1684
- }).map(normalizePluginObject)
1685
- };
1686
- rawEnvironmentConfigs.push({
1687
- name,
1688
- content: stringifyConfig(debugConfig, inspectOptions.verbose)
1689
- }), environmentConfigs[name] = debugConfig;
1690
- }
1691
- return {
1692
- rsbuildConfig,
1693
- rawRsbuildConfig,
1694
- environmentConfigs: environments,
1695
- rawEnvironmentConfigs
1696
- };
1697
- };
1698
- async function outputInspectConfigFiles({ rawBundlerConfigs, rawEnvironmentConfigs, inspectOptions, configType }) {
1699
- let { outputPath } = inspectOptions, files = [
1700
- ...rawEnvironmentConfigs.map(({ name, content })=>{
1701
- if (1 === rawEnvironmentConfigs.length) return {
1702
- path: (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(outputPath, 'rsbuild.config.mjs'),
1703
- label: 'Rsbuild config',
1704
- content
1705
- };
1706
- let outputFile = `rsbuild.config.${name}.mjs`;
1707
- return {
1708
- path: (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(outputPath, outputFile),
1709
- label: `Rsbuild config (${name})`,
1710
- content
1711
- };
1712
- }),
1713
- ...rawBundlerConfigs.map(({ name, content })=>{
1714
- let outputFile = `${configType}.config.${name}.mjs`, outputFilePath = (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(outputPath, outputFile);
1715
- return __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__.default.existsSync(outputFilePath) && (outputFilePath = outputFilePath.replace(/\.mjs$/, `.${Date.now()}.mjs`)), {
1716
- path: outputFilePath,
1717
- label: `${upperFirst(configType)} Config (${name})`,
1718
- content
1719
- };
1720
- })
1721
- ];
1722
- await __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__.default.promises.mkdir(outputPath, {
1723
- recursive: !0
1724
- }), await Promise.all(files.map(async (item)=>__WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__.default.promises.writeFile(item.path, `export default ${item.content}`)));
1725
- let fileInfos = files.map((item)=>` - ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.bold(__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow(item.label))}: ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.underline(item.path)}`).join('\n');
1726
- __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.success(`config inspection completed, generated files: \n\n${fileInfos}\n`);
1727
- }
1728
- function stringifyConfig(config, verbose) {
1729
- return (0, __WEBPACK_EXTERNAL_MODULE__compiled_rspack_chain_index_js_b67fefbd__.default.toString)(config, {
1730
- verbose
1731
- });
1732
- }
1733
1669
  let normalizePublicDirs = (publicDir)=>{
1734
1670
  if (!1 === publicDir) return [];
1735
1671
  let defaultConfig = {
@@ -2094,12 +2030,12 @@ let getEnvironmentHTMLPaths = (entry, config)=>'web' !== config.output.target ||
2094
2030
  }, {});
2095
2031
  async function updateEnvironmentContext(context, configs) {
2096
2032
  for (let [index, [name, config]] of (context.environments ||= {}, Object.entries(configs).entries())){
2097
- let tsconfigPath = config.source.tsconfigPath ? getAbsolutePath(context.rootPath, config.source.tsconfigPath) : void 0, browserslist = await getBrowserslistByEnvironment(context.rootPath, config), entry = config.source.entry ?? {}, htmlPaths = getEnvironmentHTMLPaths(entry, config), environmentContext = {
2033
+ let browserslist = await getBrowserslistByEnvironment(context.rootPath, config), { entry = {}, tsconfigPath } = config.source, htmlPaths = getEnvironmentHTMLPaths(entry, config), environmentContext = {
2098
2034
  index,
2099
2035
  name,
2100
2036
  distPath: function(cwd, config) {
2101
2037
  var _config_output_distPath, _config_output;
2102
- return getAbsolutePath(cwd, (null == (_config_output = config.output) || null == (_config_output_distPath = _config_output.distPath) ? void 0 : _config_output_distPath.root) ?? ROOT_DIST_DIR);
2038
+ return ensureAbsolutePath(cwd, (null == (_config_output = config.output) || null == (_config_output_distPath = _config_output.distPath) ? void 0 : _config_output_distPath.root) ?? ROOT_DIST_DIR);
2103
2039
  }(context.rootPath, config),
2104
2040
  entry,
2105
2041
  browserslist,
@@ -2114,9 +2050,9 @@ async function updateEnvironmentContext(context, configs) {
2114
2050
  }
2115
2051
  }
2116
2052
  async function createContext(options, userConfig) {
2117
- let { cwd } = options, rootPath = userConfig.root ? getAbsolutePath(cwd, userConfig.root) : cwd, rsbuildConfig = await withDefaultConfig(rootPath, userConfig), cachePath = (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(rootPath, 'node_modules', '.cache'), specifiedEnvironments = options.environment && options.environment.length > 0 ? options.environment : void 0, bundlerType = userConfig.provider ? 'webpack' : 'rspack';
2053
+ let { cwd } = options, rootPath = userConfig.root ? ensureAbsolutePath(cwd, userConfig.root) : cwd, rsbuildConfig = await withDefaultConfig(rootPath, userConfig), cachePath = (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(rootPath, 'node_modules', '.cache'), specifiedEnvironments = options.environment && options.environment.length > 0 ? options.environment : void 0, bundlerType = userConfig.provider ? 'webpack' : 'rspack';
2118
2054
  return {
2119
- version: "1.3.19",
2055
+ version: "1.3.21",
2120
2056
  rootPath,
2121
2057
  distPath: '',
2122
2058
  cachePath,
@@ -2491,7 +2427,7 @@ let pluginCache = ()=>({
2491
2427
  setup (api) {
2492
2428
  let cacheEnabled = !1;
2493
2429
  api.modifyBundlerChain(async (chain, { environment, env })=>{
2494
- var digest;
2430
+ var data;
2495
2431
  let { config } = environment, { bundlerType } = api.context, buildCache = config.performance.buildCache ?? 'webpack' === bundlerType;
2496
2432
  if (!1 === buildCache) return;
2497
2433
  cacheEnabled = !0;
@@ -2501,7 +2437,7 @@ let pluginCache = ()=>({
2501
2437
  userBuildDependencies: cacheConfig.buildDependencies
2502
2438
  } : {});
2503
2439
  'webpack' === bundlerType && await validateWebpackCache(cacheDirectory, buildDependencies);
2504
- let cacheVersion = Array.isArray(cacheConfig.cacheDigest) && cacheConfig.cacheDigest.length ? `${environment.name}-${env}-${digest = cacheConfig.cacheDigest, __WEBPACK_EXTERNAL_MODULE_node_crypto_9ba42079__.default.createHash('md5').update(JSON.stringify(digest)).digest('hex').slice(0, 8)}` : `${environment.name}-${env}`;
2440
+ let cacheVersion = Array.isArray(cacheConfig.cacheDigest) && cacheConfig.cacheDigest.length ? `${environment.name}-${env}-${data = JSON.stringify(cacheConfig.cacheDigest), __WEBPACK_EXTERNAL_MODULE_node_crypto_9ba42079__.default.hash ? __WEBPACK_EXTERNAL_MODULE_node_crypto_9ba42079__.default.hash('sha256', data, 'hex').slice(0, 16) : __WEBPACK_EXTERNAL_MODULE_node_crypto_9ba42079__.default.createHash('sha256').update(data).digest('hex').slice(0, 16)}` : `${environment.name}-${env}`;
2505
2441
  'rspack' === bundlerType ? (chain.cache(!0), chain.experiments({
2506
2442
  ...chain.get('experiments'),
2507
2443
  cache: {
@@ -4630,14 +4566,75 @@ let reduceTransformImportConfig = (options)=>{
4630
4566
  });
4631
4567
  });
4632
4568
  }
4633
- }), getInspectOutputPath = (context, inspectOptions)=>inspectOptions.outputPath ? (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.isAbsolute)(inspectOptions.outputPath) ? inspectOptions.outputPath : (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(context.distPath, inspectOptions.outputPath) : (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(context.distPath, RSBUILD_OUTPUTS_PATH);
4634
- async function inspectConfig({ context, pluginManager, rsbuildOptions, bundlerConfigs, inspectOptions = {} }) {
4569
+ }), normalizePluginObject = (plugin)=>{
4570
+ let { setup: _, ...rest } = plugin;
4571
+ return {
4572
+ ...rest,
4573
+ setup () {}
4574
+ };
4575
+ }, getRsbuildInspectConfig = ({ normalizedConfig, inspectOptions, pluginManager })=>{
4576
+ let { environments, ...rsbuildConfig } = normalizedConfig, rawRsbuildConfig = stringifyConfig({
4577
+ ...rsbuildConfig,
4578
+ plugins: pluginManager.getPlugins().map(normalizePluginObject)
4579
+ }, inspectOptions.verbose), environmentConfigs = {}, rawEnvironmentConfigs = [];
4580
+ for (let [name, config] of Object.entries(environments)){
4581
+ let debugConfig = {
4582
+ ...config,
4583
+ plugins: pluginManager.getPlugins({
4584
+ environment: name
4585
+ }).map(normalizePluginObject)
4586
+ };
4587
+ rawEnvironmentConfigs.push({
4588
+ name,
4589
+ content: stringifyConfig(debugConfig, inspectOptions.verbose)
4590
+ }), environmentConfigs[name] = debugConfig;
4591
+ }
4592
+ return {
4593
+ rsbuildConfig,
4594
+ rawRsbuildConfig,
4595
+ environmentConfigs: environments,
4596
+ rawEnvironmentConfigs
4597
+ };
4598
+ };
4599
+ async function outputInspectConfigFiles({ rawBundlerConfigs, rawEnvironmentConfigs, inspectOptions, configType }) {
4600
+ let { outputPath } = inspectOptions, files = [
4601
+ ...rawEnvironmentConfigs.map(({ name, content })=>{
4602
+ if (1 === rawEnvironmentConfigs.length) return {
4603
+ path: (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(outputPath, 'rsbuild.config.mjs'),
4604
+ label: 'Rsbuild config',
4605
+ content
4606
+ };
4607
+ let outputFile = `rsbuild.config.${name}.mjs`;
4608
+ return {
4609
+ path: (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(outputPath, outputFile),
4610
+ label: `Rsbuild config (${name})`,
4611
+ content
4612
+ };
4613
+ }),
4614
+ ...rawBundlerConfigs.map(({ name, content })=>{
4615
+ let outputFile = `${configType}.config.${name}.mjs`, outputFilePath = (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(outputPath, outputFile);
4616
+ return __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__.default.existsSync(outputFilePath) && (outputFilePath = outputFilePath.replace(/\.mjs$/, `.${Date.now()}.mjs`)), {
4617
+ path: outputFilePath,
4618
+ label: `${upperFirst(configType)} Config (${name})`,
4619
+ content
4620
+ };
4621
+ })
4622
+ ];
4623
+ await __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__.default.promises.mkdir(outputPath, {
4624
+ recursive: !0
4625
+ }), await Promise.all(files.map(async (item)=>__WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__.default.promises.writeFile(item.path, `export default ${item.content}`)));
4626
+ let fileInfos = files.map((item)=>` - ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.bold(__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.yellow(item.label))}: ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__.default.underline(item.path)}`).join('\n');
4627
+ __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.success(`config inspection completed, generated files: \n\n${fileInfos}\n`);
4628
+ }
4629
+ function stringifyConfig(config, verbose) {
4630
+ return (0, __WEBPACK_EXTERNAL_MODULE__compiled_rspack_chain_index_js_b67fefbd__.default.toString)(config, {
4631
+ verbose
4632
+ });
4633
+ }
4634
+ let getInspectOutputPath = (context, inspectOptions)=>inspectOptions.outputPath ? (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.isAbsolute)(inspectOptions.outputPath) ? inspectOptions.outputPath : (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(context.distPath, inspectOptions.outputPath) : (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(context.distPath, RSBUILD_OUTPUTS_PATH);
4635
+ async function inspectConfig({ context, pluginManager, bundlerConfigs, inspectOptions = {}, bundler = 'rspack' }) {
4635
4636
  inspectOptions.mode ? setNodeEnv(inspectOptions.mode) : getNodeEnv() || setNodeEnv('development');
4636
- let rspackConfigs = bundlerConfigs || (await initConfigs({
4637
- context,
4638
- pluginManager,
4639
- rsbuildOptions
4640
- })).rspackConfigs, rawBundlerConfigs = rspackConfigs.map((config, index)=>({
4637
+ let rawBundlerConfigs = bundlerConfigs.map((config, index)=>({
4641
4638
  name: config.name || String(index),
4642
4639
  content: stringifyConfig(config, inspectOptions.verbose)
4643
4640
  })), { rsbuildConfig, rawRsbuildConfig, environmentConfigs, rawEnvironmentConfigs } = getRsbuildInspectConfig({
@@ -4652,7 +4649,7 @@ async function inspectConfig({ context, pluginManager, rsbuildOptions, bundlerCo
4652
4649
  ...inspectOptions,
4653
4650
  outputPath
4654
4651
  },
4655
- configType: 'rspack'
4652
+ configType: bundler
4656
4653
  }), {
4657
4654
  rsbuildConfig: rawRsbuildConfig,
4658
4655
  environmentConfigs: rawEnvironmentConfigs.map((r)=>r.content),
@@ -4660,7 +4657,7 @@ async function inspectConfig({ context, pluginManager, rsbuildOptions, bundlerCo
4660
4657
  origin: {
4661
4658
  rsbuildConfig,
4662
4659
  environmentConfigs,
4663
- bundlerConfigs: rspackConfigs
4660
+ bundlerConfigs
4664
4661
  }
4665
4662
  };
4666
4663
  }
@@ -4672,18 +4669,22 @@ async function modifyRspackConfig(context, rspackConfig, chainUtils) {
4672
4669
  get: (_, prop)=>currentConfig[prop],
4673
4670
  set: (_, prop, value)=>(currentConfig[prop] = value, !0)
4674
4671
  }), utils = await getConfigUtils(proxiedConfig, chainUtils);
4675
- return [currentConfig] = await context.hooks.modifyRspackConfig.callChain({
4672
+ if ([currentConfig] = await context.hooks.modifyRspackConfig.callChain({
4676
4673
  environment: utils.environment.name,
4677
4674
  args: [
4678
4675
  rspackConfig,
4679
4676
  utils
4680
4677
  ]
4681
- }), (null == (_utils_environment_config_tools = utils.environment.config.tools) ? void 0 : _utils_environment_config_tools.rspack) && (currentConfig = await reduceConfigsAsyncWithContext({
4682
- initial: currentConfig,
4683
- config: utils.environment.config.tools.rspack,
4684
- ctx: utils,
4685
- mergeFn: (...args)=>currentConfig = utils.mergeConfig.call(utils, args)
4686
- })), __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.debug('modify Rspack config done'), currentConfig;
4678
+ }), null == (_utils_environment_config_tools = utils.environment.config.tools) ? void 0 : _utils_environment_config_tools.rspack) {
4679
+ let toolsRspackConfig = utils.environment.config.tools.rspack;
4680
+ currentConfig = await reduceConfigsAsyncWithContext({
4681
+ initial: currentConfig,
4682
+ config: toolsRspackConfig,
4683
+ ctx: utils,
4684
+ mergeFn: (...args)=>currentConfig = utils.mergeConfig.call(utils, args)
4685
+ });
4686
+ }
4687
+ return __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.debug('modify Rspack config done'), currentConfig;
4687
4688
  }
4688
4689
  async function getConfigUtils(config, chainUtils) {
4689
4690
  return {
@@ -4829,19 +4830,26 @@ async function initRsbuildConfig({ context, pluginManager }) {
4829
4830
  getPluginAPI: context.getPluginAPI,
4830
4831
  pluginManager
4831
4832
  }), await modifyRsbuildConfig(context);
4832
- let normalizedBaseConfig = normalizeConfig(context.config), environments = {}, mergedEnvironments = initEnvironmentConfigs(normalizedBaseConfig, context.rootPath, context.specifiedEnvironments), { dev: { hmr, assetPrefix, progressBar, lazyCompilation, writeToDisk, ...rsbuildSharedDev }, server } = normalizedBaseConfig;
4833
+ 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();
4833
4834
  for (let [name, config] of Object.entries(mergedEnvironments)){
4834
- let environmentConfig = await modifyEnvironmentConfig(context, config, name);
4835
- environments[name] = {
4835
+ let environmentConfig = await modifyEnvironmentConfig(context, config, name), normalizedEnvironmentConfig = {
4836
4836
  ...environmentConfig,
4837
4837
  dev: {
4838
4838
  ...environmentConfig.dev,
4839
4839
  ...rsbuildSharedDev
4840
4840
  },
4841
4841
  server
4842
- };
4842
+ }, { tsconfigPath } = normalizedEnvironmentConfig.source;
4843
+ if (tsconfigPath) {
4844
+ let absoluteTsconfigPath = ensureAbsolutePath(context.rootPath, tsconfigPath);
4845
+ normalizedEnvironmentConfig.source.tsconfigPath = absoluteTsconfigPath, tsconfigPaths.add(absoluteTsconfigPath);
4846
+ }
4847
+ environments[name] = normalizedEnvironmentConfig;
4843
4848
  }
4844
- context.normalizedConfig = {
4849
+ tsconfigPaths.size && 'prefer-tsconfig' === normalizedBaseConfig.resolve.aliasStrategy && normalizedBaseConfig.dev.watchFiles.push({
4850
+ paths: Array.from(tsconfigPaths),
4851
+ type: 'reload-server'
4852
+ }), context.normalizedConfig = {
4845
4853
  ...normalizedBaseConfig,
4846
4854
  environments
4847
4855
  }, await updateEnvironmentContext(context, environments);
@@ -4909,7 +4917,7 @@ let commonOpts = {}, getEnvDir = (cwd, envDir)=>envDir ? __WEBPACK_EXTERNAL_MODU
4909
4917
  async function init({ cliOptions, isRestart, isBuildWatch = !1 }) {
4910
4918
  cliOptions && (commonOpts = cliOptions);
4911
4919
  try {
4912
- let cwd = process.cwd(), root = commonOpts.root ? getAbsolutePath(cwd, commonOpts.root) : cwd, rsbuild = await createRsbuild({
4920
+ let cwd = process.cwd(), root = commonOpts.root ? ensureAbsolutePath(cwd, commonOpts.root) : cwd, rsbuild = await createRsbuild({
4913
4921
  cwd: root,
4914
4922
  rsbuildConfig: ()=>init_loadConfig(root),
4915
4923
  environment: commonOpts.environment,
@@ -4919,17 +4927,16 @@ async function init({ cliOptions, isRestart, isBuildWatch = !1 }) {
4919
4927
  }
4920
4928
  });
4921
4929
  return rsbuild.onBeforeCreateCompiler(()=>{
4922
- var _config_dev;
4923
4930
  if ('dev' !== rsbuild.context.action && !isBuildWatch) return;
4924
4931
  let files = [], config = rsbuild.getNormalizedConfig();
4925
- if (null == (_config_dev = config.dev) ? void 0 : _config_dev.watchFiles) for (let watchFilesConfig of castArray(config.dev.watchFiles)){
4926
- if ('reload-server' !== watchFilesConfig.type) continue;
4927
- let paths = castArray(watchFilesConfig.paths);
4928
- watchFilesConfig.options ? watchFilesForRestart({
4932
+ if (config.dev.watchFiles) for (let watchConfig of config.dev.watchFiles){
4933
+ if ('reload-server' !== watchConfig.type) continue;
4934
+ let paths = castArray(watchConfig.paths);
4935
+ watchConfig.options ? watchFilesForRestart({
4929
4936
  files: paths,
4930
4937
  rsbuild,
4931
4938
  isBuildWatch,
4932
- watchOptions: watchFilesConfig.options
4939
+ watchOptions: watchConfig.options
4933
4940
  }) : files.push(...paths);
4934
4941
  }
4935
4942
  watchFilesForRestart({
@@ -5574,7 +5581,7 @@ class CompilationManager {
5574
5581
  clientPaths,
5575
5582
  devConfig,
5576
5583
  serverConfig
5577
- }), { base } = serverConfig, assetPrefixes = publicPaths.map(pathnameParse).map((prefix)=>base && '/' !== base ? stripBase(prefix, base) : prefix), wrapper = async (req, res, next)=>{
5584
+ }), { base } = serverConfig, assetPrefixes = publicPaths.map(getPathnameFromUrl).map((prefix)=>base && '/' !== base ? stripBase(prefix, base) : prefix), wrapper = async (req, res, next)=>{
5578
5585
  let { url } = req, assetPrefix = url && assetPrefixes.find((prefix)=>url.startsWith(prefix));
5579
5586
  assetPrefix && '/' !== assetPrefix ? (req.url = url.slice(assetPrefix.length - 1), middleware(req, res, (...args)=>{
5580
5587
  req.url = url, next(...args);
@@ -6468,12 +6475,20 @@ let RSPACK_BUILD_ERROR = 'Rspack build failed.', build_build = async (initOption
6468
6475
  });
6469
6476
  return rspackConfigs;
6470
6477
  },
6471
- inspectConfig: async (inspectOptions)=>inspectConfig({
6478
+ async inspectConfig (inspectOptions) {
6479
+ let bundlerConfigs = (await initConfigs({
6480
+ context,
6481
+ pluginManager,
6482
+ rsbuildOptions
6483
+ })).rspackConfigs;
6484
+ return inspectConfig({
6472
6485
  context,
6473
6486
  pluginManager,
6474
6487
  rsbuildOptions,
6475
- inspectOptions
6476
- })
6488
+ inspectOptions,
6489
+ bundlerConfigs
6490
+ });
6491
+ }
6477
6492
  };
6478
6493
  };
6479
6494
  function prodServer_define_property(obj, key, value) {
@@ -6540,7 +6555,7 @@ async function startProdServer(context, config, { getPortSilently } = {}) {
6540
6555
  pwd: context.rootPath,
6541
6556
  output: {
6542
6557
  path: context.distPath,
6543
- assetPrefixes: Object.values(context.environments).map((e)=>pathnameParse(e.config.output.assetPrefix))
6558
+ assetPrefixes: Object.values(context.environments).map((e)=>getPathnameFromUrl(e.config.output.assetPrefix))
6544
6559
  },
6545
6560
  serverConfig
6546
6561
  }, middlewares);
@@ -7384,11 +7399,11 @@ async function runCLI() {
7384
7399
  }
7385
7400
  process.title = 'rsbuild-node';
7386
7401
  let { npm_execpath } = process.env;
7387
- (!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) && console.log(), __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.greet(` Rsbuild v1.3.19\n`);
7402
+ (!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) && console.log(), __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.greet(` Rsbuild v1.3.21\n`);
7388
7403
  try {
7389
7404
  !function() {
7390
7405
  let cli = cac_dist('rsbuild');
7391
- cli.help(), cli.version("1.3.19"), applyCommonOptions(cli);
7406
+ cli.help(), cli.version("1.3.21"), applyCommonOptions(cli);
7392
7407
  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');
7393
7408
  applyServerOptions(devCommand), applyServerOptions(previewCommand), devCommand.action(async (options)=>{
7394
7409
  try {
@@ -7439,6 +7454,6 @@ async function runCLI() {
7439
7454
  __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.error('Failed to start Rsbuild CLI.'), __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.error(err);
7440
7455
  }
7441
7456
  }
7442
- let src_version = "1.3.19";
7457
+ let src_version = "1.3.21";
7443
7458
  var __webpack_exports__logger = __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger, __webpack_exports__rspack = __WEBPACK_EXTERNAL_MODULE__rspack_core_e0096ff7__.rspack;
7444
7459
  export { PLUGIN_CSS_NAME, PLUGIN_SWC_NAME, createRsbuild, defaultAllowedOrigins, defineConfig, ensureAssetPrefix, config_loadConfig as loadConfig, loadEnv, mergeRsbuildConfig, runCLI, src_version as version, __webpack_exports__logger as logger, __webpack_exports__rspack as rspack };
@@ -1,4 +1,4 @@
1
- import type { InspectConfigOptions, InspectConfigResult, NormalizedConfig, PluginManager, PublicDir, PublicDirOptions, RsbuildConfig, RsbuildEntry } from './types';
1
+ import type { NormalizedConfig, PublicDir, PublicDirOptions, RsbuildConfig, RsbuildEntry } from './types';
2
2
  /**
3
3
  * Default allowed origins for CORS.
4
4
  * - localhost
@@ -81,32 +81,4 @@ export type LoadConfigResult = {
81
81
  };
82
82
  export type ConfigLoader = 'jiti' | 'native';
83
83
  export declare function loadConfig({ cwd, path, envMode, meta, loader, }?: LoadConfigOptions): Promise<LoadConfigResult>;
84
- export declare const getRsbuildInspectConfig: ({ normalizedConfig, inspectOptions, pluginManager, }: {
85
- normalizedConfig: NormalizedConfig;
86
- inspectOptions: InspectConfigOptions;
87
- pluginManager: PluginManager;
88
- }) => {
89
- rawRsbuildConfig: string;
90
- rsbuildConfig: InspectConfigResult["origin"]["rsbuildConfig"];
91
- rawEnvironmentConfigs: Array<{
92
- name: string;
93
- content: string;
94
- }>;
95
- environmentConfigs: InspectConfigResult["origin"]["environmentConfigs"];
96
- };
97
- export declare function outputInspectConfigFiles({ rawBundlerConfigs, rawEnvironmentConfigs, inspectOptions, configType, }: {
98
- configType: string;
99
- rawEnvironmentConfigs: Array<{
100
- name: string;
101
- content: string;
102
- }>;
103
- rawBundlerConfigs: Array<{
104
- name: string;
105
- content: string;
106
- }>;
107
- inspectOptions: InspectConfigOptions & {
108
- outputPath: string;
109
- };
110
- }): Promise<void>;
111
- export declare function stringifyConfig(config: unknown, verbose?: boolean): string;
112
84
  export declare const normalizePublicDirs: (publicDir?: PublicDir) => Required<PublicDirOptions>[];
@@ -5,7 +5,7 @@ export * from './fs';
5
5
  export * from './path';
6
6
  export * from './stats';
7
7
  export { color };
8
- export declare const rspackMinVersion = "1.0.0";
8
+ export declare const rspackMinVersion = "1.2.4";
9
9
  export declare const getNodeEnv: () => string;
10
10
  export declare const setNodeEnv: (env: string) => void;
11
11
  export declare const isNil: (o: unknown) => o is undefined | null;
@@ -14,6 +14,11 @@ export declare const isObject: (obj: unknown) => obj is Record<string, any>;
14
14
  export declare const isPlainObject: (obj: unknown) => obj is Record<string, any>;
15
15
  export declare const castArray: <T>(arr?: T | T[]) => T[];
16
16
  export declare const cloneDeep: <T>(value: T) => T;
17
+ /**
18
+ * If the application overrides the Rspack version to a lower one,
19
+ * we should check that the Rspack version is greater than the minimum
20
+ * supported version.
21
+ */
17
22
  export declare const isSatisfyRspackVersion: (originalVersion: string) => Promise<boolean>;
18
23
  export declare const removeLeadingSlash: (s: string) => string;
19
24
  export declare const removeTailingSlash: (s: string) => string;
@@ -42,3 +47,4 @@ export declare const prettyTime: (seconds: number) => string;
42
47
  */
43
48
  export declare const isTTY: (type?: "stdin" | "stdout") => boolean;
44
49
  export declare const addCompilationError: (compilation: Rspack.Compilation, message: string) => void;
50
+ export declare function hash(data: string): string;
@@ -1,5 +1,4 @@
1
- export declare function getAbsolutePath(base: string, filepath: string): string;
2
- export declare function getRelativePath(base: string, filepath: string): string;
1
+ export declare function toRelativePath(base: string, filepath: string): string;
3
2
  export declare function getCommonParentPath(paths: string[]): string;
4
3
  export declare const getCompiledPath: (packageName: string) => string;
5
4
  /**
@@ -9,7 +8,7 @@ export declare const getCompiledPath: (packageName: string) => string;
9
8
  * @returns Resolved absolute file path.
10
9
  */
11
10
  export declare const ensureAbsolutePath: (base: string, filePath: string) => string;
12
- export declare const pathnameParse: (publicPath: string) => string;
11
+ export declare const getPathnameFromUrl: (publicPath: string) => string;
13
12
  /** dedupe and remove nested paths */
14
13
  export declare const dedupeNestedPaths: (paths: string[]) => string[];
15
14
  /**
@@ -0,0 +1,35 @@
1
+ import type { InitConfigsOptions } from './provider/initConfigs';
2
+ import type { InspectConfigOptions, InspectConfigResult, NormalizedConfig, PluginManager, Rspack, WebpackConfig } from './types';
3
+ export declare const getRsbuildInspectConfig: ({ normalizedConfig, inspectOptions, pluginManager, }: {
4
+ normalizedConfig: NormalizedConfig;
5
+ inspectOptions: InspectConfigOptions;
6
+ pluginManager: PluginManager;
7
+ }) => {
8
+ rawRsbuildConfig: string;
9
+ rsbuildConfig: InspectConfigResult["origin"]["rsbuildConfig"];
10
+ rawEnvironmentConfigs: Array<{
11
+ name: string;
12
+ content: string;
13
+ }>;
14
+ environmentConfigs: InspectConfigResult["origin"]["environmentConfigs"];
15
+ };
16
+ export declare function outputInspectConfigFiles({ rawBundlerConfigs, rawEnvironmentConfigs, inspectOptions, configType, }: {
17
+ configType: string;
18
+ rawEnvironmentConfigs: Array<{
19
+ name: string;
20
+ content: string;
21
+ }>;
22
+ rawBundlerConfigs: Array<{
23
+ name: string;
24
+ content: string;
25
+ }>;
26
+ inspectOptions: InspectConfigOptions & {
27
+ outputPath: string;
28
+ };
29
+ }): Promise<void>;
30
+ export declare function stringifyConfig(config: unknown, verbose?: boolean): string;
31
+ export declare function inspectConfig<B extends 'rspack' | 'webpack' = 'rspack'>({ context, pluginManager, bundlerConfigs, inspectOptions, bundler, }: InitConfigsOptions & {
32
+ inspectOptions?: InspectConfigOptions;
33
+ bundlerConfigs: B extends 'rspack' ? Rspack.Configuration[] : WebpackConfig[];
34
+ bundler?: 'rspack' | 'webpack';
35
+ }): Promise<InspectConfigResult<B>>;
@@ -3,7 +3,7 @@
3
3
  */
4
4
  export { setCssExtractPlugin, setHTMLPlugin } from '../pluginHelper';
5
5
  export { initRsbuildConfig } from './initConfigs';
6
- export { stringifyConfig, getRsbuildInspectConfig, outputInspectConfigFiles, } from '../config';
6
+ export { inspectConfig } from '../inspectConfig';
7
7
  export { getHTMLPlugin } from '../pluginHelper';
8
8
  export { formatStats, getStatsOptions, prettyTime } from '../helpers';
9
9
  export { registerBuildHook, registerDevHook } from '../hooks';
@@ -4,6 +4,15 @@ export type InitConfigsOptions = {
4
4
  pluginManager: PluginManager;
5
5
  rsbuildOptions: ResolvedCreateRsbuildOptions;
6
6
  };
7
+ /**
8
+ * Initialize the Rsbuild config
9
+ * 1. Initialize the Rsbuild plugins
10
+ * 2. Run all the `modifyRsbuildConfig` hooks
11
+ * 3. Normalize the Rsbuild config, merge with the default config
12
+ * 4. Initialize the configs for each environment
13
+ * 5. Run all the `modifyEnvironmentConfig` hooks
14
+ * 6. Validate the final Rsbuild config
15
+ */
7
16
  export declare function initRsbuildConfig({ context, pluginManager, }: Pick<InitConfigsOptions, 'context' | 'pluginManager'>): Promise<NormalizedConfig>;
8
17
  export declare function initConfigs({ context, pluginManager, rsbuildOptions, }: InitConfigsOptions): Promise<{
9
18
  rspackConfigs: Rspack.Configuration[];
@@ -38,8 +38,8 @@ export type RsbuildDevServer = {
38
38
  */
39
39
  port: number;
40
40
  /**
41
- * Notify that the Rsbuild server has been started.
42
- * Rsbuild will trigger `onAfterStartDevServer` hook in this stage.
41
+ * Notifies Rsbuild that the custom server has successfully started.
42
+ * Rsbuild will trigger the `onAfterStartDevServer` hook at this stage.
43
43
  */
44
44
  afterListen: () => Promise<void>;
45
45
  /**