@rsbuild/core 1.1.6 → 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.
@@ -10088,7 +10088,7 @@
10088
10088
  defaultSizes,
10089
10089
  mode,
10090
10090
  } = {}) {
10091
- return html`<!doctype html>
10091
+ return html`<!DOCTYPE html>
10092
10092
  <html>
10093
10093
  <head>
10094
10094
  <meta charset="UTF-8" />
package/dist/index.cjs CHANGED
@@ -1784,7 +1784,7 @@ var __webpack_exports__ = {};
1784
1784
  case 'assets':
1785
1785
  return filename.assets ?? `[name]${hash}[ext]`;
1786
1786
  default:
1787
- throw Error(`unknown key ${type} in "output.filename"`);
1787
+ throw Error(`[rsbuild:config] unknown key ${type} in "output.filename"`);
1788
1788
  }
1789
1789
  }
1790
1790
  let applyToCompiler = (compiler, apply)=>{
@@ -1806,7 +1806,7 @@ var __webpack_exports__ = {};
1806
1806
  function loadEnv({ cwd = process.cwd(), mode = getNodeEnv(), prefixes = [
1807
1807
  'PUBLIC_'
1808
1808
  ] } = {}) {
1809
- 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.");
1809
+ 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.");
1810
1810
  let filePaths = [
1811
1811
  '.env',
1812
1812
  '.env.local',
@@ -2103,7 +2103,6 @@ var __webpack_exports__ = {};
2103
2103
  '@swc/helpers': swcHelpersPath
2104
2104
  },
2105
2105
  define: {},
2106
- aliasStrategy: 'prefer-tsconfig',
2107
2106
  preEntry: [],
2108
2107
  decorators: {
2109
2108
  version: '2022-03'
@@ -2185,10 +2184,14 @@ var __webpack_exports__ = {};
2185
2184
  exportLocalsConvention: 'camelCase'
2186
2185
  },
2187
2186
  emitAssets: !0
2187
+ }), getDefaultResolveConfig = ()=>({
2188
+ alias: {},
2189
+ aliasStrategy: 'prefer-tsconfig'
2188
2190
  }), createDefaultConfig = ()=>({
2189
2191
  dev: getDefaultDevConfig(),
2190
2192
  server: getDefaultServerConfig(),
2191
2193
  html: getDefaultHtmlConfig(),
2194
+ resolve: getDefaultResolveConfig(),
2192
2195
  source: getDefaultSourceConfig(),
2193
2196
  output: getDefaultOutputConfig(),
2194
2197
  tools: getDefaultToolsConfig(),
@@ -2290,13 +2293,13 @@ var __webpack_exports__ = {};
2290
2293
  envMode: envMode || nodeEnv,
2291
2294
  meta
2292
2295
  });
2293
- if (void 0 === result) throw Error('The config function must return a config object.');
2296
+ if (void 0 === result) throw Error('[rsbuild:loadConfig] The config function must return a config object.');
2294
2297
  return {
2295
2298
  content: applyMetaInfo(result),
2296
2299
  filePath: configFilePath
2297
2300
  };
2298
2301
  }
2299
- if (!isObject(configExport)) throw Error(`The config must be an object or a function that returns an object, get ${index_js_default().yellow(configExport)}`);
2302
+ 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)}`);
2300
2303
  return {
2301
2304
  content: applyMetaInfo(configExport),
2302
2305
  filePath: configFilePath
@@ -2389,7 +2392,7 @@ var __webpack_exports__ = {};
2389
2392
  let allLines = [];
2390
2393
  function getPlugin(name) {
2391
2394
  let targets = plugins.filter((item)=>item.instance.name === name);
2392
- if (!targets.length) throw Error(`plugin ${name} not existed`);
2395
+ if (!targets.length) throw Error(`[rsbuild:plugin] Plugin "${name}" not existed`);
2393
2396
  return targets;
2394
2397
  }
2395
2398
  for (let plugin of plugins){
@@ -2410,7 +2413,7 @@ var __webpack_exports__ = {};
2410
2413
  if (allLines.length) {
2411
2414
  let restInRingPoints = {};
2412
2415
  for (let l of allLines)restInRingPoints[l[0]] = !0, restInRingPoints[l[1]] = !0;
2413
- throw Error(`plugins dependencies has loop: ${Object.keys(restInRingPoints).join(',')}`);
2416
+ throw Error(`[rsbuild:plugin] Plugins dependencies has loop: ${Object.keys(restInRingPoints).join(',')}`);
2414
2417
  }
2415
2418
  return sortedPoint;
2416
2419
  };
@@ -2637,7 +2640,7 @@ var __webpack_exports__ = {};
2637
2640
  case 'report':
2638
2641
  return Compilation.PROCESS_ASSETS_STAGE_REPORT;
2639
2642
  default:
2640
- throw Error(`Invalid process assets stage: ${stage}`);
2643
+ throw Error(`[rsbuild] Invalid process assets stage: ${stage}`);
2641
2644
  }
2642
2645
  }, browsersListCache = new Map();
2643
2646
  async function getBrowserslist(path) {
@@ -2721,7 +2724,7 @@ var __webpack_exports__ = {};
2721
2724
  async function createContext(options, userConfig, bundlerType) {
2722
2725
  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');
2723
2726
  return {
2724
- version: "1.1.6",
2727
+ version: "1.1.7",
2725
2728
  rootPath,
2726
2729
  distPath: '',
2727
2730
  cachePath,
@@ -3105,7 +3108,7 @@ var __webpack_exports__ = {};
3105
3108
  if ('function' == typeof postcssOptions) {
3106
3109
  let postcssOptionsWrapper = (loaderContext)=>{
3107
3110
  let options = postcssOptions(loaderContext);
3108
- if ('object' != typeof options || null === options) throw Error(`\`postcssOptions\` function must return a PostCSSOptions object, got "${typeof options}".`);
3111
+ if ('object' != typeof options || null === options) throw Error(`[rsbuild:css] \`postcssOptions\` function must return a PostCSSOptions object, got "${typeof options}".`);
3109
3112
  return updatePostcssOptions({
3110
3113
  ...userOptions,
3111
3114
  ...options,
@@ -3224,7 +3227,7 @@ var __webpack_exports__ = {};
3224
3227
  preEntry.forEach(addEntry), injectCoreJsEntry && addEntry(createVirtualModule('import "core-js";')), castArray(entry[entryName]).forEach(addEntry);
3225
3228
  }
3226
3229
  }), api.onBeforeCreateCompiler(({ bundlerConfigs })=>{
3227
- if (bundlerConfigs.every((config)=>!config.entry)) throw Error(`Could not find any entry module, please make sure that ${index_js_default().cyan('src/index.(ts|js|tsx|jsx|mjs|cjs)')} exists, or customize entry through the ${index_js_default().cyan('source.entry')} configuration.`);
3230
+ 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|mjs|cjs)')} exists, or customize entry through the ${index_js_default().cyan('source.entry')} configuration.`);
3228
3231
  });
