@rsbuild/core 2.0.0-alpha.4 → 2.0.0-beta.1

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/131.js CHANGED
@@ -14,12 +14,17 @@ import * as __rspack_external_os from "os";
14
14
  import * as __rspack_external_path from "path";
15
15
  import * as __rspack_external_url from "url";
16
16
  import { __webpack_require__ } from "./rslib-runtime.js";
17
+ import { rspack as core_rspack } from "@rspack/core";
17
18
  import node_process from "node:process";
18
19
  import node_os, { constants as external_node_os_constants, type as external_node_os_type } from "node:os";
19
20
  import node_tty from "node:tty";
20
21
  import { promisify as external_node_util_promisify, stripVTControlCharacters } from "node:util";
21
22
  import { isPromise, isRegExp } from "node:util/types";
22
23
  import node_zlib from "node:zlib";
24
+ function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : node_process.argv) {
25
+ let prefix = flag.startsWith('-') ? '' : 1 === flag.length ? '-' : '--', position = argv.indexOf(prefix + flag), terminatorPosition = argv.indexOf('--');
26
+ return -1 !== position && (-1 === terminatorPosition || position < terminatorPosition);
27
+ }
23
28
  __webpack_require__.add({
24
29
  "../../node_modules/.pnpm/deepmerge@4.3.1/node_modules/deepmerge/dist/cjs.js" (module) {
25
30
  var isMergeableObject = function isMergeableObject(value) {
@@ -1002,11 +1007,6 @@ __webpack_require__.add({
1002
1007
  module.exports = __rspack_external_url;
1003
1008
  }
1004
1009
  });
1005
- let external_node_module_ = __webpack_require__("node:module"), rspack_rspack = (0, external_node_module_.createRequire)(import.meta.url)('@rspack/core');
1006
- function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : node_process.argv) {
1007
- let prefix = flag.startsWith('-') ? '' : 1 === flag.length ? '-' : '--', position = argv.indexOf(prefix + flag), terminatorPosition = argv.indexOf('--');
1008
- return -1 !== position && (-1 === terminatorPosition || position < terminatorPosition);
1009
- }
1010
1010
  let { env: dist_env } = node_process;
1011
1011
  function envForceColor() {
1012
1012
  if (!('FORCE_COLOR' in dist_env)) return;
@@ -2254,7 +2254,7 @@ class src_class extends ChainedMap {
2254
2254
  ]);
2255
2255
  }
2256
2256
  }
