@rsbuild/core 1.1.5 → 1.1.7

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
@@ -1698,7 +1698,7 @@ function getFilename(config, type, isProd, isServer) {
1698
1698
  case 'assets':
1699
1699
  return filename.assets ?? `[name]${hash}[ext]`;
1700
1700
  default:
1701
- throw Error(`unknown key ${type} in "output.filename"`);
1701
+ throw Error(`[rsbuild:config] unknown key ${type} in "output.filename"`);
1702
1702
  }
1703
1703
  }
1704
1704
  let applyToCompiler = (compiler, apply)=>{
@@ -1720,7 +1720,7 @@ let camelCase = (input)=>input.replace(/[-_](\w)/g, (_, c)=>c.toUpperCase()), pr
1720
1720
  function loadEnv({ cwd = process.cwd(), mode = getNodeEnv(), prefixes = [
1721
1721
  'PUBLIC_'
1722
1722
  ] } = {}) {
1723
- if ('local' === mode) throw Error("'local' cannot be used as a value for env mode, because \".env.local\" represents a temporary local file. Please use another value.");
1723
+ 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.");
1724
1724
  let filePaths = [
1725
1725
  '.env',
1726
1726
  '.env.local',
@@ -2013,7 +2013,6 @@ let config_require = (0, __WEBPACK_EXTERNAL_MODULE_node_module__.createRequire)(
2013
2013
  '@swc/helpers': swcHelpersPath
2014
2014
  },
2015
2015
  define: {},
2016
- aliasStrategy: 'prefer-tsconfig',
2017
2016
  preEntry: [],
2018
2017
  decorators: {
2019
2018
  version: '2022-03'
@@ -2095,10 +2094,14 @@ let config_require = (0, __WEBPACK_EXTERNAL_MODULE_node_module__.createRequire)(
2095
2094
  exportLocalsConvention: 'camelCase'
2096
2095
  },
2097
2096
  emitAssets: !0
2097
+ }), getDefaultResolveConfig = ()=>({
2098
+ alias: {},
2099
+ aliasStrategy: 'prefer-tsconfig'
2098
2100
  }), createDefaultConfig = ()=>({
2099
2101
  dev: getDefaultDevConfig(),
2100
2102
  server: getDefaultServerConfig(),
2101
2103
  html: getDefaultHtmlConfig(),
2104
+ resolve: getDefaultResolveConfig(),
2102
2105
  source: getDefaultSourceConfig(),
2103
2106
  output: getDefaultOutputConfig(),
2104
2107
  tools: getDefaultToolsConfig(),
@@ -2200,13 +2203,13 @@ async function config_loadConfig({ cwd = process.cwd(), path, envMode, meta } =
2200
2203
  envMode: envMode || nodeEnv,
2201
2204
  meta
2202
2205
  });
2203
- if (void 0 === result) throw Error('The config function must return a config object.');
2206
+ if (void 0 === result) throw Error('[rsbuild:loadConfig] The config function must return a config object.');
2204
2207
  return {
2205
2208
  content: applyMetaInfo(result),
2206
2209
  filePath: configFilePath
2207
2210
  };
2208
2211
  }
2209
- if (!isObject(configExport)) throw Error(`The config must be an object or a function that returns an object, get ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js__.default.yellow(configExport)}`);
2212
+ if (!isObject(configExport)) throw Error(`[rsbuild:loadConfig] The config must be an object or a function that returns an object, get ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js__.default.yellow(configExport)}`);
2210
2213
  return {
2211
2214
  content: applyMetaInfo(configExport),
2212
2215
  filePath: configFilePath
@@ -2299,7 +2302,7 @@ let normalizePublicDirs = (publicDir)=>{
2299
2302
  let allLines = [];
2300
2303
  function getPlugin(name) {
2301
2304
  let targets = plugins.filter((item)=>item.instance.name === name);
2302
- if (!targets.length) throw Error(`plugin ${name} not existed`);
2305
+ if (!targets.length) throw Error(`[rsbuild:plugin] Plugin "${name}" not existed`);
2303
2306
  return targets;
2304
2307
  }
2305
2308
  for (let plugin of plugins){
@@ -2320,7 +2323,7 @@ let normalizePublicDirs = (publicDir)=>{
2320
2323
  if (allLines.length) {
2321
2324
  let restInRingPoints = {};
2322
2325
  for (let l of allLines)restInRingPoints[l[0]] = !0, restInRingPoints[l[1]] = !0;
2323
- throw Error(`plugins dependencies has loop: ${Object.keys(restInRingPoints).join(',')}`);
2326
+ throw Error(`[rsbuild:plugin] Plugins dependencies has loop: ${Object.keys(restInRingPoints).join(',')}`);
2324
2327
  }
2325
2328
  return sortedPoint;
2326
2329
  };
@@ -2547,7 +2550,7 @@ let onBeforeCompile = ({ compiler, beforeCompile, beforeEnvironmentCompiler, isW
2547
2550
  case 'report':
2548
2551
  return Compilation.PROCESS_ASSETS_STAGE_REPORT;
2549
2552
  default:
2550
- throw Error(`Invalid process assets stage: ${stage}`);
2553
+ throw Error(`[rsbuild] Invalid process assets stage: ${stage}`);
2551
2554
  }
2552
2555
  }, browsersListCache = new Map();
2553
2556
  async function getBrowserslist(path) {
@@ -2631,7 +2634,7 @@ async function updateEnvironmentContext(context, configs) {
2631
2634
  async function createContext(options, userConfig, bundlerType) {
2632
2635
  let { cwd } = options, rootPath = userConfig.root ? getAbsolutePath(cwd, userConfig.root) : cwd, rsbuildConfig = await withDefaultConfig(rootPath, userConfig), cachePath = (0, external_node_path_.join)(rootPath, 'node_modules', '.cache');
2633
2636
  return {
2634
- version: "1.1.5",
2637
+ version: "1.1.7",
2635
2638
  rootPath,
2636
2639
  distPath: '',
2637
2640
  cachePath,
@@ -2639,6 +2642,7 @@ async function createContext(options, userConfig, bundlerType) {
2639
2642
  environments: {},
2640
2643
  hooks: {
2641
2644
  onExit: createAsyncHook(),
2645
+ onCloseBuild: createAsyncHook(),
2642
2646
  onAfterBuild: createAsyncHook(),
2643
2647
  onBeforeBuild: createAsyncHook(),
2644
2648
  onDevCompileDone: createAsyncHook(),
@@ -2825,6 +2829,9 @@ let pluginAppIcon = ()=>({
2825
2829
  infrastructureLogging: {
2826
2830
  level: 'error'
2827
2831
  }
2832
+ }), chain.watchOptions({
2833
+ ignored: /[\\/](?:\.git|node_modules)[\\/]/,
2834
+ aggregateTimeout: 0
2828
2835
  }), chain.performance.hints(!1), chain.module.parser.merge({
2829
2836
  javascript: {
2830
2837
  exportsPresence: 'error'
@@ -3010,7 +3017,7 @@ let isPostcssPluginCreator = (plugin)=>'function' == typeof plugin && !0 === plu
3010
3017
  if ('function' == typeof postcssOptions) {
3011
3018
  let postcssOptionsWrapper = (loaderContext)=>{
3012
3019
  let options = postcssOptions(loaderContext);
3013
- if ('object' != typeof options || null === options) throw Error(`\`postcssOptions\` function must return a PostCSSOptions object, got "${typeof options}".`);
3020
+ if ('object' != typeof options || null === options) throw Error(`[rsbuild:css] \`postcssOptions\` function must return a PostCSSOptions object, got "${typeof options}".`);
3014
3021
  return updatePostcssOptions({
3015
3022
  ...userOptions,
3016
3023
  ...options,
@@ -3129,7 +3136,7 @@ let isPostcssPluginCreator = (plugin)=>'function' == typeof plugin && !0 === plu
3129
3136
  preEntry.forEach(addEntry), injectCoreJsEntry && addEntry(createVirtualModule('import "core-js";')), castArray(entry[entryName]).forEach(addEntry);
3130
3137
  }
3131
3138
  }), api.onBeforeCreateCompiler(({ bundlerConfigs })=>{
3132
- if (bundlerConfigs.every((config)=>!config.entry)) throw Error(`Could not find any entry module, please make sure that ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js__.default.cyan('src/index.(ts|js|tsx|jsx|mjs|cjs)')} exists, or customize entry through the ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js__.default.cyan('source.entry')} configuration.`);
3139
+ if (bundlerConfigs.every((config)=>!config.entry)) throw Error(`[rsbuild:config] Could not find any entry module, please make sure that ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js__.default.cyan('src/index.(ts|js|tsx|jsx|mjs|cjs)')} exists, or customize entry through the ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js__.default.cyan('source.entry')} configuration.`);
3133
3140
  });
3134
3141
  }
3135
3142
  }), fileSize_gzip = (0, __WEBPACK_EXTERNAL_MODULE_node_util__.promisify)(__WEBPACK_EXTERNAL_MODULE_node_zlib__.default.gzip);
@@ -3203,7 +3210,7 @@ async function printFileSizes(options, stats, rootPath, environmentName) {
3203
3210
  gzipSizeLabel && (log += ` ${gzipSizeLabel}`), logs.push(log);
3204
3211
  }
3205
3212
  }
3206
- if (!1 !== options.total) {
3213
+ if (!1 !== options.total && assets.length > 1) {
3207
3214
  let totalSizeLabel = `${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js__.default.blue('Total:')} ${calcFileSize(totalSize)}`, log = `\n ${totalSizeLabel}`;
3208
3215
  options.compressed && (log += __WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js__.default.dim(` (gzip: ${calcFileSize(totalGzipSize)})`)), log += '\n', logs.push(log);
3209
3216
  }
@@ -3223,7 +3230,7 @@ let pluginFileSize = ()=>({
3223
3230
  ], defaultConfig = {
3224
3231
  total: !0,
3225
3232
  detail: !0,
3226
- compressed: !0
3233
+ compressed: 'node' !== environment.config.output.target
3227
3234
  }, mergedConfig = !0 === printFileSize ? defaultConfig : {
3228
3235
  ...defaultConfig,
3229
3236
  ...printFileSize
@@ -3343,9 +3350,9 @@ class RsbuildHtmlPlugin {
3343
3350
  let emitFavicon = async (compilation, favicon)=>{
3344
3351
  let name = external_node_path_.default.basename(favicon);
3345
3352
  if (compilation.assets[name]) return name;
3346
- if (!compilation.inputFileSystem) throw Error("[RsbuildHtmlPlugin] 'compilation.inputFileSystem' is not available.");
3353
+ if (!compilation.inputFileSystem) throw Error("[rsbuild:html] 'compilation.inputFileSystem' is not available.");
3347
3354
  let filename = external_node_path_.default.resolve(compilation.compiler.context, favicon), buf = await (0, __WEBPACK_EXTERNAL_MODULE_node_util__.promisify)(compilation.inputFileSystem.readFile)(filename);
3348
- if (!buf) throw Error(`[RsbuildHtmlPlugin] Failed to read the favicon, please check if the '${filename}' file exists'.`);
3355
+ if (!buf) throw Error(`[rsbuild:html] Failed to read the favicon, please check if the '${filename}' file exists'.`);
3349
3356
  let source = new compiler.webpack.sources.RawSource(buf, !1);
3350
3357
  return compilation.emitAsset(name, source), name;
3351
3358
  }, addFavicon = async (headTags, favicon, compilation, publicPath)=>{
@@ -3405,7 +3412,7 @@ async function getTemplate(entryName, config, rootPath) {
3405
3412
  };
3406
3413
  let absolutePath = (0, external_node_path_.isAbsolute)(templatePath) ? templatePath : external_node_path_.default.resolve(rootPath, templatePath);
3407
3414
  if (!existTemplatePath.has(absolutePath)) {
3408
- if (!await isFileExists(absolutePath)) throw Error(`Failed to resolve HTML template, please check if the file exists: ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js__.default.cyan(absolutePath)}`);
3415
+ if (!await isFileExists(absolutePath)) throw Error(`[rsbuild:html] Failed to resolve HTML template, please check if the file exists: ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js__.default.cyan(absolutePath)}`);
3409
3416
  existTemplatePath.add(absolutePath);
3410
3417
  }
3411
3418
  let templateContent = await external_node_fs_.default.promises.readFile(absolutePath, 'utf-8');
@@ -3707,13 +3714,14 @@ let generateManifest = (htmlPaths)=>(_seed, files)=>{
3707
3714
  }, pluginManifest = ()=>({
3708
3715
  name: 'rsbuild:manifest',
3709
3716
  setup (api) {
3710
- api.modifyBundlerChain(async (chain, { CHAIN_ID, environment })=>{
3711
- let { output: { manifest } } = environment.config;
3717
+ api.modifyBundlerChain(async (chain, { CHAIN_ID, environment, isDev })=>{
3718
+ let { output: { manifest }, dev: { writeToDisk } } = environment.config;
3712
3719
  if (!1 === manifest) return;
3713
3720
  let { RspackManifestPlugin } = await import("../compiled/rspack-manifest-plugin/index.js"), { htmlPaths } = environment;
3714
3721
  chain.plugin(CHAIN_ID.PLUGIN.MANIFEST).use(RspackManifestPlugin, [
3715
3722
  {
3716
3723
  fileName: 'string' == typeof manifest ? manifest : 'manifest.json',
3724
+ writeToFileEmit: isDev && !0 !== writeToDisk,
3717
3725
  generate: generateManifest(htmlPaths)
3718
3726
  }
3719
3727
  ]);
@@ -3845,7 +3853,7 @@ let pluginMoment = ()=>({
3845
3853
  raw: !0
3846
3854
  }, ({ code, emitFile, resourcePath })=>{
3847
3855
  let name = nodeAddons_getFilename(resourcePath);
3848
- if (null === name) throw Error(`Failed to load Node.js addon: "${resourcePath}"`);
3856
+ if (null === name) throw Error(`[rsbuild:node-addons] Failed to load Node.js addon: "${resourcePath}"`);
3849
3857
  return emitFile(name, code), `
3850
3858
  try {
3851
3859
  const path = require("path");
@@ -3921,7 +3929,7 @@ function printServerURLs({ urls: originalUrls, port, routes, protocol, printUrls
3921
3929
  protocol
3922
3930
  });
3923
3931
  if (!newUrls) return null;
3924
- if (!Array.isArray(newUrls)) throw Error(`"server.printUrls" must return an array, but got ${typeof newUrls}.`);
3932
+ if (!Array.isArray(newUrls)) throw Error(`[rsbuild:config] "server.printUrls" must return an array, but got ${typeof newUrls}.`);
3925
3933
  urls = newUrls.map((url)=>({
3926
3934
  url,
3927
3935
  label: getUrlLabel(url)
@@ -3960,7 +3968,7 @@ let getPort = async ({ host, port, strictPort, tryLimits = 20 })=>{
3960
3968
  if ('EADDRINUSE' !== e.code) throw e;
3961
3969
  port++, attempts++;
3962
3970
  }
3963
- if (port !== original && strictPort) throw Error(`Port "${original}" is occupied, please choose another one.`);
3971
+ if (port !== original && strictPort) throw Error(`[rsbuild:server] Port "${original}" is occupied, please choose another one.`);
3964
3972
  return port;
3965
3973
  }, getServerConfig = async ({ config })=>{
3966
3974
  let host = config.server.host || DEFAULT_DEV_HOST, originalPort = config.server.port || 3000, port = await getPort({
@@ -4201,7 +4209,7 @@ let getJsAsyncPath = (jsPath, isServer, jsAsync)=>void 0 !== jsAsync ? jsAsync :
4201
4209
  ]);
4202
4210
  });
4203
4211
  }
4204
- }), pluginResolve = ()=>({
4212
+ }), resolve_require = (0, __WEBPACK_EXTERNAL_MODULE_node_module__.createRequire)(import.meta.url), pluginResolve = ()=>({
4205
4213
  name: 'rsbuild:resolve',
4206
4214
  setup (api) {
4207
4215
  api.modifyBundlerChain({
@@ -4231,12 +4239,43 @@ let getJsAsyncPath = (jsPath, isServer, jsAsync)=>void 0 !== jsAsync ? jsAsync :
4231
4239
  chain,
4232
4240
  tsconfigPath
4233
4241
  }), !function({ chain, config, rootPath }) {
4234
- let { alias } = config.source;
4235
- if (!alias) return;
4236
- let mergedAlias = reduceConfigs({
4242
+ let mergedSourceAlias = config.source.alias ? reduceConfigs({
4237
4243
  initial: {},
4238
- config: alias
4239
- });
4244
+ config: config.source.alias
4245
+ }) : {}, mergedResolveAlias = config.resolve.alias ? reduceConfigs({
4246
+ initial: {},
4247
+ config: config.resolve.alias
4248
+ }) : {}, mergedAlias = {
4249
+ ...mergedSourceAlias,
4250
+ ...mergedResolveAlias
4251
+ };
4252
+ if (config.resolve.dedupe) for (let pkgName of config.resolve.dedupe){
4253
+ let pkgPath;
4254
+ if (mergedAlias[pkgName]) {
4255
+ __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.debug(`[rsbuild:resolve] The package "${pkgName}" is already in the alias config, dedupe option for "${pkgName}" will be ignored.`);
4256
+ continue;
4257
+ }
4258
+ try {
4259
+ pkgPath = (0, external_node_path_.dirname)(resolve_require.resolve(`${pkgName}/package.json`, {
4260
+ paths: [
4261
+ rootPath
4262
+ ]
4263
+ }));
4264
+ } catch (e) {}
4265
+ if (!pkgPath) try {
4266
+ pkgPath = resolve_require.resolve(pkgName, {
4267
+ paths: [
4268
+ rootPath
4269
+ ]
4270
+ });
4271
+ let trailing = '/' === external_node_path_.sep ? pkgName : pkgName.split('/').join(external_node_path_.sep);
4272
+ for(; !pkgPath.endsWith(trailing) && pkgPath.includes('node_modules');)pkgPath = (0, external_node_path_.dirname)(pkgPath);
4273
+ } catch (e) {
4274
+ __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.debug(`[rsbuild:resolve] The package "${pkgName}" is not resolved in the project, dedupe option for "${pkgName}" will be ignored.`);
4275
+ continue;
4276
+ }
4277
+ mergedAlias[pkgName] = pkgPath;
4278
+ }
4240
4279
  for (let name of Object.keys(mergedAlias)){
4241
4280
  let formattedValues = castArray(mergedAlias[name]).map((value)=>'string' == typeof value && value.startsWith('.') ? ensureAbsolutePath(rootPath, value) : value);
4242
4281
  chain.resolve.alias.set(name, 1 === formattedValues.length ? formattedValues[0] : formattedValues);
@@ -4251,7 +4290,9 @@ let getJsAsyncPath = (jsPath, isServer, jsAsync)=>void 0 !== jsAsync ? jsAsync :
4251
4290
  chain,
4252
4291
  config,
4253
4292
  CHAIN_ID
4254
- }), tsconfigPath && 'rspack' === api.context.bundlerType && 'prefer-tsconfig' === config.source.aliasStrategy && chain.resolve.tsConfig({
4293
+ });
4294
+ let aliasStrategy = config.source.aliasStrategy ?? config.resolve.aliasStrategy;
4295
+ tsconfigPath && 'rspack' === api.context.bundlerType && 'prefer-tsconfig' === aliasStrategy && chain.resolve.tsConfig({
4255
4296
  configFile: tsconfigPath,
4256
4297
  references: 'auto'
4257
4298
  });
@@ -4778,7 +4819,7 @@ let resourceHints_generateLinks = (options, rel)=>options.map((option)=>({
4778
4819
  swcConfig.jsc.transform.legacyDecorator = !1, swcConfig.jsc.transform.decoratorVersion = '2022-03';
4779
4820
  break;
4780
4821
  default:
4781
- throw Error(`Unknown decorators version: ${version}`);
4822
+ throw Error(`[rsbuild:swc] Unknown decorators version: ${version}`);
4782
4823
  }
4783
4824
  }(swcConfig, config), castArray(target1 = target).includes('web') || target1.includes('web-worker')) {
4784
4825
  let polyfillMode = config.output.polyfill;
@@ -5080,7 +5121,7 @@ async function generateRspackConfig({ target, context, environment }) {
5080
5121
  if ((rspackConfig = await modifyRspackConfig(context, rspackConfig, await getConfigUtils(rspackConfig, chainUtils))).plugins) {
5081
5122
  for (let plugin of rspackConfig.plugins)if (plugin && void 0 === plugin.apply && 'name' in plugin && 'setup' in plugin) {
5082
5123
  let name = __WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js__.default.bold(__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js__.default.yellow(plugin.name));
5083
- throw Error(`${name} appears to be an Rsbuild plugin. It cannot be used as an Rspack plugin.`);
5124
+ throw Error(`[rsbuild:plugin] "${name}" appears to be an Rsbuild plugin. It cannot be used as an Rspack plugin.`);
5084
5125
  }
5085
5126
  }
5086
5127
  return rspackConfig;
@@ -5141,11 +5182,11 @@ let initEnvironmentConfigs = (normalizedConfig, rootPath, specifiedEnvironments)
5141
5182
  }, config)
5142
5183
  })
5143
5184
  ]));
5144
- if (!Object.keys(resolvedEnvironments).length) throw Error(`The current build is specified to run only in the ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js__.default.yellow(null == specifiedEnvironments ? void 0 : specifiedEnvironments.join(','))} environment, but the configuration of the specified environment was not found.`);
5185
+ if (!Object.keys(resolvedEnvironments).length) throw Error(`[rsbuild:config] The current build is specified to run only in the ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js__.default.yellow(null == specifiedEnvironments ? void 0 : specifiedEnvironments.join(','))} environment, but the configuration of the specified environment was not found.`);
5145
5186
  return resolvedEnvironments;
5146
5187
  }
5147
5188
  let defaultEnvironmentName = camelCase(rsbuildSharedConfig.output.target);
5148
- if (!isEnvironmentEnabled(defaultEnvironmentName)) throw Error(`The current build is specified to run only in the ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js__.default.yellow(null == specifiedEnvironments ? void 0 : specifiedEnvironments.join(','))} environment, but the configuration of the specified environment was not found.`);
5189
+ if (!isEnvironmentEnabled(defaultEnvironmentName)) throw Error(`[rsbuild:config] The current build is specified to run only in the ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js__.default.yellow(null == specifiedEnvironments ? void 0 : specifiedEnvironments.join(','))} environment, but the configuration of the specified environment was not found.`);
5149
5190
  return {
5150
5191
  [defaultEnvironmentName]: applyEnvironmentDefaultConfig({
5151
5192
  ...rsbuildSharedConfig,
@@ -5264,7 +5305,7 @@ function setupCliShortcuts({ help = !0, openPage, closeServer, printUrls, restar
5264
5305
  action: printUrls
5265
5306
  }
5266
5307
  ].filter(Boolean);
5267
- if (customShortcuts && !Array.isArray(shortcuts = customShortcuts(shortcuts))) throw Error('`dev.cliShortcuts` must return an array of shortcuts.');
5308
+ if (customShortcuts && !Array.isArray(shortcuts = customShortcuts(shortcuts))) throw Error('[rsbuild:config] `dev.cliShortcuts` must return an array of shortcuts.');
5268
5309
  help && __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.log(` ➜ ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js__.default.dim('press')} ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js__.default.bold('h + enter')} ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js__.default.dim('to show shortcuts')}\n`);
5269
5310
  let rl = __WEBPACK_EXTERNAL_MODULE_node_readline__.default.createInterface({
5270
5311
  input: process.stdin
@@ -5588,7 +5629,7 @@ class BasicRunner {
5588
5629
  postExecute(_m, _file) {}
5589
5630
  createRunner() {
5590
5631
  this.requirers.set('entry', (_currentDirectory, _modulePath, _context = {})=>{
5591
- throw Error('Not implement');
5632
+ throw Error('[rsbuild:runner] Not implement');
5592
5633
  });
5593
5634
  }
5594
5635
  constructor(_options){
@@ -5675,7 +5716,7 @@ class EsmRunner extends CommonJsRunner {
5675
5716
  name: 'context for esm'
5676
5717
  }), esmCache = new Map(), esmIdentifier = this._options.name;
5677
5718
  return (currentDirectory, modulePath, context = {})=>{
5678
- if (!__WEBPACK_EXTERNAL_MODULE_node_vm__.default.SourceTextModule) throw Error("Running esm bundle needs add Node.js option '--experimental-vm-modules'.");
5719
+ if (!__WEBPACK_EXTERNAL_MODULE_node_vm__.default.SourceTextModule) throw Error('[rsbuild:runner] Running ESM bundle needs add Node.js option "--experimental-vm-modules".');
5679
5720
  let _require = this.getRequire(), file = context.file || this.getFile(modulePath, currentDirectory);
5680
5721
  if (!file) return this.requirers.get('miss')(currentDirectory, modulePath);
5681
5722
  let esm = esmCache.get(file.path);
@@ -5713,7 +5754,7 @@ class BasicRunnerFactory {
5713
5754
  compilerOptions,
5714
5755
  readFileSync
5715
5756
  };
5716
- if ('web' === compilerOptions.target || 'webworker' === compilerOptions.target) throw Error(`not support run ${compilerOptions.target} resource in rsbuild server`);
5757
+ if ('web' === compilerOptions.target || 'webworker' === compilerOptions.target) throw Error(`[rsbuild:runner] Not support run "${compilerOptions.target}" resource in Rsbuild server`);
5717
5758
  return new EsmRunner(runnerOptions);
5718
5759
  }
5719
5760
  constructor(name){
@@ -5733,7 +5774,7 @@ let run = async (bundlePath, outputPath, compilerOptions, readFileSync)=>new Bas
5733
5774
  entrypoints: !0,
5734
5775
  outputPath: !0
5735
5776
  });
5736
- if (!(null == entrypoints ? void 0 : entrypoints[entryName])) throw Error(`can't find entry(${entryName})`);
5777
+ if (!(null == entrypoints ? void 0 : entrypoints[entryName])) throw Error(`[rsbuild:loadBundle] Can't find entry: "${entryName}"`);
5737
5778
  let { chunks: entryChunks = [] } = entrypoints[entryName], files = entryChunks.reduce((prev, entryChunkName)=>{
5738
5779
  let chunk = null == chunks ? void 0 : chunks.find((chunk)=>{
5739
5780
  var _chunk_names;
@@ -5741,12 +5782,12 @@ let run = async (bundlePath, outputPath, compilerOptions, readFileSync)=>new Bas
5741
5782
  });
5742
5783
  return (null == chunk ? void 0 : chunk.files) ? prev.concat(chunk.files.filter((file)=>!file.endsWith('.css'))) : prev;
5743
5784
  }, []);
5744
- if (0 === files.length) throw Error(`can't get bundle by entryName(${entryName})`);
5745
- if (files.length > 1) throw Error(`only support load single entry chunk, but got ${files.length}: ${files.join(',')}`);
5785
+ if (0 === files.length) throw Error(`[rsbuild:loadBundle] Failed to get bundle by entryName: "${entryName}"`);
5786
+ if (files.length > 1) throw Error(`[rsbuild:loadBundle] Only support load single entry chunk, but got ${files.length}: ${files.join(',')}`);
5746
5787
  return await run(files[0], outputPath, stats.compilation.options, utils.readFileSync);
5747
5788
  }, getTransformedHtml = async (entryName, utils)=>{
5748
5789
  let { htmlPaths, distPath } = utils.environment, htmlPath = htmlPaths[entryName];
5749
- if (!htmlPath) throw Error(`can't get html file by entryName(${entryName})`);
5790
+ if (!htmlPath) throw Error(`[rsbuild:getTransformedHtml] Failed to get HTML file by entryName: "${entryName}"`);
5750
5791
  let fileName = (0, external_node_path_.join)(distPath, htmlPath);
5751
5792
  return utils.readFileSync(fileName);
5752
5793
  }, ENCODING_REGEX = /\bgzip\b/, CONTENT_TYPE_REGEX = /text|javascript|\/json|xml/i, shouldCompress = (res)=>{
@@ -6056,7 +6097,7 @@ async function devServer_createDevServer(options, createCompiler, config, { comp
6056
6097
  });
6057
6098
  }) : Promise.resolve(), startCompile = async ()=>{
6058
6099
  let compiler = customCompiler || await createCompiler();
6059
- if (!compiler) throw Error('Failed to get compiler instance.');
6100
+ if (!compiler) throw Error('[rsbuild:server] Failed to get compiler instance.');
6060
6101
  let publicPaths = isMultiCompiler(compiler) ? compiler.compilers.map(getPublicPathFromCompiler) : [
6061
6102
  getPublicPathFromCompiler(compiler)
6062
6103
  ], compilerDevMiddleware = new CompilerDevMiddleware({
@@ -6124,7 +6165,7 @@ async function devServer_createDevServer(options, createCompiler, config, { comp
6124
6165
  name,
6125
6166
  {
6126
6167
  getStats: async ()=>{
6127
- if (!runCompile) throw Error("can't get stats info when runCompile is false");
6168
+ if (!runCompile) throw Error('[rsbuild:server] Can not get stats info when "runCompile" is false');
6128
6169
  return await waitFirstCompileDone, lastStats[environment.index];
6129
6170
  },
6130
6171
  loadBundle: async (entryName)=>(await waitFirstCompileDone, loadBundle(lastStats[environment.index], entryName, {
@@ -6196,7 +6237,7 @@ async function createCompiler_createCompiler(options) {
6196
6237
  if (await context.hooks.onBeforeCreateCompiler.call({
6197
6238
  bundlerConfigs: rspackConfigs,
6198
6239
  environments: context.environments
6199
- }), !await isSatisfyRspackVersion(__WEBPACK_EXTERNAL_MODULE__rspack_core__.rspack.rspackVersion)) throw Error(`The current Rspack version does not meet the requirements, the minimum supported version of Rspack is ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js__.default.green(rspackMinVersion)}`);
6240
+ }), !await isSatisfyRspackVersion(__WEBPACK_EXTERNAL_MODULE__rspack_core__.rspack.rspackVersion)) throw Error(`[rsbuild] The current Rspack version does not meet the requirements, the minimum supported version of Rspack is ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js__.default.green(rspackMinVersion)}`);
6200
6241
  let compiler = 1 === rspackConfigs.length ? (0, __WEBPACK_EXTERNAL_MODULE__rspack_core__.rspack)(rspackConfigs[0]) : (0, __WEBPACK_EXTERNAL_MODULE__rspack_core__.rspack)(rspackConfigs), isVersionLogged = !1, isCompiling = !1, logRspackVersion = ()=>{
6201
6242
  !isVersionLogged && (__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.debug(`Use Rspack v${__WEBPACK_EXTERNAL_MODULE__rspack_core__.rspack.rspackVersion}`), isVersionLogged = !0);
6202
6243
  };
@@ -6274,11 +6315,7 @@ let build_build = async (initOptions, { watch, compiler: customCompiler } = {})=
6274
6315
  });
6275
6316
  return {
6276
6317
  stats,
6277
- close: ()=>new Promise((resolve)=>{
6278
- compiler.close(()=>{
6279
- resolve();
6280
- });
6281
- })
6318
+ close: async ()=>{}
6282
6319
  };
6283
6320
  }, rspackProvider = async ({ context, pluginManager, rsbuildOptions })=>{
6284
6321
  let createCompiler = async ()=>(await createCompiler_createCompiler({
@@ -6576,7 +6613,7 @@ async function createRsbuild(options = {}) {
6576
6613
  for (let newPlugin of newPlugins){
6577
6614
  if (!!newPlugin) if (!function(plugin) {
6578
6615
  let type = typeof plugin;
6579
- if ('object' !== type || null === plugin) throw Error(`Expect Rsbuild plugin instance to be an object, but got ${type}.`);
6616
+ if ('object' !== type || null === plugin) throw Error(`[rsbuild:plugin] Expect Rsbuild plugin instance to be an object, but got ${type}.`);
6580
6617
  if (!isFunction(plugin.setup)) {
6581
6618
  if (isFunction(plugin.apply)) {
6582
6619
  let { name = 'SomeWebpackPlugin' } = plugin.constructor || {};
@@ -6594,7 +6631,7 @@ async function createRsbuild(options = {}) {
6594
6631
  `)
6595
6632
  ].join('\n'));
6596
6633
  }
6597
- throw Error(`Expect Rsbuild plugin.setup to be a function, but got ${type}.`);
6634
+ throw Error(`[rsbuild:plugin] Expect the setup function of Rsbuild plugin to be a function, but got ${type}.`);
6598
6635
  }
6599
6636
  }(newPlugin), before) {
6600
6637
  let index = plugins.findIndex((item)=>item.instance.name === before);
@@ -6638,12 +6675,12 @@ async function createRsbuild(options = {}) {
6638
6675
  if (context.normalizedConfig) {
6639
6676
  if (null == options ? void 0 : options.environment) {
6640
6677
  let config = context.normalizedConfig.environments[options.environment];
6641
- if (!config) throw Error(`Cannot find normalized config by environment: ${options.environment}.`);
6678
+ if (!config) throw Error(`[rsbuild] Cannot find normalized config by environment: ${options.environment}.`);
6642
6679
  return config;
6643
6680
  }
6644
6681
  return context.normalizedConfig;
6645
6682
  }
6646
- throw Error('Cannot access normalized config until modifyRsbuildConfig is called.');
6683
+ throw Error('[rsbuild] Cannot access normalized config until modifyRsbuildConfig is called.');
6647
6684
  }
6648
6685
  let getRsbuildConfig = (type = 'current')=>{
6649
6686
  switch(type){
@@ -6654,7 +6691,7 @@ async function createRsbuild(options = {}) {
6654
6691
  case 'normalized':
6655
6692
  return getNormalizedConfig();
6656
6693
  }
6657
- throw Error('`getRsbuildConfig` get an invalid type param.');
6694
+ throw Error('[rsbuild] `getRsbuildConfig` get an invalid type param.');
6658
6695
  }, exposed = [], expose = (id, api)=>{
6659
6696
  exposed.push({
6660
6697
  id,
@@ -6744,6 +6781,7 @@ async function createRsbuild(options = {}) {
6744
6781
  isPluginExists: pluginManager.isPluginExists,
6745
6782
  onExit,
6746
6783
  onAfterBuild: hooks.onAfterBuild.tap,
6784
+ onCloseBuild: hooks.onCloseBuild.tap,
6747
6785
  onBeforeBuild: hooks.onBeforeBuild.tap,
6748
6786
  onCloseDevServer: hooks.onCloseDevServer.tap,
6749
6787
  onDevCompileDone: hooks.onDevCompileDone.tap,
@@ -6806,15 +6844,24 @@ async function createRsbuild(options = {}) {
6806
6844
  pluginManager
6807
6845
  }), { distPath } = context, { checkDistDir = !0 } = options;
6808
6846
  if (checkDistDir) {
6809
- if (!(0, external_node_fs_.existsSync)(distPath)) throw Error(`The output directory ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js__.default.yellow(distPath)} does not exist, please build the project before previewing.`);
6847
+ if (!(0, external_node_fs_.existsSync)(distPath)) throw Error(`[rsbuild:preview] The output directory ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js__.default.yellow(distPath)} does not exist, please build the project before previewing.`);
6810
6848
  if (function(path) {
6811
6849
  let files = external_node_fs_.default.readdirSync(path);
6812
6850
  return 0 === files.length || 1 === files.length && '.git' === files[0];
6813
- }(distPath)) throw Error(`The output directory ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js__.default.yellow(distPath)} is empty, please build the project before previewing.`);
6851
+ }(distPath)) throw Error(`[rsbuild:preview] The output directory ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js__.default.yellow(distPath)} is empty, please build the project before previewing.`);
6814
6852
  }
6815
6853
  return startProdServer(context, config, options);
6854
+ }, build = async (...args)=>{
6855
+ !getNodeEnv() && setNodeEnv('production');
6856
+ let buildInstance = await providerInstance.build(...args);
6857
+ return {
6858
+ ...buildInstance,
6859
+ close: async ()=>{
6860
+ await context.hooks.onCloseBuild.call(), await buildInstance.close();
6861
+ }
6862
+ };
6816
6863
  }, rsbuild = {
6817
- build: (...args)=>(!getNodeEnv() && setNodeEnv('production'), providerInstance.build(...args)),
6864
+ build,
6818
6865
  preview,
6819
6866
  startDevServer: (...args)=>(!getNodeEnv() && setNodeEnv('development'), providerInstance.startDevServer(...args)),
6820
6867
  createDevServer: (...args)=>(!getNodeEnv() && setNodeEnv('development'), providerInstance.createDevServer(...args)),
@@ -6826,6 +6873,7 @@ async function createRsbuild(options = {}) {
6826
6873
  ]),
6827
6874
  ...pick(globalPluginAPI, [
6828
6875
  'context',
6876
+ 'onCloseBuild',
6829
6877
  'onBeforeBuild',
6830
6878
  'onBeforeCreateCompiler',
6831
6879
  'onBeforeStartDevServer',
@@ -6880,13 +6928,13 @@ async function runCLI() {
6880
6928
  'preview'
6881
6929
  ].includes(command) ? 'production' : 'development';
6882
6930
  }
6883
- }();
6931
+ }(), process.title = 'rsbuild-node';
6884
6932
  let { npm_execpath } = process.env;
6885
- (!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) && console.log(), __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.greet(` Rsbuild v1.1.5\n`);
6933
+ (!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) && console.log(), __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.greet(` Rsbuild v1.1.7\n`);
6886
6934
  }();
6887
6935
  try {
6888
6936
  !function() {
6889
- program.name('rsbuild').usage('<command> [options]').version("1.1.5");
6937
+ program.name('rsbuild').usage('<command> [options]').version("1.1.7");
6890
6938
  let devCommand = program.command('dev'), buildCommand = program.command('build'), previewCommand = program.command('preview'), inspectCommand = program.command('inspect');
6891
6939
  [
6892
6940
  devCommand,
@@ -6913,7 +6961,7 @@ async function runCLI() {
6913
6961
  }), buildInstance = await (null == rsbuild ? void 0 : rsbuild.build({
6914
6962
  watch: options.watch
6915
6963
  }));
6916
- options.watch && buildInstance && onBeforeRestartServer(buildInstance.close);
6964
+ buildInstance && (options.watch ? onBeforeRestartServer(buildInstance.close) : await buildInstance.close());
6917
6965
  } catch (err) {
6918
6966
  __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.error('Failed to build.'), __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.error(err), process.exit(1);
6919
6967
  }
@@ -6945,6 +6993,6 @@ async function runCLI() {
6945
6993
  __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.error('Failed to start Rsbuild CLI.'), __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.error(err);
6946
6994
  }
6947
6995
  }
6948
- let src_version = "1.1.5";
6996
+ let src_version = "1.1.7";
6949
6997
  var __webpack_exports__logger = __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger, __webpack_exports__rspack = __WEBPACK_EXTERNAL_MODULE__rspack_core__.rspack;
6950
6998
  export { PLUGIN_CSS_NAME, PLUGIN_SWC_NAME, internal_namespaceObject as __internalHelper, createRsbuild, defineConfig, ensureAssetPrefix, config_loadConfig as loadConfig, loadEnv, mergeRsbuildConfig, runCLI, src_version as version, __webpack_exports__logger as logger, __webpack_exports__rspack as rspack };
@@ -1,10 +1,11 @@
1
- import type { AsyncHook, EnvironmentAsyncHook, InternalContext, ModifyBundlerChainFn, ModifyEnvironmentConfigFn, ModifyHTMLTagsFn, ModifyRsbuildConfigFn, ModifyRspackConfigFn, ModifyWebpackChainFn, ModifyWebpackConfigFn, OnAfterBuildFn, OnAfterCreateCompilerFn, OnAfterEnvironmentCompileFn, OnAfterStartDevServerFn, OnAfterStartProdServerFn, OnBeforeBuildFn, OnBeforeCreateCompilerFn, OnBeforeEnvironmentCompile, OnBeforeStartDevServerFn, OnBeforeStartProdServerFn, OnCloseDevServerFn, OnDevCompileDoneFn, OnExitFn, Rspack } from './types';
1
+ import type { AsyncHook, EnvironmentAsyncHook, InternalContext, ModifyBundlerChainFn, ModifyEnvironmentConfigFn, ModifyHTMLTagsFn, ModifyRsbuildConfigFn, ModifyRspackConfigFn, ModifyWebpackChainFn, ModifyWebpackConfigFn, OnAfterBuildFn, OnAfterCreateCompilerFn, OnAfterEnvironmentCompileFn, OnAfterStartDevServerFn, OnAfterStartProdServerFn, OnBeforeBuildFn, OnBeforeCreateCompilerFn, OnBeforeEnvironmentCompile, OnBeforeStartDevServerFn, OnBeforeStartProdServerFn, OnCloseBuildFn, OnCloseDevServerFn, OnDevCompileDoneFn, OnExitFn, Rspack } from './types';
2
2
  export declare function createEnvironmentAsyncHook<Callback extends (...args: any[]) => any>(): EnvironmentAsyncHook<Callback>;
3
3
  export declare function createAsyncHook<Callback extends (...args: any[]) => any>(): AsyncHook<Callback>;
4
4
  export declare function initHooks(): {
5
5
  /** The following hooks are global hooks */
6
6
  onExit: AsyncHook<OnExitFn>;
7
7
  onAfterBuild: AsyncHook<OnAfterBuildFn>;
8
+ onCloseBuild: AsyncHook<OnCloseBuildFn>;
8
9
  onBeforeBuild: AsyncHook<OnBeforeBuildFn>;
9
10
  onDevCompileDone: AsyncHook<OnDevCompileDoneFn>;
10
11
  onCloseDevServer: AsyncHook<OnCloseDevServerFn>;
@@ -98,13 +98,13 @@ export type Decorators = {
98
98
  };
99
99
  export interface SourceConfig {
100
100
  /**
101
- * Create aliases to import or require certain modules,
102
- * same as the [resolve.alias](https://rspack.dev/config/resolve) config of Rspack.
101
+ * @deprecated Use `resolve.alias` instead.
102
+ * `source.alias` will be removed in v2.0.0.
103
103
  */
104
104
  alias?: ConfigChain<Alias>;
105
105
  /**
106
- * Used to control the priority between the `paths` option in `tsconfig.json`
107
- * and the `alias` option in the bundler.
106
+ * @deprecated Use `resolve.aliasStrategy` instead.
107
+ * `source.aliasStrategy` will be removed in v2.0.0.
108
108
  */
109
109
  aliasStrategy?: AliasStrategy;
110
110
  /**
@@ -163,8 +163,11 @@ export type TransformImport = {
163
163
  type TransformImportFn = (imports: TransformImport[]) => TransformImport[] | void;
164
164
  export interface NormalizedSourceConfig extends SourceConfig {
165
165
  define: Define;
166
+ /**
167
+ * @deprecated Use `resolve.alias` instead.
168
+ * `source.alias` will be removed in v2.0.0.
169
+ */
166
170
  alias: ConfigChain<Alias>;
167
- aliasStrategy: AliasStrategy;
168
171
  preEntry: string[];
169
172
  decorators: Required<Decorators>;
170
173
  }
@@ -1141,6 +1144,25 @@ export interface DevConfig {
1141
1144
  export type NormalizedDevConfig = DevConfig & Required<Pick<DevConfig, 'hmr' | 'liveReload' | 'assetPrefix' | 'writeToDisk' | 'cliShortcuts'>> & {
1142
1145
  client: NormalizedClientConfig;
1143
1146
  };
1147
+ export interface ResolveConfig {
1148
+ /**
1149
+ * Force Rsbuild to resolve the specified packages from project root,
1150
+ * which is useful for deduplicating packages and reducing the bundle size.
1151
+ */
1152
+ dedupe?: string[];
1153
+ /**
1154
+ * Create aliases to import or require certain modules,
1155
+ * same as the [resolve.alias](https://rspack.dev/config/resolve) config of Rspack.
1156
+ */
1157
+ alias?: ConfigChain<Alias>;
1158
+ /**
1159
+ * Control the priority between the `paths` option in `tsconfig.json`
1160
+ * and the `resolve.alias` option of Rsbuild.
1161
+ * @default 'prefer-tsconfig'
1162
+ */
1163
+ aliasStrategy?: AliasStrategy;
1164
+ }
1165
+ export type NormalizedResolveConfig = ResolveConfig & Pick<Required<ResolveConfig>, 'alias' | 'aliasStrategy'>;
1144
1166
  export type ModuleFederationConfig = {
1145
1167
  options: ModuleFederationPluginOptions;
1146
1168
  };
@@ -1168,7 +1190,11 @@ export interface EnvironmentConfig {
1168
1190
  */
1169
1191
  tools?: ToolsConfig;
1170
1192
  /**
1171
- * Options for source code parsing and compilation.
1193
+ * Options for module resolution.
1194
+ */
1195
+ resolve?: ResolveConfig;
1196
+ /**
1197
+ * Options for input source code.
1172
1198
  */
1173
1199
  source?: SourceConfig;
1174
1200
  /**
@@ -1235,6 +1261,7 @@ export type MergedEnvironmentConfig = {
1235
1261
  dev: Pick<NormalizedDevConfig, 'hmr' | 'assetPrefix' | 'progressBar' | 'lazyCompilation' | 'writeToDisk'>;
1236
1262
  html: NormalizedHtmlConfig;
1237
1263
  tools: NormalizedToolsConfig;
1264
+ resolve: NormalizedResolveConfig;
1238
1265
  source: NormalizedSourceConfig;
1239
1266
  output: Omit<NormalizedOutputConfig, 'distPath'> & {
1240
1267
  distPath: Omit<Required<DistPathConfig>, 'jsAsync' | 'cssAsync'> & {
@@ -13,6 +13,7 @@ export type OnBeforeEnvironmentCompile<B = 'rspack'> = (params: CompileCommonPar
13
13
  environment: EnvironmentContext;
14
14
  bundlerConfig?: B extends 'rspack' ? Rspack.Configuration : WebpackConfig;
15
15
  }) => MaybePromise<void>;
16
+ export type OnCloseBuildFn = () => MaybePromise<void>;
16
17
  export type OnBeforeBuildFn<B = 'rspack'> = (params: CompileCommonParams & {
17
18
  environments: Record<string, EnvironmentContext>;
18
19
  bundlerConfigs?: B extends 'rspack' ? Rspack.Configuration[] : WebpackConfig[];