3229
3232
  }
3230
3233
  }), external_node_zlib_namespaceObject = require("node:zlib");
@@ -3300,7 +3303,7 @@ var __webpack_exports__ = {};
3300
3303
  gzipSizeLabel && (log += ` ${gzipSizeLabel}`), logs.push(log);
3301
3304
  }
3302
3305
  }
3303
- if (!1 !== options.total) {
3306
+ if (!1 !== options.total && assets.length > 1) {
3304
3307
  let totalSizeLabel = `${index_js_default().blue('Total:')} ${calcFileSize(totalSize)}`, log = `\n ${totalSizeLabel}`;
3305
3308
  options.compressed && (log += index_js_default().dim(` (gzip: ${calcFileSize(totalGzipSize)})`)), log += '\n', logs.push(log);
3306
3309
  }
@@ -3440,9 +3443,9 @@ var __webpack_exports__ = {};
3440
3443
  let emitFavicon = async (compilation, favicon)=>{
3441
3444
  let name = external_node_path_default().basename(favicon);
3442
3445
  if (compilation.assets[name]) return name;
3443
- if (!compilation.inputFileSystem) throw Error("[RsbuildHtmlPlugin] 'compilation.inputFileSystem' is not available.");
3446
+ if (!compilation.inputFileSystem) throw Error("[rsbuild:html] 'compilation.inputFileSystem' is not available.");
3444
3447
  let filename = external_node_path_default().resolve(compilation.compiler.context, favicon), buf = await (0, external_node_util_namespaceObject.promisify)(compilation.inputFileSystem.readFile)(filename);
3445
- if (!buf) throw Error(`[RsbuildHtmlPlugin] Failed to read the favicon, please check if the '${filename}' file exists'.`);
3448
+ if (!buf) throw Error(`[rsbuild:html] Failed to read the favicon, please check if the '${filename}' file exists'.`);
3446
3449
  let source = new compiler.webpack.sources.RawSource(buf, !1);
3447
3450
  return compilation.emitAsset(name, source), name;
3448
3451
  }, addFavicon = async (headTags, favicon, compilation, publicPath)=>{
@@ -3502,7 +3505,7 @@ var __webpack_exports__ = {};
3502
3505
  };
3503
3506
  let absolutePath = (0, external_node_path_.isAbsolute)(templatePath) ? templatePath : external_node_path_default().resolve(rootPath, templatePath);
3504
3507
  if (!existTemplatePath.has(absolutePath)) {
3505
- if (!await isFileExists(absolutePath)) throw Error(`Failed to resolve HTML template, please check if the file exists: ${index_js_default().cyan(absolutePath)}`);
3508
+ if (!await isFileExists(absolutePath)) throw Error(`[rsbuild:html] Failed to resolve HTML template, please check if the file exists: ${index_js_default().cyan(absolutePath)}`);
3506
3509
  existTemplatePath.add(absolutePath);
3507
3510
  }
3508
3511
  let templateContent = await external_node_fs_default().promises.readFile(absolutePath, 'utf-8');
@@ -3804,13 +3807,14 @@ var __webpack_exports__ = {};
3804
3807
  }, pluginManifest = ()=>({
3805
3808
  name: 'rsbuild:manifest',
3806
3809
  setup (api) {
3807
- api.modifyBundlerChain(async (chain, { CHAIN_ID, environment })=>{
3808
- let { output: { manifest } } = environment.config;
3810
+ api.modifyBundlerChain(async (chain, { CHAIN_ID, environment, isDev })=>{
3811
+ let { output: { manifest }, dev: { writeToDisk } } = environment.config;
3809
3812
  if (!1 === manifest) return;
3810
3813
  let { RspackManifestPlugin } = await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "../../compiled/rspack-manifest-plugin/index.js")), { htmlPaths } = environment;
3811
3814
  chain.plugin(CHAIN_ID.PLUGIN.MANIFEST).use(RspackManifestPlugin, [
3812
3815
  {
3813
3816
  fileName: 'string' == typeof manifest ? manifest : 'manifest.json',
3817
+ writeToFileEmit: isDev && !0 !== writeToDisk,
3814
3818
  generate: generateManifest(htmlPaths)
3815
3819
  }
3816
3820
  ]);
@@ -3943,7 +3947,7 @@ var __webpack_exports__ = {};
3943
3947
  raw: !0
3944
3948
  }, ({ code, emitFile, resourcePath })=>{
3945
3949
  let name = nodeAddons_getFilename(resourcePath);
3946
- if (null === name) throw Error(`Failed to load Node.js addon: "${resourcePath}"`);
3950
+ if (null === name) throw Error(`[rsbuild:node-addons] Failed to load Node.js addon: "${resourcePath}"`);
3947
3951
  return emitFile(name, code), `
3948
3952
  try {
3949
3953
  const path = require("path");
@@ -4023,7 +4027,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
4023
4027
  protocol
4024
4028
  });
4025
4029
  if (!newUrls) return null;
4026
- if (!Array.isArray(newUrls)) throw Error(`"server.printUrls" must return an array, but got ${typeof newUrls}.`);
4030
+ if (!Array.isArray(newUrls)) throw Error(`[rsbuild:config] "server.printUrls" must return an array, but got ${typeof newUrls}.`);
4027
4031
  urls = newUrls.map((url)=>({
4028
4032
  url,
4029
4033
  label: getUrlLabel(url)
@@ -4062,7 +4066,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
4062
4066
  if ('EADDRINUSE' !== e.code) throw e;
4063
4067
  port++, attempts++;
4064
4068
  }
4065
- if (port !== original && strictPort) throw Error(`Port "${original}" is occupied, please choose another one.`);
4069
+ if (port !== original && strictPort) throw Error(`[rsbuild:server] Port "${original}" is occupied, please choose another one.`);
4066
4070
  return port;
4067
4071
  }, getServerConfig = async ({ config })=>{
4068
4072
  let host = config.server.host || DEFAULT_DEV_HOST, originalPort = config.server.port || 3000, port = await getPort({
@@ -4303,7 +4307,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
4303
4307
  ]);
4304
4308
  });
4305
4309
  }
4306
- }), pluginResolve = ()=>({
4310
+ }), resolve_require = (0, external_node_module_namespaceObject.createRequire)(__rslib_import_meta_url__), pluginResolve = ()=>({
4307
4311
  name: 'rsbuild:resolve',
4308
4312
  setup (api) {
4309
4313
  api.modifyBundlerChain({
@@ -4333,12 +4337,43 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
4333
4337
  chain,
4334
4338
  tsconfigPath
4335
4339
  }), !function({ chain, config, rootPath }) {
4336
- let { alias } = config.source;
4337
- if (!alias) return;
4338
- let mergedAlias = reduceConfigs({
4340
+ let mergedSourceAlias = config.source.alias ? reduceConfigs({
4339
4341
  initial: {},
4340
- config: alias
4341
- });
4342
+ config: config.source.alias
4343
+ }) : {}, mergedResolveAlias = config.resolve.alias ? reduceConfigs({
4344
+ initial: {},
4345
+ config: config.resolve.alias
4346
+ }) : {}, mergedAlias = {
4347
+ ...mergedSourceAlias,
4348
+ ...mergedResolveAlias
4349
+ };
4350
+ if (config.resolve.dedupe) for (let pkgName of config.resolve.dedupe){
4351
+ let pkgPath;
4352
+ if (mergedAlias[pkgName]) {
4353
+ rslog_index_js_namespaceObject.logger.debug(`[rsbuild:resolve] The package "${pkgName}" is already in the alias config, dedupe option for "${pkgName}" will be ignored.`);
4354
+ continue;
4355
+ }
4356
+ try {
4357
+ pkgPath = (0, external_node_path_.dirname)(resolve_require.resolve(`${pkgName}/package.json`, {
4358
+ paths: [
4359
+ rootPath
4360
+ ]
4361
+ }));
4362
+ } catch (e) {}
4363
+ if (!pkgPath) try {
4364
+ pkgPath = resolve_require.resolve(pkgName, {
4365
+ paths: [
4366
+ rootPath
4367
+ ]
4368
+ });
4369
+ let trailing = '/' === external_node_path_.sep ? pkgName : pkgName.split('/').join(external_node_path_.sep);
4370
+ for(; !pkgPath.endsWith(trailing) && pkgPath.includes('node_modules');)pkgPath = (0, external_node_path_.dirname)(pkgPath);
4371
+ } catch (e) {
4372
+ rslog_index_js_namespaceObject.logger.debug(`[rsbuild:resolve] The package "${pkgName}" is not resolved in the project, dedupe option for "${pkgName}" will be ignored.`);
4373
+ continue;
4374
+ }
4375
+ mergedAlias[pkgName] = pkgPath;
4376
+ }
4342
4377
  for (let name of Object.keys(mergedAlias)){
4343
4378
  let formattedValues = castArray(mergedAlias[name]).map((value)=>'string' == typeof value && value.startsWith('.') ? ensureAbsolutePath(rootPath, value) : value);
4344
4379
  chain.resolve.alias.set(name, 1 === formattedValues.length ? formattedValues[0] : formattedValues);
@@ -4353,7 +4388,9 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
4353
4388
  chain,
4354
4389
  config,
4355
4390
  CHAIN_ID
4356
- }), tsconfigPath && 'rspack' === api.context.bundlerType && 'prefer-tsconfig' === config.source.aliasStrategy && chain.resolve.tsConfig({
4391
+ });
4392
+ let aliasStrategy = config.source.aliasStrategy ?? config.resolve.aliasStrategy;
4393
+ tsconfigPath && 'rspack' === api.context.bundlerType && 'prefer-tsconfig' === aliasStrategy && chain.resolve.tsConfig({
4357
4394
  configFile: tsconfigPath,
4358
4395
  references: 'auto'
4359
4396
  });
@@ -4884,7 +4921,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
4884
4921
  swcConfig.jsc.transform.legacyDecorator = !1, swcConfig.jsc.transform.decoratorVersion = '2022-03';
4885
4922
  break;
4886
4923
  default:
4887
- throw Error(`Unknown decorators version: ${version}`);
4924
+ throw Error(`[rsbuild:swc] Unknown decorators version: ${version}`);
4888
4925
  }
4889
4926
  }(swcConfig, config), castArray(target1 = target).includes('web') || target1.includes('web-worker')) {
4890
4927
  let polyfillMode = config.output.polyfill;
@@ -5186,7 +5223,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
5186
5223
  if ((rspackConfig = await modifyRspackConfig(context, rspackConfig, await getConfigUtils(rspackConfig, chainUtils))).plugins) {
5187
5224
  for (let plugin of rspackConfig.plugins)if (plugin && void 0 === plugin.apply && 'name' in plugin && 'setup' in plugin) {
5188
5225
  let name = index_js_default().bold(index_js_default().yellow(plugin.name));
5189
- throw Error(`${name} appears to be an Rsbuild plugin. It cannot be used as an Rspack plugin.`);
5226
+ throw Error(`[rsbuild:plugin] "${name}" appears to be an Rsbuild plugin. It cannot be used as an Rspack plugin.`);
5190
5227
  }
5191
5228
  }
5192
5229
  return rspackConfig;
@@ -5247,11 +5284,11 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
5247
5284
  }, config)
5248
5285
  })
5249
5286
  ]));
5250
- if (!Object.keys(resolvedEnvironments).length) throw Error(`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.`);
5287
+ 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.`);
5251
5288
  return resolvedEnvironments;
5252
5289
  }
5253
5290
  let defaultEnvironmentName = camelCase(rsbuildSharedConfig.output.target);
5254
- if (!isEnvironmentEnabled(defaultEnvironmentName)) throw Error(`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.`);
5291
+ 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.`);
5255
5292
  return {
5256
5293
  [defaultEnvironmentName]: applyEnvironmentDefaultConfig({
5257
5294
  ...rsbuildSharedConfig,
@@ -5372,7 +5409,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
5372
5409
  action: printUrls
5373
5410
  }
5374
5411
  ].filter(Boolean);
5375
- if (customShortcuts && !Array.isArray(shortcuts = customShortcuts(shortcuts))) throw Error('`dev.cliShortcuts` must return an array of shortcuts.');
5412
+ if (customShortcuts && !Array.isArray(shortcuts = customShortcuts(shortcuts))) throw Error('[rsbuild:config] `dev.cliShortcuts` must return an array of shortcuts.');
5376
5413
  help && rslog_index_js_namespaceObject.logger.log(` ➜ ${index_js_default().dim('press')} ${index_js_default().bold('h + enter')} ${index_js_default().dim('to show shortcuts')}\n`);
5377
5414
  let rl = external_node_readline_default().createInterface({
5378
5415
  input: process.stdin
@@ -5698,7 +5735,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
5698
5735
  postExecute(_m, _file) {}
5699
5736
  createRunner() {
5700
5737
  this.requirers.set('entry', (_currentDirectory, _modulePath, _context = {})=>{
5701
- throw Error('Not implement');
5738
+ throw Error('[rsbuild:runner] Not implement');
5702
5739
  });
5703
5740
  }
5704
5741
  constructor(_options){
@@ -5787,7 +5824,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
5787
5824
  name: 'context for esm'
5788
5825
  }), esmCache = new Map(), esmIdentifier = this._options.name;
5789
5826
  return (currentDirectory, modulePath, context = {})=>{
5790
- if (!external_node_vm_default().SourceTextModule) throw Error("Running esm bundle needs add Node.js option '--experimental-vm-modules'.");
5827
+ if (!external_node_vm_default().SourceTextModule) throw Error('[rsbuild:runner] Running ESM bundle needs add Node.js option "--experimental-vm-modules".');
5791
5828
  let _require = this.getRequire(), file = context.file || this.getFile(modulePath, currentDirectory);
5792
5829
  if (!file) return this.requirers.get('miss')(currentDirectory, modulePath);
5793
5830
  let esm = esmCache.get(file.path);
@@ -5825,7 +5862,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
5825
5862
  compilerOptions,
5826
5863
  readFileSync
5827
5864
  };
5828
- if ('web' === compilerOptions.target || 'webworker' === compilerOptions.target) throw Error(`not support run ${compilerOptions.target} resource in rsbuild server`);
5865
+ if ('web' === compilerOptions.target || 'webworker' === compilerOptions.target) throw Error(`[rsbuild:runner] Not support run "${compilerOptions.target}" resource in Rsbuild server`);
5829
5866
  return new EsmRunner(runnerOptions);
5830
5867
  }
5831
5868
  constructor(name){
@@ -5846,7 +5883,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
5846
5883
  entrypoints: !0,
5847
5884
  outputPath: !0
5848
5885
  });
5849
- if (!(null == entrypoints ? void 0 : entrypoints[entryName])) throw Error(`can't find entry(${entryName})`);
5886
+ if (!(null == entrypoints ? void 0 : entrypoints[entryName])) throw Error(`[rsbuild:loadBundle] Can't find entry: "${entryName}"`);
5850
5887
  let { chunks: entryChunks = [] } = entrypoints[entryName], files = entryChunks.reduce((prev, entryChunkName)=>{
5851
5888
  let chunk = null == chunks ? void 0 : chunks.find((chunk)=>{
5852
5889
  var _chunk_names;
@@ -5854,12 +5891,12 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
5854
5891
  });
5855
5892
  return (null == chunk ? void 0 : chunk.files) ? prev.concat(chunk.files.filter((file)=>!file.endsWith('.css'))) : prev;
5856
5893
  }, []);
5857
- if (0 === files.length) throw Error(`can't get bundle by entryName(${entryName})`);
5858
- if (files.length > 1) throw Error(`only support load single entry chunk, but got ${files.length}: ${files.join(',')}`);
5894
+ if (0 === files.length) throw Error(`[rsbuild:loadBundle] Failed to get bundle by entryName: "${entryName}"`);
5895
+ if (files.length > 1) throw Error(`[rsbuild:loadBundle] Only support load single entry chunk, but got ${files.length}: ${files.join(',')}`);
5859
5896
  return await run(files[0], outputPath, stats.compilation.options, utils.readFileSync);
5860
5897
  }, getTransformedHtml = async (entryName, utils)=>{
5861
5898
  let { htmlPaths, distPath } = utils.environment, htmlPath = htmlPaths[entryName];
5862
- if (!htmlPath) throw Error(`can't get html file by entryName(${entryName})`);
5899
+ if (!htmlPath) throw Error(`[rsbuild:getTransformedHtml] Failed to get HTML file by entryName: "${entryName}"`);
5863
5900
  let fileName = (0, external_node_path_.join)(distPath, htmlPath);
5864
5901
  return utils.readFileSync(fileName);
5865
5902
  }, ENCODING_REGEX = /\bgzip\b/, CONTENT_TYPE_REGEX = /text|javascript|\/json|xml/i, shouldCompress = (res)=>{
@@ -6169,7 +6206,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
6169
6206
  });
6170
6207
  }) : Promise.resolve(), startCompile = async ()=>{
6171
6208
  let compiler = customCompiler || await createCompiler();
6172
- if (!compiler) throw Error('Failed to get compiler instance.');
6209
+ if (!compiler) throw Error('[rsbuild:server] Failed to get compiler instance.');
6173
6210
  let publicPaths = isMultiCompiler(compiler) ? compiler.compilers.map(getPublicPathFromCompiler) : [
6174
6211
  getPublicPathFromCompiler(compiler)
6175
6212
  ], compilerDevMiddleware = new CompilerDevMiddleware({
@@ -6237,7 +6274,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
6237
6274
  name,
6238
6275
  {
6239
6276
  getStats: async ()=>{
6240
- if (!runCompile) throw Error("can't get stats info when runCompile is false");
6277
+ if (!runCompile) throw Error('[rsbuild:server] Can not get stats info when "runCompile" is false');
6241
6278
  return await waitFirstCompileDone, lastStats[environment.index];
6242
6279
  },
6243
6280
  loadBundle: async (entryName)=>(await waitFirstCompileDone, loadBundle(lastStats[environment.index], entryName, {
@@ -6309,7 +6346,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
6309
6346
  if (await context.hooks.onBeforeCreateCompiler.call({
6310
6347
  bundlerConfigs: rspackConfigs,
6311
6348
  environments: context.environments
6312
- }), !await isSatisfyRspackVersion(core_namespaceObject.rspack.rspackVersion)) throw Error(`The current Rspack version does not meet the requirements, the minimum supported version of Rspack is ${index_js_default().green(rspackMinVersion)}`);
6349
+ }), !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)}`);
6313
6350
  let compiler = 1 === rspackConfigs.length ? (0, core_namespaceObject.rspack)(rspackConfigs[0]) : (0, core_namespaceObject.rspack)(rspackConfigs), isVersionLogged = !1, isCompiling = !1, logRspackVersion = ()=>{
6314
6351
  !isVersionLogged && (rslog_index_js_namespaceObject.logger.debug(`Use Rspack v${core_namespaceObject.rspack.rspackVersion}`), isVersionLogged = !0);
6315
6352
  };
@@ -6685,7 +6722,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
6685
6722
  for (let newPlugin of newPlugins){
6686
6723
  if (!!newPlugin) if (!function(plugin) {
6687
6724
  let type = typeof plugin;
6688
- if ('object' !== type || null === plugin) throw Error(`Expect Rsbuild plugin instance to be an object, but got ${type}.`);
6725
+ if ('object' !== type || null === plugin) throw Error(`[rsbuild:plugin] Expect Rsbuild plugin instance to be an object, but got ${type}.`);
6689
6726
  if (!isFunction(plugin.setup)) {
6690
6727
  if (isFunction(plugin.apply)) {
6691
6728
  let { name = 'SomeWebpackPlugin' } = plugin.constructor || {};
@@ -6703,7 +6740,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
6703
6740
  `)
6704
6741
  ].join('\n'));