2257
- let setNodeEnv = (env)=>{
2257
+ let external_node_module_ = __webpack_require__("node:module"), vendors_require = (0, external_node_module_.createRequire)(import.meta.url), requireCompiledPackage = (name)=>vendors_require(`${COMPILED_PATH}/${name}/index.js`), setNodeEnv = (env)=>{
2258
2258
  process.env.NODE_ENV = env;
2259
2259
  }, isFunction = (func)=>'function' == typeof func, isObject = (obj)=>'[object Object]' === Object.prototype.toString.call(obj), objectPrototype = Object.prototype, getProto = Object.getPrototypeOf, isPlainObject = (obj)=>null !== obj && 'object' == typeof obj && getProto(obj) === objectPrototype, helpers_castArray = (arr)=>void 0 === arr ? [] : Array.isArray(arr) ? arr : [
2260
2260
  arr
@@ -2319,7 +2319,7 @@ let compiler_isMultiCompiler = (compiler)=>'compilers' in compiler && Array.isAr
2319
2319
  }, applyToCompiler = (compiler, apply)=>{
2320
2320
  compiler_isMultiCompiler(compiler) ? compiler.compilers.forEach(apply) : apply(compiler, 0);
2321
2321
  }, addCompilationError = (compilation, message)=>{
2322
- compilation.errors.push(new rspack_rspack.WebpackError(message));
2322
+ compilation.errors.push(new core_rspack.WebpackError(message));
2323
2323
  };
2324
2324
  function resolveFileName(stats) {
2325
2325
  let file = stats.file || stats.moduleName;
@@ -2864,7 +2864,7 @@ let OVERRIDE_PATHS = new Set([
2864
2864
  }, mergeRsbuildConfig = (...originalConfigs)=>{
2865
2865
  let configs = originalConfigs.filter((config)=>void 0 !== config).map(normalizeConfigStructure);
2866
2866
  return 2 === configs.length ? mergeConfig_merge(configs[0], configs[1]) : 1 === configs.length ? configs[0] : 0 === configs.length ? {} : configs.reduce((result, config)=>mergeConfig_merge(result, config), {});
2867
- }, defaultConfig_require = (0, external_node_module_.createRequire)(import.meta.url), defaultAllowedOrigins = /^https?:\/\/(?:(?:[^:]+\.)?localhost|127\.0\.0\.1|\[::1\])(?::\d+)?$/, createDefaultConfig = ()=>({
2867
+ }, defaultAllowedOrigins = /^https?:\/\/(?:(?:[^:]+\.)?localhost|127\.0\.0\.1|\[::1\])(?::\d+)?$/, createDefaultConfig = ()=>({
2868
2868
  dev: {
2869
2869
  hmr: !0,
2870
2870
  liveReload: !0,
@@ -2913,7 +2913,7 @@ let OVERRIDE_PATHS = new Set([
2913
2913
  scriptLoading: 'defer',
2914
2914
  implementation: 'js'
2915
2915
  },
2916
- resolve: (swcHelpersPath || (swcHelpersPath = (0, external_node_path_.dirname)(defaultConfig_require.resolve('@swc/helpers/package.json'))), {
2916
+ resolve: (swcHelpersPath || (swcHelpersPath = (0, external_node_path_.dirname)(vendors_require.resolve('@swc/helpers/package.json'))), {
2917
2917
  alias: {
2918
2918
  '@swc/helpers': swcHelpersPath
2919
2919
  },
@@ -2992,12 +2992,10 @@ let OVERRIDE_PATHS = new Set([
2992
2992
  enable: !1
2993
2993
  }
2994
2994
  },
2995
+ splitChunks: {},
2995
2996
  performance: {
2996
2997
  printFileSize: !0,
2997
- removeConsole: !1,
2998
- chunkSplit: {
2999
- strategy: 'split-by-experience'
3000
- }
2998
+ removeConsole: !1
3001
2999
  },
3002
3000
  environments: {},
3003
3001
  logLevel: 'info'
@@ -3177,7 +3175,7 @@ function getHTMLPathByEntry(entryName, config) {
3177
3175
  return prefix.startsWith('/') && src_logger.warn(`${picocolors_default().dim('[rsbuild:config]')} Absolute path is not recommended at ${picocolors_default().yellow(`output.distPath.html: "${prefix}"`)}, use relative path instead.`), external_node_path_.posix.join(prefix, filename).replace(/^\/+/, '');
3178
3176
  }
3179
3177
  let mapProcessAssetsStage = (stage)=>{
3180
- let { Compilation } = rspack_rspack;
3178
+ let { Compilation } = core_rspack;
3181
3179
  switch(stage){
3182
3180
  case 'additional':
3183
3181
  return Compilation.PROCESS_ASSETS_STAGE_ADDITIONAL;
@@ -3258,7 +3256,7 @@ function initPluginAPI({ context, pluginManager }) {
3258
3256
  compilation.hooks.childCompiler.tap(pluginName, (childCompiler)=>{
3259
3257
  childCompiler.__rsbuildTransformer = transformer;
3260
3258
  });
3261
- let { sources } = rspack_rspack;
3259
+ let { sources } = core_rspack;
3262
3260
  for (let { descriptor, handler, environment: pluginEnvironment } of processAssetsFns)(!descriptor.targets || descriptor.targets.includes(target)) && (!descriptor.environments || descriptor.environments.includes(environment.name)) && (!pluginEnvironment || isEnvironmentMatch(pluginEnvironment, environment.name)) && compilation.hooks.processAssets.tapPromise({
3263
3261
  name: pluginName,
3264
3262
  stage: mapProcessAssetsStage(descriptor.stage)
@@ -3446,7 +3444,7 @@ function createPublicContext(context) {
3446
3444
  async function createContext(options, userConfig) {
3447
3445
  let { cwd } = options, rootPath = userConfig.root ? ensureAbsolutePath(cwd, userConfig.root) : cwd, rsbuildConfig = await withDefaultConfig(rootPath, userConfig), cachePath = (0, external_node_path_.join)(rootPath, 'node_modules', '.cache'), specifiedEnvironments = options.environment && options.environment.length > 0 ? options.environment : void 0;
3448
3446
  return {
3449
- version: "2.0.0-alpha.4",
3447
+ version: "2.0.0-beta.1",
3450
3448
  rootPath,
3451
3449
  distPath: '',
3452
3450
  cachePath,
@@ -3676,9 +3674,9 @@ let configChain_CHAIN_ID = {
3676
3674
  JS: 'js',
3677
3675
  CSS: 'css'
3678
3676
  }
3679
- }, vendors_require = (0, external_node_module_.createRequire)(import.meta.url), requireCompiledPackage = (name)=>vendors_require(`${COMPILED_PATH}/${name}/index.js`);
3677
+ };
3680
3678
  function pluginHelper_getHTMLPlugin(config) {
3681
- return config?.html.implementation === 'native' ? rspack_rspack.HtmlRspackPlugin : (pluginHelper_htmlPlugin || (pluginHelper_htmlPlugin = requireCompiledPackage('html-rspack-plugin')), pluginHelper_htmlPlugin);
3679
+ return config?.html.implementation === 'native' ? core_rspack.HtmlRspackPlugin : (pluginHelper_htmlPlugin || (pluginHelper_htmlPlugin = requireCompiledPackage('html-rspack-plugin')), pluginHelper_htmlPlugin);
3682
3680
  }
3683
3681
  async function modifyRspackConfig(context, rspackConfig, chainUtils) {
3684
3682
  src_logger.debug('applying modifyRspackConfig hook');
@@ -3734,7 +3732,7 @@ function getConfigUtils(getCurrentConfig, chainUtils) {
3734
3732
  }
3735
3733
  function getChainUtils(target, environment, environments) {
3736
3734
  return {
3737
- rspack: rspack_rspack,
3735
+ rspack: core_rspack,
3738
3736
  environment,
3739
3737
  environments,
3740
3738
  env: process.env.NODE_ENV || '',
@@ -3757,7 +3755,7 @@ function validateRspackConfig(config) {
3757
3755
  config.devServer && src_logger.warn(`${picocolors_default().dim('[rsbuild:config]')} Find invalid Rspack config: "${picocolors_default().yellow('devServer')}". Note that Rspack's "devServer" config is not supported by Rsbuild. You can use Rsbuild's "dev" config to configure the Rsbuild dev server.`);
3758
3756
  }
3759
3757
  async function generateRspackConfig({ target, context, environmentName }) {
3760
- let chainUtils = getChainUtils(target, context.environments[environmentName], context.environments), { BannerPlugin, DefinePlugin, IgnorePlugin, ProvidePlugin, SourceMapDevToolPlugin, HotModuleReplacementPlugin } = rspack_rspack, rspackConfig = (await modifyBundlerChain(context, {
3758
+ let chainUtils = getChainUtils(target, context.environments[environmentName], context.environments), { BannerPlugin, DefinePlugin, IgnorePlugin, ProvidePlugin, SourceMapDevToolPlugin, HotModuleReplacementPlugin } = core_rspack, rspackConfig = (await modifyBundlerChain(context, {
3761
3759
  ...chainUtils,
3762
3760
  bundler: {
3763
3761
  BannerPlugin,
@@ -3807,13 +3805,13 @@ let createEnvironmentNotFoundError = (environments = [])=>{
3807
3805
  };
3808
3806
  async function initRsbuildConfig({ context, pluginManager }) {
3809
3807
  var config, rootPath;
3810
- let defaultConfig;
3808
+ let defaultConfig, host;
3811
3809
  if (context.normalizedConfig) return context.normalizedConfig;
3812
3810
  await initPlugins({
3813
3811
  context,
3814
3812
  pluginManager
3815
3813
  }), await modifyRsbuildConfig(context);
3816
- let normalizedBaseConfig = (config = context.config, rootPath = context.rootPath, config.server ||= {}, config.server.publicDir = ((rootPath, publicDir)=>{
3814
+ let normalizedBaseConfig = (config = context.config, rootPath = context.rootPath, config.server ||= {}, config.server.host = 'string' == typeof (host = config.server.host) ? host : !0 === host ? ALL_INTERFACES_IPV4 : LOCALHOST, config.server.publicDir = ((rootPath, publicDir)=>{
3817
3815
  if (!1 === publicDir) return [];
3818
3816
  let defaultConfig = {
3819
3817
  name: (0, external_node_path_.join)(rootPath, 'public'),
@@ -3973,7 +3971,7 @@ async function createCompiler_createCompiler(options) {
3973
3971
  if (await context.hooks.onBeforeCreateCompiler.callBatch({
3974
3972
  bundlerConfigs: rspackConfigs,
3975
3973
  environments: context.environments
3976
- }), (version = rspack_rspack.rspackVersion).includes('-canary') && (version = version.split('-canary')[0]), !(!(version && /^[\d.]+$/.test(version)) || ((version1, version2)=>{
3974
+ }), (version = core_rspack.rspackVersion).includes('-canary') && (version = version.split('-canary')[0]), !(!(version && /^[\d.]+$/.test(version)) || ((version1, version2)=>{
3977
3975
  let parts1 = version1.split('.').map(Number), parts2 = version2.split('.').map(Number), len = Math.max(parts1.length, parts2.length);
3978
3976
  for(let i = 0; i < len; i++){
3979
3977
  let item1 = parts1[i] ?? 0, item2 = parts2[i] ?? 0;
@@ -3982,10 +3980,10 @@ async function createCompiler_createCompiler(options) {
3982
3980
  }
3983
3981
  return 0;
3984
3982
  })(version, '1.5.0') >= 0)) throw Error(`${picocolors_default().dim('[rsbuild]')} The current Rspack version does not meet the requirements, the minimum supported version of Rspack is ${picocolors_default().green("1.5.0")}`);
3985
- let isMultiCompiler = rspackConfigs.length > 1, compiler = isMultiCompiler ? rspack_rspack(rspackConfigs) : rspack_rspack(rspackConfigs[0]);
3983
+ let isMultiCompiler = rspackConfigs.length > 1, compiler = isMultiCompiler ? core_rspack(rspackConfigs) : core_rspack(rspackConfigs[0]);
3986
3984
  'true' === process.env.RSPACK_UNSAFE_FAST_DROP && (compiler.unsafeFastDrop = !0);
3987
3985
  let isVersionLogged = !1, isCompiling = !1, logRspackVersion = ()=>{
3988
- isVersionLogged || (src_logger.debug(`using Rspack v${rspack_rspack.rspackVersion}`), isVersionLogged = !0);
3986
+ isVersionLogged || (src_logger.debug(`using Rspack v${core_rspack.rspackVersion}`), isVersionLogged = !0);
3989
3987
  }, lazyModules = new Set();
3990
3988
  compiler.hooks.infrastructureLog.tap(HOOK_NAME, (name, _, args)=>{
3991
3989
  let log = args[0];
@@ -4095,7 +4093,7 @@ async function createCompiler_createCompiler(options) {
4095
4093
  context,
4096
4094
  compiler,
4097
4095
  bundlerConfigs: rspackConfigs,
4098
- MultiStatsCtor: rspack_rspack.MultiStats
4096
+ MultiStatsCtor: core_rspack.MultiStats
4099
4097
  }), await context.hooks.onAfterCreateCompiler.callBatch({
4100
4098
  compiler,
4101
4099
  environments: context.environments
@@ -4164,7 +4162,7 @@ let RSPACK_BUILD_ERROR = 'Rspack build failed.', build_build = async (initOption
4164
4162
  rspackConfigs,
4165
4163
  compiler,
4166
4164
  isWatch: !!watch,
4167
- MultiStatsCtor: rspack_rspack.MultiStats
4165
+ MultiStatsCtor: core_rspack.MultiStats
4168
4166
  }), watch) {
4169
4167
  let watchOptions = rspackConfigs.map((options)=>options.watchOptions || {});
4170
4168
  return compiler.watch(watchOptions.length > 1 ? watchOptions : watchOptions[0] || {}, (err)=>{
@@ -4253,7 +4251,7 @@ function getRegExpForExts(exts) {
4253
4251
  return RegExp(1 === normalizedExts.length ? `\\.${matcher}$` : `\\.(?:${matcher})$`, 'i');
4254
4252
  }
4255
4253
  function getCacheDirectory({ cacheDirectory }, context) {
4256
- return cacheDirectory ? (0, external_node_path_.isAbsolute)(cacheDirectory) ? cacheDirectory : (0, external_node_path_.join)(context.rootPath, cacheDirectory) : (0, external_node_path_.join)(context.cachePath, context.bundlerType);
4254
+ return cacheDirectory ? (0, external_node_path_.isAbsolute)(cacheDirectory) ? cacheDirectory : (0, external_node_path_.join)(context.rootPath, cacheDirectory) : (0, external_node_path_.join)(context.cachePath, 'rspack');
4257
4255
  }
4258
4256
  async function getBuildDependencies(context, config, environmentContext, additionalDependencies) {
4259
4257
  let rootPackageJson = (0, external_node_path_.join)(context.rootPath, 'package.json'), browserslistConfig = (0, external_node_path_.join)(context.rootPath, '.browserslistrc'), buildDependencies = {};
@@ -4691,7 +4689,7 @@ class RsbuildHtmlPlugin {
4691
4689
  } catch (error) {
4692
4690
  return src_logger.debug(`read favicon error: ${error}`), addCompilationError(compilation, `${picocolors_default().dim('[rsbuild:html]')} Failed to read the favicon file at ${picocolors_default().yellow(inputFilename)}.`), null;
4693
4691
  }
4694
- let source = new rspack_rspack.sources.RawSource(fileContent, !1), outputFilename = external_node_path_.default.posix.join(faviconDistPath, name);
4692
+ let source = new core_rspack.sources.RawSource(fileContent, !1), outputFilename = external_node_path_.default.posix.join(faviconDistPath, name);
4695
4693
  return compilation.emitAsset(outputFilename, source), outputFilename;
4696
4694
  }, addFavicon = async ({ headTags, favicon, faviconDistPath, compilation, publicPath })=>{
4697
4695
  let href = favicon;
@@ -5227,10 +5225,7 @@ function pluginModuleFederation() {
5227
5225
  config.dev ||= {}, config.server ||= {}, userConfig.server?.cors === void 0 && (config.server.cors = !0), config.server?.port && !config.dev.client?.port && (config.dev.client ||= {}, config.dev.client.port = config.server.port), userConfig.dev?.assetPrefix === void 0 && config.dev.assetPrefix === config.server?.base && (config.dev.assetPrefix = !0);
5228
5226
  }
5229
5227
  }), api.modifyEnvironmentConfig((config)=>{
5230
- config.moduleFederation?.options && (config.performance?.chunkSplit?.strategy === 'split-by-experience' && (config.performance.chunkSplit = {
5231
- ...config.performance.chunkSplit,
5232
- strategy: 'custom'
5233
- }), config.source.include = [
5228
+ config.moduleFederation?.options && (config.source.include = [
5234
5229
  ...config.source.include || [],
5235
5230
  /@module-federation[\\/]/
5236
5231
  ]);
@@ -5238,7 +5233,7 @@ function pluginModuleFederation() {
5238
5233
  let { config } = environment;
5239
5234
  if (!config.moduleFederation?.options || 'web' !== target) return;
5240
5235
  let { options } = config.moduleFederation;
5241
- chain.plugin(CHAIN_ID.PLUGIN.MODULE_FEDERATION).use(rspack_rspack.container.ModuleFederationPlugin, [
5236
+ chain.plugin(CHAIN_ID.PLUGIN.MODULE_FEDERATION).use(core_rspack.container.ModuleFederationPlugin, [
5242
5237
  options
5243
5238
  ]), options.name && !chain.output.get('uniqueName') && chain.output.set('uniqueName', options.name);
5244
5239
  });
@@ -5257,7 +5252,6 @@ function getPublicPath({ isDev, config, context }) {
5257
5252
  let defaultPort = server.port ?? 3000;
5258
5253
  return formatPublicPath(replacePortPlaceholder(publicPath, isDev ? context.devServer?.port ?? defaultPort : defaultPort));
5259
5254
  }
5260
- let resolve_require = (0, external_node_module_.createRequire)(import.meta.url);
5261
5255
  function applyAlias({ chain, config, rootPath }) {
5262
5256
  let mergedAlias = reduceConfigs({
5263
5257
  initial: {},
@@ -5270,14 +5264,14 @@ function applyAlias({ chain, config, rootPath }) {
5270
5264
  continue;
5271
5265
  }
5272
5266
  try {
5273
- pkgPath = (0, external_node_path_.dirname)(resolve_require.resolve(`${pkgName}/package.json`, {
5267
+ pkgPath = (0, external_node_path_.dirname)(vendors_require.resolve(`${pkgName}/package.json`, {
5274
5268
  paths: [
5275
5269
  rootPath
5276
5270
  ]
5277
5271
  }));
5278
5272
  } catch {}
5279
5273
  if (!pkgPath) try {
5280
- pkgPath = resolve_require.resolve(pkgName, {
5274
+ pkgPath = vendors_require.resolve(pkgName, {
5281
5275
  paths: [
5282
5276
  rootPath
5283
5277
  ]
@@ -5407,7 +5401,7 @@ let resourceHints_generateLinks = (options, rel)=>options.map((option)=>({
5407
5401
  rel,
5408
5402
  ...option
5409
5403
  }
5410
- })), rsdoctor_require = (0, external_node_module_.createRequire)(import.meta.url);
5404
+ }));
5411
5405
  function resolveLayer(value) {
5412
5406
  return "OVERVIEW" === value ? 'info' : "ALL" === value ? 'trace' : value;
5413
5407
  }
@@ -5424,7 +5418,7 @@ async function applyProfile(root, filterValue, traceLayer = 'perfetto', traceOut
5424
5418
  traceOutput = 'perfetto' === traceLayer ? defaultRustTracePerfettoOutput : 'stdout';
5425
5419
  }
5426
5420
  let filter = resolveLayer(filterValue);
5427
- return await ensureFileDir(traceOutput), await rspack_rspack.experiments.globalTrace.register(filter, traceLayer, traceOutput), traceOutput;
5421
+ return await ensureFileDir(traceOutput), await core_rspack.experiments.globalTrace.register(filter, traceLayer, traceOutput), traceOutput;
5428
5422
  }
5429
5423
  function getForceSplittingGroups(forceSplitting, strategy) {
5430
5424
  let cacheGroups = {};
@@ -5440,109 +5434,152 @@ function getForceSplittingGroups(forceSplitting, strategy) {
5440
5434
  };
5441
5435
  return cacheGroups;
5442
5436
  }
5437
+ function resolveDefaultPreset(config) {
5438
+ let { polyfill } = config.output;
5439
+ return 'entry' === polyfill || 'usage' === polyfill ? {
5440
+ cacheGroups: {
5441
+ 'lib-polyfill': {
5442
+ name: 'lib-polyfill',
5443
+ test: /node_modules[\\/](?:tslib|core-js|@swc[\\/]helpers)[\\/]/,
5444
+ priority: 0
5445
+ }
5446
+ }
5447
+ } : {};
5448
+ }
5449
+ function resolvePerPackagePreset() {
5450
+ return {
5451
+ minSize: 0,
5452
+ maxInitialRequests: 1 / 0,
5453
+ cacheGroups: {
5454
+ vendors: {
5455
+ priority: -9,
5456
+ test: NODE_MODULES_REGEX,
5457
+ name: (module)=>module ? getPackageNameFromModulePath(module.context) : void 0
5458
+ }
5459
+ }
5460
+ };
5461
+ }
5462
+ function resolveSingleVendorPreset() {
5463
+ return {
5464
+ cacheGroups: {
5465
+ singleVendor: {
5466
+ test: NODE_MODULES_REGEX,
5467
+ priority: 0,
5468
+ chunks: 'all',
5469
+ name: 'vendor',
5470
+ enforce: !0
5471
+ }
5472
+ }
5473
+ };
5474
+ }
5475
+ function splitByExperience(ctx) {
5476
+ let { override, config, forceSplittingGroups } = ctx;
5477
+ return {
5478
+ ...getDefaultSplitChunksForWeb(config),
5479
+ ...override,
5480
+ cacheGroups: {
5481
+ ...resolveDefaultPreset(config)?.cacheGroups,
5482
+ ...forceSplittingGroups,
5483
+ ...override.cacheGroups
5484
+ }
5485
+ };
5486
+ }
5443
5487
  let MODULE_PATH_REGEX = /.*[\\/]node_modules[\\/](?!\.pnpm[\\/])(?:(@[^\\/]+)[\\/])?([^\\/]+)/;
5444
5488
  function getPackageNameFromModulePath(modulePath) {
5445
5489
  let handleModuleContext = modulePath?.match(MODULE_PATH_REGEX);
5446
5490
  if (!handleModuleContext) return;
5447
5491
  let [, scope, name] = handleModuleContext;
5448
- return [
5449
- 'npm',
5450
- (scope ?? '').replace('@', ''),
5451
- name
5452
- ].filter(Boolean).join('.');
5453
- }
5454
- let SPLIT_STRATEGY_DISPATCHER = {
5455
- 'split-by-experience': function splitByExperience(ctx) {
5456
- let { override, polyfill, defaultConfig, forceSplittingGroups } = ctx, experienceCacheGroup = {}, packageRegExps = {
5457
- axios: /node_modules[\\/]axios(-.+)?[\\/]/
5458
- };
5459
- for (let [name, test] of (('entry' === polyfill || 'usage' === polyfill) && (packageRegExps.polyfill = /node_modules[\\/](?:tslib|core-js|@swc[\\/]helpers)[\\/]/), Object.entries(packageRegExps))){
5460
- let key = `lib-${name}`;
5461
- experienceCacheGroup[key] = {
5462
- test,
5463
- priority: 0,
5464
- name: key
5465
- };
5492
+ return `npm-${scope ? `${scope.replace('@', '')}_` : ''}${name}`;
5493
+ }
5494
+ function splitByModule(ctx) {
5495
+ let { config, override, forceSplittingGroups } = ctx, perPackageOptions = resolvePerPackagePreset();
5496
+ return {
5497
+ ...getDefaultSplitChunksForWeb(config),
5498
+ ...perPackageOptions,
5499
+ ...override,
5500
+ cacheGroups: {
5501
+ ...forceSplittingGroups,
5502
+ ...perPackageOptions.cacheGroups,
5503
+ ...override.cacheGroups
5466
5504
  }
5467
- return {
5468
- ...defaultConfig,
5469
- ...override,
5470
- cacheGroups: {
5471
- ...defaultConfig.cacheGroups,
5472
- ...experienceCacheGroup,
5473
- ...forceSplittingGroups,
5474
- ...override.cacheGroups
5475
- }
5476
- };
5477
- },
5478
- 'split-by-module': function splitByModule(ctx) {
5479
- let { override, forceSplittingGroups, defaultConfig } = ctx;
5480
- return {
5481
- ...defaultConfig,
5482
- minSize: 0,
5483
- maxInitialRequests: 1 / 0,
5484
- ...override,
5485
- cacheGroups: {
5486
- ...defaultConfig.cacheGroups,
5487
- ...forceSplittingGroups,
5488
- vendors: {
5489
- priority: -9,
5490
- test: NODE_MODULES_REGEX,
5491
- name: (module)=>module ? getPackageNameFromModulePath(module.context) : void 0
5492
- },
5493
- ...override.cacheGroups
5494
- }
5495
- };
5496
- },
5497
- 'split-by-size': function splitBySize(ctx) {
5498
- let { override, forceSplittingGroups, defaultConfig, userConfig } = ctx;
5499
- return {
5500
- ...defaultConfig,
5501
- minSize: userConfig.minSize ?? 0,
5502
- maxSize: userConfig.maxSize ?? 1 / 0,
5503
- ...override,
5504
- cacheGroups: {
5505
- ...defaultConfig.cacheGroups,
5506
- ...forceSplittingGroups,
5507
- ...override.cacheGroups
5508
- }
5509
- };
5510
- },
5511
- custom: function splitCustom(ctx) {
5512
- let { override, forceSplittingGroups, defaultConfig } = ctx;
5513
- return {
5514
- ...defaultConfig,
5515
- ...override,
5516
- cacheGroups: {
5517
- ...defaultConfig.cacheGroups,
5518
- ...forceSplittingGroups,
5519
- ...override.cacheGroups
5520
- }
5521
- };
5522
- },
5523
- 'all-in-one': function allInOne(_ctx) {
5524
- return !1;
5525
- },
5526
- 'single-vendor': function singleVendor(ctx) {
5527
- let { override, defaultConfig, forceSplittingGroups } = ctx;
5528
- return {
5529
- ...defaultConfig,
5530
- ...override,
5531
- cacheGroups: {
5532
- ...defaultConfig.cacheGroups,
5533
- singleVendor: {
5534
- test: NODE_MODULES_REGEX,
5535
- priority: 0,
5536
- chunks: 'all',
5537
- name: 'vendor',
5538
- enforce: !0
5539
- },
5540
- ...forceSplittingGroups,
5541
- ...override.cacheGroups
5542
- }
5543
- };
5505
+ };
5506
+ }
5507
+ function splitBySize(ctx) {
5508
+ let { override, forceSplittingGroups, config } = ctx, { minSize = 0, maxSize = 1 / 0 } = config.performance.chunkSplit;
5509
+ return {
5510
+ ...getDefaultSplitChunksForWeb(config),
5511
+ minSize,
5512
+ maxSize,
5513
+ ...override,
5514
+ cacheGroups: {
5515
+ ...forceSplittingGroups,
5516
+ ...override.cacheGroups
5517
+ }
5518
+ };
5519
+ }
5520
+ function splitCustom(ctx) {
5521
+ let { config, override, forceSplittingGroups } = ctx;
5522
+ return {
5523
+ ...getDefaultSplitChunksForWeb(config),
5524
+ ...override,
5525
+ cacheGroups: {
5526
+ ...forceSplittingGroups,
5527
+ ...override.cacheGroups
5528
+ }
5529
+ };
5530
+ }
5531
+ function allInOne(_ctx) {
5532
+ return !1;
5533
+ }
5534
+ function singleVendor(ctx) {
5535
+ let { config, override, forceSplittingGroups } = ctx;
5536
+ return {
5537
+ ...getDefaultSplitChunksForWeb(config),
5538
+ ...override,
5539
+ cacheGroups: {
5540
+ ...resolveSingleVendorPreset().cacheGroups,
5541
+ ...forceSplittingGroups,
5542
+ ...override.cacheGroups
5543
+ }
5544
+ };
5545
+ }
5546
+ let getDefaultSplitChunksForWeb = (config)=>({
5547
+ chunks: config.moduleFederation?.options?.exposes ? 'async' : 'all'
5548
+ });
5549
+ function makeLegacySplitChunksOptions(chunkSplit, config, rootPath) {
5550
+ let forceSplittingGroups = {};
5551
+ chunkSplit.forceSplitting && (forceSplittingGroups = getForceSplittingGroups(chunkSplit.forceSplitting, chunkSplit.strategy));
5552
+ let override = 'custom' === chunkSplit.strategy ? chunkSplit.splitChunks ?? chunkSplit.override : chunkSplit.override;
5553
+ return ({
5554
+ 'all-in-one': allInOne,
5555
+ 'split-by-experience': splitByExperience,
5556
+ 'split-by-module': splitByModule,
5557
+ 'split-by-size': splitBySize,
5558
+ 'single-vendor': singleVendor,
5559
+ custom: splitCustom
5560
+ })[chunkSplit.strategy || 'split-by-experience']({
5561
+ config,
5562
+ rootPath,
5563
+ override: override || {},
5564
+ forceSplittingGroups
5565
+ });
5566
+ }
5567
+ function getSplitChunksByPreset(config, preset) {
5568
+ if (!preset) return {};
5569
+ switch(preset){
5570
+ case 'default':
5571
+ return resolveDefaultPreset(config);
5572
+ case 'single-vendor':
5573
+ return resolveSingleVendorPreset();
5574
+ case 'per-package':
5575
+ return resolvePerPackagePreset();
5576
+ case 'none':
5577
+ return {};
5578
+ default:
5579
+ throw Error(`[rsbuild] Unknown splitChunks preset: ${preset}`);
5544
5580
  }
5545
- }, swc_require = (0, external_node_module_.createRequire)(import.meta.url), builtinSwcLoaderName = 'builtin:swc-loader';
5581
+ }
5582
+ let builtinSwcLoaderName = 'builtin:swc-loader';
5546
5583
  function applyScriptCondition({ rule, isDev, config, rsbuildTarget }) {
5547
5584
  for (let condition of (rule.include.add({
5548
5585
  not: NODE_MODULES_REGEX
@@ -5579,7 +5616,7 @@ function getDefaultSwcConfig({ browserslist, cacheRoot, config, isProd }) {
5579
5616
  function applyCoreJs(swcConfig, polyfillMode, rootPath) {
5580
5617
  let coreJsPath = ((rootPath)=>{
5581
5618
  try {
5582
- return swc_require.resolve('core-js/package.json', {
5619
+ return vendors_require.resolve('core-js/package.json', {
5583
5620
  paths: [
5584
5621
  rootPath,
5585
5622
  import.meta.dirname
@@ -5983,7 +6020,7 @@ init(
5983
6020
  ${JSON.stringify(config.dev.client.logLevel)}
5984
6021
  )
5985
6022
  `;
5986
- new rspack_rspack.EntryPlugin(compiler.context, createVirtualModule(hmrEntry), {
6023
+ new core_rspack.EntryPlugin(compiler.context, createVirtualModule(hmrEntry), {
5987
6024
  name: void 0
5988
6025
  }).apply(compiler);
5989
6026
  }
@@ -6221,10 +6258,7 @@ let isValidMethodName = (methodName)=>'<unknown>' !== methodName && !/[\\/]/.tes
6221
6258
  fullStack && (log1 += fullStack);
6222
6259
  }
6223
6260
  }
6224
- return (log = log1).includes('ReferenceError: process is not defined') ? `${log}\n${picocolors_default().yellow(` - \`process\` is a Node.js global and not available in browsers.
6225
- - To access \`process.env.*\`, define them in a \`.env\` file with the \`PUBLIC_\` prefix.
6226
- - Or configure them via \`source.define\`.
6227
- - Alternatively, install \`@rsbuild/plugin-node-polyfill\` to polyfill Node.js globals.`)}` : log;
6261
+ return (log = log1).includes('ReferenceError: process is not defined') ? `${log}\n${picocolors_default().yellow(" - `process` is a Node.js global and not available in browsers.\n - To access `process.env.*`, define them in a `.env` file with the `PUBLIC_` prefix.\n - Or configure them via `source.define`.\n - Alternatively, install `@rsbuild/plugin-node-polyfill` to polyfill Node.js globals.")}` : log;
6228
6262
  }, styles = {
6229
6263
  1: 'font-weight:bold',
6230
6264
  2: 'opacity:0.5',
@@ -6693,30 +6727,35 @@ let faviconFallbackMiddleware = (req, res, next)=>{
6693
6727
  }), res.end(`The server is configured with a base URL of ${base} - did you mean to visit ${redirectPath} instead?`);
6694
6728
  };
6695
6729
  function formatProxyOptions(proxyOptions) {
6696
- let ret = [];
6697
- if (Array.isArray(proxyOptions)) ret.push(...proxyOptions);
6698
- else if ('target' in proxyOptions) ret.push(proxyOptions);
6699
- else for (let [context, options] of Object.entries(proxyOptions)){
6700
- let opts = {
6701
- context,
6702
- changeOrigin: !0,
6703
- logLevel: 'warn',
6704
- logProvider: ()=>src_logger
6705
- };
6706
- 'string' == typeof options ? opts.target = options : Object.assign(opts, options), ret.push(opts);
6707
- }
6708
- return ret;
6730
+ let logPrefix = picocolors_default().dim('[http-proxy-middleware]: '), defaultOptions = {
6731
+ changeOrigin: !0,
6732
+ logger: {
6733
+ info (msg) {
6734
+ src_logger.debug(logPrefix + msg);
6735
+ },
6736
+ warn: (msg)=>{
6737
+ src_logger.warn(logPrefix + msg);
6738
+ },
6739
+ error: (msg)=>{
6740
+ src_logger.error(logPrefix + msg);
6741
+ }
6742
+ }
6743
+ };
6744
+ return Array.isArray(proxyOptions) ? proxyOptions.map((options)=>({
6745
+ ...defaultOptions,
6746
+ ...options
6747
+ })) : Object.entries(proxyOptions).map(([pathFilter, value])=>({
6748
+ ...defaultOptions,
6749
+ pathFilter,
6750
+ ...'string' == typeof value ? {
6751
+ target: value
6752
+ } : value
6753
+ }));
6709
6754
  }
6710
6755
  function createProxyMiddleware(proxyOptions) {
6711
6756
  let formattedOptions = formatProxyOptions(proxyOptions), proxyMiddlewares = [], middlewares = [], { createProxyMiddleware: baseMiddleware } = requireCompiledPackage('http-proxy-middleware');
6712
6757
  for (let opts of formattedOptions){
6713
- let { onProxyRes } = opts;
6714
- opts.onProxyRes = (proxyRes, _req, res)=>{
6715
- onProxyRes && onProxyRes(proxyRes, _req, res), res.on('close', ()=>{
6716
- res.writableEnded || proxyRes.destroy();
6717
- });
6718
- };
6719
- let proxyMiddleware = baseMiddleware(opts.context, opts), middleware = async (req, res, next)=>{
6758
+ let proxyMiddleware = baseMiddleware(opts), middleware = async (req, res, next)=>{
6720
6759
  let bypassUrl = 'function' == typeof opts.bypass ? await opts.bypass(req, res, opts) : null;
6721
6760
  !1 === bypassUrl ? (res.statusCode = 404, next()) : 'string' == typeof bypassUrl ? (req.url = bypassUrl, next()) : !0 === bypassUrl ? next() : proxyMiddleware(req, res, next);
6722
6761
  };
@@ -6746,7 +6785,7 @@ let applyDefaultMiddlewares = async ({ config, buildManager, context, devServerA
6746
6785
  let { compress } = server;
6747
6786
  if (compress && middlewares.push(gzipMiddleware_gzipMiddleware('object' == typeof compress ? compress : void 0)), 'dev' === context.action && buildManager) {
6748
6787
  let { compiler } = buildManager;
6749
- (compiler_isMultiCompiler(compiler) ? compiler.compilers.some((childCompiler)=>childCompiler.options.lazyCompilation) : compiler.options.lazyCompilation) && middlewares.push(rspack_rspack.lazyCompilationMiddleware(compiler));
6788
+ (compiler_isMultiCompiler(compiler) ? compiler.compilers.some((childCompiler)=>childCompiler.options.lazyCompilation) : compiler.options.lazyCompilation) && middlewares.push(core_rspack.lazyCompilationMiddleware(compiler));
6750
6789
  }
6751
6790
  server.base && '/' !== server.base && middlewares.push(getBaseUrlMiddleware({
6752
6791
  base: server.base
@@ -6962,7 +7001,7 @@ class BasicRunner {
6962
7001
  });
6963
7002
  }
6964
7003
  }
6965
- let cjs_require = (0, external_node_module_.createRequire)(import.meta.url), cjs_define = (...args)=>{
7004
+ let cjs_define = (...args)=>{
6966
7005
  args.pop()();
6967
7006
  };
6968
7007
  class CommonJsRunner extends BasicRunner {
@@ -7004,16 +7043,16 @@ class CommonJsRunner extends BasicRunner {
7004
7043
  }
7005
7044
  createMissRequirer() {
7006
7045
  return (_currentDirectory, modulePath, _context = {})=>{
7007
- let resolvedPath = cjs_require.resolve(modulePath, {
7046
+ let resolvedPath = vendors_require.resolve(modulePath, {
7008
7047
  paths: [
7009
7048
  _currentDirectory
7010
7049
  ]
7011
7050
  });
7012
- return cjs_require(resolvedPath.startsWith('node:') ? resolvedPath.slice(5) : resolvedPath);
7051
+ return vendors_require(resolvedPath.startsWith('node:') ? resolvedPath.slice(5) : resolvedPath);
7013
7052
  };
7014
7053
  }
7015
7054
  createCjsRequirer() {
7016
- let requireCache = Object.create(null), vm = cjs_require('node:vm');
7055
+ let requireCache = Object.create(null), vm = vendors_require('node:vm');
7017
7056
  return (currentDirectory, modulePath, context = {})=>{
7018
7057
  let file = context.file || this.getFile(modulePath, currentDirectory);
7019
7058
  if (!file) return this.requirers.get('miss')(currentDirectory, modulePath);
@@ -7034,7 +7073,6 @@ class CommonJsRunner extends BasicRunner {
7034
7073
  };
7035
7074
  }
7036
7075
  }
7037
- let esm_require = (0, external_node_module_.createRequire)(import.meta.url);
7038
7076
  class EsmRunner extends CommonJsRunner {
7039
7077
  createRunner() {
7040
7078
  super.createRunner(), this.requirers.set('cjs', this.getRequire()), this.requirers.set('esm', this.createEsmRequirer());
@@ -7051,7 +7089,7 @@ class EsmRunner extends CommonJsRunner {
7051
7089
  });
7052
7090
  }
7053
7091
  createEsmRequirer() {
7054
- let esmCache = new Map(), esmIdentifier = this._options.name, vm = esm_require('node:vm');
7092
+ let esmCache = new Map(), esmIdentifier = this._options.name, vm = vendors_require('node:vm');
7055
7093
  return (currentDirectory, modulePath, context = {})=>{
7056
7094
  if (!vm.SourceTextModule) throw Error(`${picocolors_default().dim('[rsbuild:runner]')} Running ESM bundle needs add Node.js option ${picocolors_default().yellow('--experimental-vm-modules')}.`);
7057
7095
  let _require = this.getRequire(), file = context.file || this.getFile(modulePath, currentDirectory);
@@ -8117,7 +8155,7 @@ try {
8117
8155
  config: config.tools.styleLoader
8118
8156
  });
8119
8157
  mainRule.use(CHAIN_ID.USE.STYLE).loader(getCompiledPath('style-loader')).options(styleLoaderOptions);
8120
- } else mainRule.use(CHAIN_ID.USE.MINI_CSS_EXTRACT).loader((cssExtractPlugin || rspack_rspack.CssExtractRspackPlugin).loader).options(config.tools.cssExtract.loaderOptions);
8158
+ } else mainRule.use(CHAIN_ID.USE.MINI_CSS_EXTRACT).loader((cssExtractPlugin || core_rspack.CssExtractRspackPlugin).loader).options(config.tools.cssExtract.loaderOptions);
8121
8159
  else mainRule.use(CHAIN_ID.USE.IGNORE_CSS).loader(external_node_path_.default.join(dirname, 'ignoreCssLoader.mjs'));
8122
8160
  let importLoaders = {
8123
8161
  normal: 0,
@@ -8205,7 +8243,7 @@ try {
8205
8243
  let isStringExport = 'string' === cssLoaderOptions.exportType;
8206
8244
  if (isStringExport && mainRule.uses.has(CHAIN_ID.USE.MINI_CSS_EXTRACT) && mainRule.uses.delete(CHAIN_ID.USE.MINI_CSS_EXTRACT), emitCss && !config.output.injectStyles && !isStringExport) {
8207
8245
  let extractPluginOptions = config.tools.cssExtract.pluginOptions, cssPath = config.output.distPath.css, cssFilename = getFilename(config, 'css', isProd), isCssFilenameFn = 'function' == typeof cssFilename, cssAsyncPath = config.output.distPath.cssAsync ?? (cssPath ? `${cssPath}/async` : 'async');
8208
- chain.plugin(CHAIN_ID.PLUGIN.MINI_CSS_EXTRACT).use(cssExtractPlugin || rspack_rspack.CssExtractRspackPlugin, [
8246
+ chain.plugin(CHAIN_ID.PLUGIN.MINI_CSS_EXTRACT).use(cssExtractPlugin || core_rspack.CssExtractRspackPlugin, [
8209
8247
  {
8210
8248
  filename: isCssFilenameFn ? (...args)=>{
8211
8249
  let name = cssFilename(...args);
@@ -8339,29 +8377,34 @@ try {
8339
8377
  {
8340
8378
  name: 'rsbuild:split-chunks',
8341
8379
  setup (api) {
8342
- api.modifyBundlerChain(async (chain, { environment, isServer, isWebWorker })=>{
8343
- if (isServer || isWebWorker) {
8344
- chain.optimization.splitChunks(!1), isWebWorker && chain.module.parser.merge({
8345
- javascript: {
8346
- dynamicImportMode: 'eager'
8347
- }
8348
- });
8380
+ api.modifyBundlerChain((chain, { environment, isServer, isWebWorker })=>{
8381
+ let { config } = environment, { splitChunks } = config;
8382
+ if (isWebWorker && chain.module.parser.merge({
8383
+ javascript: {
8384
+ dynamicImportMode: 'eager'
8385
+ }
8386
+ }), isServer || isWebWorker) {
8387
+ if (!1 === splitChunks || 0 === Object.keys(splitChunks).length) chain.optimization.splitChunks(!1);
8388
+ else {
8389
+ let { preset = 'none', ...rest } = splitChunks;
8390
+ chain.optimization.splitChunks({
8391
+ ...getSplitChunksByPreset(config, preset),
8392
+ ...rest
8393
+ });
8394
+ }
8349
8395
  return;
8350
8396
  }
8351
- let { config } = environment, defaultConfig = {
8352
- chunks: config.moduleFederation?.options?.exposes ? 'async' : 'all',
8353
- cacheGroups: {}
8354
- }, { chunkSplit } = config.performance, forceSplittingGroups = {};
8355
- chunkSplit.forceSplitting && (forceSplittingGroups = getForceSplittingGroups(chunkSplit.forceSplitting, chunkSplit.strategy));
8356
- let override = 'custom' === chunkSplit.strategy ? chunkSplit.splitChunks ?? chunkSplit.override : chunkSplit.override, splitChunksOptions = await SPLIT_STRATEGY_DISPATCHER[chunkSplit.strategy || 'split-by-experience']({
8357
- defaultConfig,
8358
- override: override || {},
8359
- forceSplittingGroups,
8360
- userConfig: chunkSplit,
8361
- rootPath: api.context.rootPath,
8362
- polyfill: config.output.polyfill
8363
- });
8364
- chain.optimization.splitChunks(splitChunksOptions);
8397
+ let { chunkSplit } = config.performance;
8398
+ if (chunkSplit && !1 !== splitChunks && 0 === Object.keys(splitChunks).length) return void chain.optimization.splitChunks(makeLegacySplitChunksOptions(chunkSplit, config, api.context.rootPath));
8399
+ if (chunkSplit && src_logger.warn('[rsbuild:config] Both `performance.chunkSplit` and `splitChunks` are set. The `performance.chunkSplit` option is deprecated and will not work. Use `splitChunks` instead.'), !1 === splitChunks) chain.optimization.splitChunks(!1);
8400
+ else {
8401
+ let { preset = 'default', ...rest } = splitChunks;
8402
+ chain.optimization.splitChunks({
8403
+ ...getDefaultSplitChunksForWeb(config),
8404
+ ...getSplitChunksByPreset(config, preset),
8405
+ ...rest
8406
+ });
8407
+ }
8365
8408
  });
8366
8409
  }
8367
8410
  },
@@ -8452,7 +8495,7 @@ try {
8452
8495
  for (let config of bundlerConfigs)if (config.plugins?.some((plugin)=>isRsdoctorPlugin(plugin))) return;
8453
8496
  let packageName = '@rsdoctor/rspack-plugin';
8454
8497
  try {
8455
- packagePath = rsdoctor_require.resolve(packageName, {
8498
+ packagePath = vendors_require.resolve(packageName, {
8456
8499
  paths: [
8457
8500
  api.context.rootPath
8458
8501
  ]
@@ -8678,7 +8721,7 @@ try {
8678
8721
  api.onBeforeBuild(async ({ isFirstCompile })=>{
8679
8722
  isFirstCompile && await onStart();
8680
8723
  }), api.onBeforeStartDevServer(onStart), api.onExit(()=>{
8681
- traceOutput && (rspack_rspack.experiments.globalTrace.cleanup(), src_logger.info(`profile file saved to ${picocolors_default().cyan(traceOutput)}`));
8724
+ traceOutput && (core_rspack.experiments.globalTrace.cleanup(), src_logger.info(`profile file saved to ${picocolors_default().cyan(traceOutput)}`));
8682
8725
  });
8683
8726
  }
8684
8727
  },
@@ -8733,7 +8776,7 @@ try {
8733
8776
  let nonce = nonces[index], environment = environmentList.find((item)=>item.index === index);
8734
8777
  if (!Object.keys(environment?.htmlPaths ?? {}).length || !nonce) return;
8735
8778
  let injectCode = createVirtualModule(`__webpack_nonce__ = "${nonce}";`);
8736
- new rspack_rspack.EntryPlugin(compiler.context, injectCode, {
8779
+ new core_rspack.EntryPlugin(compiler.context, injectCode, {
8737
8780
  name: void 0
8738
8781
  }).apply(compiler);
8739
8782
  });
@@ -8969,7 +9012,6 @@ async function loadConfig_loadConfig({ cwd = process.cwd(), path, envMode, meta,
8969
9012
  moduleCache: !1,
8970
9013
  interopDefault: !0,
8971
9014
  nativeModules: [
8972
- '@rspack/core',
8973
9015
  "typescript"
8974
9016
  ]
8975
9017
  });
@@ -9005,7 +9047,7 @@ let commonOpts = {}, init_loadConfig = async (root)=>{
9005
9047
  envMode: commonOpts.envMode,
9006
9048
  loader: commonOpts.configLoader
9007
9049
  });
9008
- return config.dev ||= {}, config.source ||= {}, config.server ||= {}, commonOpts.base && (config.server.base = commonOpts.base), commonOpts.root && (config.root = root), commonOpts.mode && (config.mode = commonOpts.mode), commonOpts.logLevel && (config.logLevel = commonOpts.logLevel), commonOpts.open && !config.server?.open && (config.server.open = commonOpts.open), commonOpts.host && (config.server.host = !0 === commonOpts.host ? ALL_INTERFACES_IPV4 : commonOpts.host), commonOpts.port && (config.server.port = commonOpts.port), void 0 === config.dev.cliShortcuts && (config.dev.cliShortcuts = !0), filePath && (config.dev.watchFiles = [
9050
+ return config.dev ||= {}, config.source ||= {}, config.server ||= {}, commonOpts.base && (config.server.base = commonOpts.base), commonOpts.root && (config.root = root), commonOpts.mode && (config.mode = commonOpts.mode), commonOpts.logLevel && (config.logLevel = commonOpts.logLevel), commonOpts.open && !config.server?.open && (config.server.open = commonOpts.open), void 0 !== commonOpts.host && (config.server.host = commonOpts.host), commonOpts.port && (config.server.port = commonOpts.port), void 0 === config.dev.cliShortcuts && (config.dev.cliShortcuts = !0), filePath && (config.dev.watchFiles = [
9009
9051
  ...config.dev.watchFiles ? helpers_castArray(config.dev.watchFiles) : [],
9010
9052
  {
9011
9053
  paths: filePath,
@@ -9103,7 +9145,7 @@ let applyServerOptions = (command)=>{
9103
9145
  };
9104
9146
  function setupCommands() {
9105
9147
  let cli = ((name = "")=>new CAC(name))('rsbuild');
9106
- cli.version("2.0.0-alpha.4"), cli.option('--base <base>', 'Set the base path of the server').option('-c, --config <config>', 'Set the configuration file (relative or absolute path)').option('--config-loader <loader>', 'Set the config file loader (auto | jiti | native)', {
9148
+ cli.version("2.0.0-beta.1"), cli.option('--base <base>', 'Set the base path of the server').option('-c, --config <config>', 'Set the configuration file (relative or absolute path)').option('--config-loader <loader>', 'Set the config file loader (auto | jiti | native)', {
9107
9149
  default: 'auto'
9108
9150
  }).option('--env-dir <dir>', 'Set the directory for loading `.env` files').option('--env-mode <mode>', 'Set the env mode to load the `.env.[mode]` file').option('--environment <name>', 'Set the environment name(s) to build', {
9109
9151
  type: [
@@ -9172,7 +9214,7 @@ function initNodeEnv() {
9172
9214
  }
9173
9215
  function showGreeting() {
9174
9216
  let { npm_execpath, npm_lifecycle_event, NODE_RUN_SCRIPT_NAME } = process.env, isBun = npm_execpath?.includes('.bun');
9175
- src_logger.greet(`${'npx' === npm_lifecycle_event || isBun || NODE_RUN_SCRIPT_NAME ? '\n' : ''}Rsbuild v2.0.0-alpha.4\n`);
9217
+ src_logger.greet(`${'npx' === npm_lifecycle_event || isBun || NODE_RUN_SCRIPT_NAME ? '\n' : ''}Rsbuild v2.0.0-beta.1\n`);
9176
9218
  }
9177
9219
  function setupLogLevel() {
9178
9220
  let logLevelIndex = process.argv.findIndex((item)=>'--log-level' === item || '--logLevel' === item);
@@ -9193,5 +9235,5 @@ function runCLI() {
9193
9235
  src_logger.error('Failed to start Rsbuild CLI.'), src_logger.error(err), process.exit(1);
9194
9236
  }
9195
9237
  }
9196
- let src_version = "2.0.0-alpha.4";
9197
- export { PLUGIN_CSS_NAME, PLUGIN_SWC_NAME, createRsbuild, defaultAllowedOrigins, defineConfig, ensureAssetPrefix, external_node_os_type, external_node_util_promisify, loadConfig_loadConfig as loadConfig, loadEnv, mergeRsbuildConfig, node_os, node_process, rspack_rspack as rspack, runCLI, src_logger as logger, src_version as version };
9238
+ let src_version = "2.0.0-beta.1";
9239
+ export { PLUGIN_CSS_NAME, PLUGIN_SWC_NAME, core_rspack as rspack, createRsbuild, defaultAllowedOrigins, defineConfig, ensureAssetPrefix, external_node_os_type, external_node_util_promisify, loadConfig_loadConfig as loadConfig, loadEnv, mergeRsbuildConfig, node_os, node_process, runCLI, src_logger as logger, src_version as version };