6705
6742
  }
6706
- throw Error(`Expect Rsbuild plugin.setup to be a function, but got ${type}.`);
6743
+ throw Error(`[rsbuild:plugin] Expect the setup function of Rsbuild plugin to be a function, but got ${type}.`);
6707
6744
  }
6708
6745
  }(newPlugin), before) {
6709
6746
  let index = plugins.findIndex((item)=>item.instance.name === before);
@@ -6747,12 +6784,12 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
6747
6784
  if (context.normalizedConfig) {
6748
6785
  if (null == options ? void 0 : options.environment) {
6749
6786
  let config = context.normalizedConfig.environments[options.environment];
6750
- if (!config) throw Error(`Cannot find normalized config by environment: ${options.environment}.`);
6787
+ if (!config) throw Error(`[rsbuild] Cannot find normalized config by environment: ${options.environment}.`);
6751
6788
  return config;
6752
6789
  }
6753
6790
  return context.normalizedConfig;
6754
6791
  }
6755
- throw Error('Cannot access normalized config until modifyRsbuildConfig is called.');
6792
+ throw Error('[rsbuild] Cannot access normalized config until modifyRsbuildConfig is called.');
6756
6793
  }
6757
6794
  let getRsbuildConfig = (type = 'current')=>{
6758
6795
  switch(type){
@@ -6763,7 +6800,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
6763
6800
  case 'normalized':
6764
6801
  return getNormalizedConfig();
6765
6802
  }
6766
- throw Error('`getRsbuildConfig` get an invalid type param.');
6803
+ throw Error('[rsbuild] `getRsbuildConfig` get an invalid type param.');
6767
6804
  }, exposed = [], expose = (id, api)=>{
6768
6805
  exposed.push({
6769
6806
  id,
@@ -6916,11 +6953,11 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
6916
6953
  pluginManager
6917
6954
  }), { distPath } = context, { checkDistDir = !0 } = options;
6918
6955
  if (checkDistDir) {
6919
- if (!(0, external_node_fs_.existsSync)(distPath)) throw Error(`The output directory ${index_js_default().yellow(distPath)} does not exist, please build the project before previewing.`);
6956
+ if (!(0, external_node_fs_.existsSync)(distPath)) throw Error(`[rsbuild:preview] The output directory ${index_js_default().yellow(distPath)} does not exist, please build the project before previewing.`);
6920
6957
  if (function(path) {
6921
6958
  let files = external_node_fs_default().readdirSync(path);
6922
6959
  return 0 === files.length || 1 === files.length && '.git' === files[0];
6923
- }(distPath)) throw Error(`The output directory ${index_js_default().yellow(distPath)} is empty, please build the project before previewing.`);
6960
+ }(distPath)) throw Error(`[rsbuild:preview] The output directory ${index_js_default().yellow(distPath)} is empty, please build the project before previewing.`);
6924
6961
  }
6925
6962
  return startProdServer(context, config, options);
6926
6963
  }, build = async (...args)=>{
@@ -7000,13 +7037,13 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
7000
7037
  'preview'
7001
7038
  ].includes(command) ? 'production' : 'development';
7002
7039
  }
7003
- }();
7040
+ }(), process.title = 'rsbuild-node';
7004
7041
  let { npm_execpath } = process.env;
7005
- (!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) && console.log(), rslog_index_js_namespaceObject.logger.greet(` Rsbuild v1.1.6\n`);
7042
+ (!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) && console.log(), rslog_index_js_namespaceObject.logger.greet(` Rsbuild v1.1.7\n`);
7006
7043
  }();
7007
7044
  try {
7008
7045
  !function() {
7009
- program.name('rsbuild').usage('<command> [options]').version("1.1.6");
7046
+ program.name('rsbuild').usage('<command> [options]').version("1.1.7");
7010
7047
  let devCommand = program.command('dev'), buildCommand = program.command('build'), previewCommand = program.command('preview'), inspectCommand = program.command('inspect');
7011
7048
  [
7012
7049
  devCommand,
@@ -7033,7 +7070,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
7033
7070
  }), buildInstance = await (null == rsbuild ? void 0 : rsbuild.build({
7034
7071
  watch: options.watch
7035
7072
  }));
7036
- options.watch && buildInstance && onBeforeRestartServer(buildInstance.close);
7073
+ buildInstance && (options.watch ? onBeforeRestartServer(buildInstance.close) : await buildInstance.close());
7037
7074
  } catch (err) {
7038
7075
  rslog_index_js_namespaceObject.logger.error('Failed to build.'), rslog_index_js_namespaceObject.logger.error(err), process.exit(1);
7039
7076
  }
@@ -7065,7 +7102,7 @@ throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
7065
7102
  rslog_index_js_namespaceObject.logger.error('Failed to start Rsbuild CLI.'), rslog_index_js_namespaceObject.logger.error(err);
7066
7103
  }
7067
7104
  }
7068
- let src_rslib_entry_version = "1.1.6";
7105
+ let src_rslib_entry_version = "1.1.7";
7069
7106
  })();
7070
7107
  var __webpack_export_target__ = exports;
7071
7108
  for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
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.6",
2637
+ version: "1.1.7",
2635
2638
  rootPath,
2636
2639
  distPath: '',
2637
2640
  cachePath,
@@ -3014,7 +3017,7 @@ let isPostcssPluginCreator = (plugin)=>'function' == typeof plugin && !0 === plu
3014
3017
  if ('function' == typeof postcssOptions) {
3015
3018
  let postcssOptionsWrapper = (loaderContext)=>{
3016
3019
  let options = postcssOptions(loaderContext);
3017
- 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}".`);
3018
3021
  return updatePostcssOptions({
3019
3022
  ...userOptions,
3020
3023
  ...options,
@@ -3133,7 +3136,7 @@ let isPostcssPluginCreator = (plugin)=>'function' == typeof plugin && !0 === plu
3133
3136
  preEntry.forEach(addEntry), injectCoreJsEntry && addEntry(createVirtualModule('import "core-js";')), castArray(entry[entryName]).forEach(addEntry);
3134
3137
  }
3135
3138
  }), api.onBeforeCreateCompiler(({ bundlerConfigs })=>{
3136
- 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.`);
3137
3140
  });
3138
3141
  }
3139
3142
  }), fileSize_gzip = (0, __WEBPACK_EXTERNAL_MODULE_node_util__.promisify)(__WEBPACK_EXTERNAL_MODULE_node_zlib__.default.gzip);
@@ -3207,7 +3210,7 @@ async function printFileSizes(options, stats, rootPath, environmentName) {
3207
3210
  gzipSizeLabel && (log += ` ${gzipSizeLabel}`), logs.push(log);
3208
3211
  }
3209
3212
  }
3210
- if (!1 !== options.total) {
3213
+ if (!1 !== options.total && assets.length > 1) {
3211
3214
  let totalSizeLabel = `${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js__.default.blue('Total:')} ${calcFileSize(totalSize)}`, log = `\n ${totalSizeLabel}`;
3212
3215
  options.compressed && (log += __WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js__.default.dim(` (gzip: ${calcFileSize(totalGzipSize)})`)), log += '\n', logs.push(log);
3213
3216
  }
@@ -3347,9 +3350,9 @@ class RsbuildHtmlPlugin {
3347
3350
  let emitFavicon = async (compilation, favicon)=>{
3348
3351
  let name = external_node_path_.default.basename(favicon);
3349
3352
  if (compilation.assets[name]) return name;
3350
- if (!compilation.inputFileSystem) throw Error("[RsbuildHtmlPlugin] 'compilation.inputFileSystem' is not available.");
3353
+ if (!compilation.inputFileSystem) throw Error("[rsbuild:html] 'compilation.inputFileSystem' is not available.");
3351
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);
3352
- 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'.`);
3353
3356
  let source = new compiler.webpack.sources.RawSource(buf, !1);
3354
3357
  return compilation.emitAsset(name, source), name;
3355
3358
  }, addFavicon = async (headTags, favicon, compilation, publicPath)=>{
@@ -3409,7 +3412,7 @@ async function getTemplate(entryName, config, rootPath) {
3409
3412
  };
3410
3413
  let absolutePath = (0, external_node_path_.isAbsolute)(templatePath) ? templatePath : external_node_path_.default.resolve(rootPath, templatePath);
3411
3414
  if (!existTemplatePath.has(absolutePath)) {
3412
- 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)}`);
3413
3416
  existTemplatePath.add(absolutePath);
3414
3417
  }
3415
3418
  let templateContent = await external_node_fs_.default.promises.readFile(absolutePath, 'utf-8');
@@ -3711,13 +3714,14 @@ let generateManifest = (htmlPaths)=>(_seed, files)=>{
3711
3714
  }, pluginManifest = ()=>({
3712
3715
  name: 'rsbuild:manifest',
3713
3716
  setup (api) {
3714
- api.modifyBundlerChain(async (chain, { CHAIN_ID, environment })=>{
3715
- let { output: { manifest } } = environment.config;
3717
+ api.modifyBundlerChain(async (chain, { CHAIN_ID, environment, isDev })=>{
3718
+ let { output: { manifest }, dev: { writeToDisk } } = environment.config;
3716
3719
  if (!1 === manifest) return;
3717
3720
  let { RspackManifestPlugin } = await import("../compiled/rspack-manifest-plugin/index.js"), { htmlPaths } = environment;
3718
3721
  chain.plugin(CHAIN_ID.PLUGIN.MANIFEST).use(RspackManifestPlugin, [
3719
3722
  {
3720
3723
  fileName: 'string' == typeof manifest ? manifest : 'manifest.json',
3724
+ writeToFileEmit: isDev && !0 !== writeToDisk,
3721
3725
  generate: generateManifest(htmlPaths)
3722
3726
  }
3723
3727
  ]);
@@ -3849,7 +3853,7 @@ let pluginMoment = ()=>({
3849
3853
  raw: !0
3850
3854
  }, ({ code, emitFile, resourcePath })=>{
3851
3855
  let name = nodeAddons_getFilename(resourcePath);
3852
- 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}"`);
3853
3857
  return emitFile(name, code), `
3854
3858
  try {
3855
3859
  const path = require("path");
@@ -3925,7 +3929,7 @@ function printServerURLs({ urls: originalUrls, port, routes, protocol, printUrls
3925
3929
  protocol
3926
3930
  });
3927
3931
  if (!newUrls) return null;
3928
- 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}.`);
3929
3933
  urls = newUrls.map((url)=>({
3930
3934
  url,
3931
3935
  label: getUrlLabel(url)
@@ -3964,7 +3968,7 @@ let getPort = async ({ host, port, strictPort, tryLimits = 20 })=>{
3964
3968
  if ('EADDRINUSE' !== e.code) throw e;
3965
3969
  port++, attempts++;
3966
3970
  }
3967
- 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.`);
3968
3972
  return port;
3969
3973
  }, getServerConfig = async ({ config })=>{
3970
3974
  let host = config.server.host || DEFAULT_DEV_HOST, originalPort = config.server.port || 3000, port = await getPort({
@@ -4205,7 +4209,7 @@ let getJsAsyncPath = (jsPath, isServer, jsAsync)=>void 0 !== jsAsync ? jsAsync :
4205
4209
  ]);
4206
4210
  });
4207
4211
  }
4208
- }), pluginResolve = ()=>({
4212
+ }), resolve_require = (0, __WEBPACK_EXTERNAL_MODULE_node_module__.createRequire)(import.meta.url), pluginResolve = ()=>({
4209
4213
  name: 'rsbuild:resolve',
4210
4214
  setup (api) {
4211
4215
  api.modifyBundlerChain({
@@ -4235,12 +4239,43 @@ let getJsAsyncPath = (jsPath, isServer, jsAsync)=>void 0 !== jsAsync ? jsAsync :
4235
4239
  chain,
4236
4240
  tsconfigPath
4237
4241
  }), !function({ chain, config, rootPath }) {
4238
- let { alias } = config.source;
4239
- if (!alias) return;
4240
- let mergedAlias = reduceConfigs({
4242
+ let mergedSourceAlias = config.source.alias ? reduceConfigs({
4241
4243
  initial: {},
4242
- config: alias
4243
- });
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
+ }
4244
4279
  for (let name of Object.keys(mergedAlias)){
4245
4280
  let formattedValues = castArray(mergedAlias[name]).map((value)=>'string' == typeof value && value.startsWith('.') ? ensureAbsolutePath(rootPath, value) : value);
4246
4281
  chain.resolve.alias.set(name, 1 === formattedValues.length ? formattedValues[0] : formattedValues);
@@ -4255,7 +4290,9 @@ let getJsAsyncPath = (jsPath, isServer, jsAsync)=>void 0 !== jsAsync ? jsAsync :
4255
4290
  chain,
4256
4291
  config,
4257
4292
  CHAIN_ID
4258
- }), 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({
4259
4296
  configFile: tsconfigPath,
4260
4297
  references: 'auto'
4261
4298
  });
@@ -4782,7 +4819,7 @@ let resourceHints_generateLinks = (options, rel)=>options.map((option)=>({
4782
4819
  swcConfig.jsc.transform.legacyDecorator = !1, swcConfig.jsc.transform.decoratorVersion = '2022-03';
4783
4820
  break;
4784
4821
  default:
4785
- throw Error(`Unknown decorators version: ${version}`);
4822
+ throw Error(`[rsbuild:swc] Unknown decorators version: ${version}`);
4786
4823
  }
4787
4824
  }(swcConfig, config), castArray(target1 = target).includes('web') || target1.includes('web-worker')) {
4788
4825
  let polyfillMode = config.output.polyfill;
@@ -5084,7 +5121,7 @@ async function generateRspackConfig({ target, context, environment }) {
5084
5121
  if ((rspackConfig = await modifyRspackConfig(context, rspackConfig, await getConfigUtils(rspackConfig, chainUtils))).plugins) {
5085
5122
  for (let plugin of rspackConfig.plugins)if (plugin && void 0 === plugin.apply && 'name' in plugin && 'setup' in plugin) {
5086
5123
  let name = __WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js__.default.bold(__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js__.default.yellow(plugin.name));
5087
- 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.`);
5088
5125
  }
5089
5126
  }
5090
5127
  return rspackConfig;
@@ -5145,11 +5182,11 @@ let initEnvironmentConfigs = (normalizedConfig, rootPath, specifiedEnvironments)
5145
5182
  }, config)
5146
5183
  })
5147
5184
  ]));
5148
- 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.`);
5149
5186
  return resolvedEnvironments;
5150
5187
  }
5151
5188
  let defaultEnvironmentName = camelCase(rsbuildSharedConfig.output.target);
5152
- 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.`);
5153
5190
  return {
5154
5191
  [defaultEnvironmentName]: applyEnvironmentDefaultConfig({
5155
5192
  ...rsbuildSharedConfig,
@@ -5268,7 +5305,7 @@ function setupCliShortcuts({ help = !0, openPage, closeServer, printUrls, restar
5268
5305
  action: printUrls
5269
5306
  }
5270
5307
  ].filter(Boolean);
5271
- 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.');
5272
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`);
5273
5310
  let rl = __WEBPACK_EXTERNAL_MODULE_node_readline__.default.createInterface({
5274
5311
  input: process.stdin
@@ -5592,7 +5629,7 @@ class BasicRunner {
5592
5629
  postExecute(_m, _file) {}
5593
5630
  createRunner() {
5594
5631
  this.requirers.set('entry', (_currentDirectory, _modulePath, _context = {})=>{
5595
- throw Error('Not implement');
5632
+ throw Error('[rsbuild:runner] Not implement');
5596
5633
  });
5597
5634
  }
5598
5635
  constructor(_options){
@@ -5679,7 +5716,7 @@ class EsmRunner extends CommonJsRunner {
5679
5716
  name: 'context for esm'
5680
5717
  }), esmCache = new Map(), esmIdentifier = this._options.name;
5681
5718
  return (currentDirectory, modulePath, context = {})=>{
5682
- 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".');
5683
5720
  let _require = this.getRequire(), file = context.file || this.getFile(modulePath, currentDirectory);
5684
5721
  if (!file) return this.requirers.get('miss')(currentDirectory, modulePath);
5685
5722
  let esm = esmCache.get(file.path);
@@ -5717,7 +5754,7 @@ class BasicRunnerFactory {
5717
5754
  compilerOptions,
5718
5755
  readFileSync
5719
5756
  };
5720
- 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`);
5721
5758
  return new EsmRunner(runnerOptions);
5722
5759
  }
5723
5760
  constructor(name){
@@ -5737,7 +5774,7 @@ let run = async (bundlePath, outputPath, compilerOptions, readFileSync)=>new Bas
5737
5774
  entrypoints: !0,
5738
5775
  outputPath: !0
5739
5776
  });
5740
- 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}"`);
5741
5778
  let { chunks: entryChunks = [] } = entrypoints[entryName], files = entryChunks.reduce((prev, entryChunkName)=>{
5742
5779
  let chunk = null == chunks ? void 0 : chunks.find((chunk)=>{
5743
5780
  var _chunk_names;
@@ -5745,12 +5782,12 @@ let run = async (bundlePath, outputPath, compilerOptions, readFileSync)=>new Bas
5745
5782
  });
5746
5783
  return (null == chunk ? void 0 : chunk.files) ? prev.concat(chunk.files.filter((file)=>!file.endsWith('.css'))) : prev;
5747
5784
  }, []);
5748
- if (0 === files.length) throw Error(`can't get bundle by entryName(${entryName})`);
5749
- 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(',')}`);
5750
5787
  return await run(files[0], outputPath, stats.compilation.options, utils.readFileSync);
5751
5788
  }, getTransformedHtml = async (entryName, utils)=>{
5752
5789
  let { htmlPaths, distPath } = utils.environment, htmlPath = htmlPaths[entryName];
5753
- 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}"`);
5754
5791
  let fileName = (0, external_node_path_.join)(distPath, htmlPath);
5755
5792
  return utils.readFileSync(fileName);
5756
5793
  }, ENCODING_REGEX = /\bgzip\b/, CONTENT_TYPE_REGEX = /text|javascript|\/json|xml/i, shouldCompress = (res)=>{
@@ -6060,7 +6097,7 @@ async function devServer_createDevServer(options, createCompiler, config, { comp
6060
6097
  });
6061
6098
  }) : Promise.resolve(), startCompile = async ()=>{
6062
6099
  let compiler = customCompiler || await createCompiler();
6063
- if (!compiler) throw Error('Failed to get compiler instance.');
6100
+ if (!compiler) throw Error('[rsbuild:server] Failed to get compiler instance.');
6064
6101
  let publicPaths = isMultiCompiler(compiler) ? compiler.compilers.map(getPublicPathFromCompiler) : [
6065
6102
  getPublicPathFromCompiler(compiler)
6066
6103
  ], compilerDevMiddleware = new CompilerDevMiddleware({
@@ -6128,7 +6165,7 @@ async function devServer_createDevServer(options, createCompiler, config, { comp
6128
6165
  name,
6129
6166
  {
6130
6167
  getStats: async ()=>{
6131
- 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');
6132
6169
  return await waitFirstCompileDone, lastStats[environment.index];
6133
6170
  },
6134
6171
  loadBundle: async (entryName)=>(await waitFirstCompileDone, loadBundle(lastStats[environment.index], entryName, {
@@ -6200,7 +6237,7 @@ async function createCompiler_createCompiler(options) {
6200
6237
  if (await context.hooks.onBeforeCreateCompiler.call({
6201
6238
  bundlerConfigs: rspackConfigs,
6202
6239
  environments: context.environments
6203
- }), !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)}`);
6204
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 = ()=>{
6205
6242
  !isVersionLogged && (__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.debug(`Use Rspack v${__WEBPACK_EXTERNAL_MODULE__rspack_core__.rspack.rspackVersion}`), isVersionLogged = !0);
6206
6243
  };
@@ -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,
@@ -6807,11 +6844,11 @@ async function createRsbuild(options = {}) {
6807
6844
  pluginManager
6808
6845
  }), { distPath } = context, { checkDistDir = !0 } = options;
6809
6846
  if (checkDistDir) {
6810
- 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.`);
6811
6848
  if (function(path) {
6812
6849
  let files = external_node_fs_.default.readdirSync(path);
6813
6850
  return 0 === files.length || 1 === files.length && '.git' === files[0];
6814
- }(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.`);
6815
6852
  }
6816
6853
  return startProdServer(context, config, options);
6817
6854
  }, build = async (...args)=>{
@@ -6891,13 +6928,13 @@ async function runCLI() {
6891
6928
  'preview'
6892
6929
  ].includes(command) ? 'production' : 'development';
6893
6930
  }
6894
- }();
6931
+ }(), process.title = 'rsbuild-node';
6895
6932
  let { npm_execpath } = process.env;
6896
- (!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.6\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`);
6897
6934
  }();
6898
6935
  try {
6899
6936
  !function() {
6900
- program.name('rsbuild').usage('<command> [options]').version("1.1.6");
6937
+ program.name('rsbuild').usage('<command> [options]').version("1.1.7");
6901
6938
  let devCommand = program.command('dev'), buildCommand = program.command('build'), previewCommand = program.command('preview'), inspectCommand = program.command('inspect');
6902
6939
  [
6903
6940
  devCommand,
@@ -6924,7 +6961,7 @@ async function runCLI() {
6924
6961
  }), buildInstance = await (null == rsbuild ? void 0 : rsbuild.build({
6925
6962
  watch: options.watch
6926
6963
  }));
6927
- options.watch && buildInstance && onBeforeRestartServer(buildInstance.close);
6964
+ buildInstance && (options.watch ? onBeforeRestartServer(buildInstance.close) : await buildInstance.close());
6928
6965
  } catch (err) {
6929
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);
6930
6967
  }
@@ -6956,6 +6993,6 @@ async function runCLI() {
6956
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);
6957
6994
  }
6958
6995
  }
6959
- let src_version = "1.1.6";
6996
+ let src_version = "1.1.7";
6960
6997
  var __webpack_exports__logger = __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger, __webpack_exports__rspack = __WEBPACK_EXTERNAL_MODULE__rspack_core__.rspack;
6961
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 };
@@ -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'> & {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsbuild/core",
3
- "version": "1.1.6",
3
+ "version": "1.1.7",
4
4
  "description": "The Rspack-based build tool.",
5
5
  "homepage": "https://rsbuild.dev",
6
6
  "bugs": {
@@ -54,8 +54,7 @@
54
54
  "devDependencies": {
55
55
  "@rslib/core": "0.1.0",
56
56
  "@types/connect": "3.4.38",
57
- "@types/fs-extra": "^11.0.4",
58
- "@types/node": "^22.9.3",
57
+ "@types/node": "^22.10.0",
59
58
  "@types/on-finished": "2.3.4",
60
59
  "@types/webpack-bundle-analyzer": "4.7.0",
61
60
  "@types/ws": "^8.5.13",
@@ -68,7 +67,6 @@
68
67
  "deepmerge": "^4.3.1",
69
68
  "dotenv": "16.4.5",
70
69
  "dotenv-expand": "11.0.7",
71
- "fs-extra": "^11.2.0",
72
70
  "html-rspack-plugin": "6.0.2",
73
71
  "http-proxy-middleware": "^2.0.6",
74
72
  "jiti": "^1.21.6",
@@ -82,7 +80,6 @@
82
80
  "postcss-loader": "8.1.1",
83
81
  "prebundle": "1.2.5",
84
82
  "reduce-configs": "^1.1.0",
85
- "rimraf": "^6.0.1",
86
83
  "rsbuild-dev-middleware": "0.1.2",
87
84
  "rslog": "^1.2.3",
88
85
  "rspack-chain": "^1.1.0",