@rsbuild/core 0.7.0-beta.6 → 0.7.0-beta.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -36,16 +36,13 @@ var __publicField = (obj, key, value) => {
36
36
  };
37
37
 
38
38
  // src/constants.ts
39
- var import_node_path, PLUGIN_SWC_NAME, PLUGIN_CSS_NAME, PLUGIN_LESS_NAME, PLUGIN_SASS_NAME, PLUGIN_STYLUS_NAME, LOADER_PATH, STATIC_PATH, COMPILED_PATH, TS_CONFIG_FILE, HTML_REGEX, CSS_REGEX;
39
+ var import_node_path, PLUGIN_SWC_NAME, PLUGIN_CSS_NAME, LOADER_PATH, STATIC_PATH, COMPILED_PATH, TS_CONFIG_FILE, HTML_REGEX, CSS_REGEX;
40
40
  var init_constants = __esm({
41
41
  "src/constants.ts"() {
42
42
  "use strict";
43
43
  import_node_path = require("path");
44
44
  PLUGIN_SWC_NAME = "rsbuild:swc";
45
45
  PLUGIN_CSS_NAME = "rsbuild:css";
46
- PLUGIN_LESS_NAME = "rsbuild:less";
47
- PLUGIN_SASS_NAME = "rsbuild:sass";
48
- PLUGIN_STYLUS_NAME = "rsbuild:stylus";
49
46
  LOADER_PATH = (0, import_node_path.join)(__dirname);
50
47
  STATIC_PATH = (0, import_node_path.join)(__dirname, "../static");
51
48
  COMPILED_PATH = (0, import_node_path.join)(__dirname, "../compiled");
@@ -333,8 +330,8 @@ var init_mergeConfig = __esm({
333
330
  "provider"
334
331
  ];
335
332
  isOverridePath = (key) => OVERRIDE_PATH.includes(key);
336
- merge = (x, y, path15 = "") => {
337
- if (isOverridePath(path15)) {
333
+ merge = (x, y, path13 = "") => {
334
+ if (isOverridePath(path13)) {
338
335
  return y ?? x;
339
336
  }
340
337
  if (x === void 0) {
@@ -356,7 +353,7 @@ var init_mergeConfig = __esm({
356
353
  const merged = {};
357
354
  const keys = /* @__PURE__ */ new Set([...Object.keys(x), ...Object.keys(y)]);
358
355
  for (const key of keys) {
359
- const childPath = path15 ? `${path15}.${key}` : key;
356
+ const childPath = path13 ? `${path13}.${key}` : key;
360
357
  merged[key] = merge(x[key], y[key], childPath);
361
358
  }
362
359
  return merged;
@@ -459,10 +456,10 @@ async function watchFiles(files) {
459
456
  }
460
457
  async function loadConfig({
461
458
  cwd = process.cwd(),
462
- path: path15,
459
+ path: path13,
463
460
  envMode
464
461
  } = {}) {
465
- const configFilePath = resolveConfigPath(cwd, path15);
462
+ const configFilePath = resolveConfigPath(cwd, path13);
466
463
  if (!configFilePath) {
467
464
  return {
468
465
  content: {},
@@ -1043,7 +1040,7 @@ async function createContextByConfig(options, bundlerType, config = {}) {
1043
1040
  const context = {
1044
1041
  entry: getEntryObject(config, "web"),
1045
1042
  targets: config.output?.targets || [],
1046
- version: "0.7.0-beta.6",
1043
+ version: "0.7.0-beta.8",
1047
1044
  rootPath,
1048
1045
  distPath,
1049
1046
  cachePath,
@@ -2064,7 +2061,6 @@ var init_html = __esm({
2064
2061
  var css_exports = {};
2065
2062
  __export(css_exports, {
2066
2063
  applyAutoprefixer: () => applyAutoprefixer,
2067
- applyCSSRule: () => applyCSSRule,
2068
2064
  enableNativeCss: () => enableNativeCss,
2069
2065
  isUseCssExtract: () => isUseCssExtract,
2070
2066
  normalizeCssLoaderOptions: () => normalizeCssLoaderOptions,
@@ -3434,10 +3430,10 @@ var init_rsdoctor = __esm({
3434
3430
  const packageName = isRspack ? "@rsdoctor/rspack-plugin" : "@rsdoctor/webpack-plugin";
3435
3431
  let module2;
3436
3432
  try {
3437
- const path15 = require.resolve(packageName, {
3433
+ const path13 = require.resolve(packageName, {
3438
3434
  paths: [api.context.rootPath]
3439
3435
  });
3440
- module2 = await import(path15);
3436
+ module2 = await import(path13);
3441
3437
  } catch (err) {
3442
3438
  import_shared30.logger.warn(
3443
3439
  `\`process.env.RSDOCTOR\` enabled, please install ${import_shared30.color.bold(import_shared30.color.yellow(packageName))} package.`
@@ -4100,227 +4096,17 @@ var init_define = __esm({
4100
4096
  }
4101
4097
  });
4102
4098
 
4103
- // src/plugins/less.ts
4104
- var less_exports = {};
4105
- __export(less_exports, {
4106
- pluginLess: () => pluginLess
4107
- });
4108
- function pluginLess() {
4109
- return {
4110
- name: "rsbuild:less",
4111
- setup(api) {
4112
- api.modifyBundlerChain(async (chain, utils) => {
4113
- const config = api.getNormalizedConfig();
4114
- const { applyCSSRule: applyCSSRule2 } = await Promise.resolve().then(() => (init_css(), css_exports));
4115
- const rule = chain.module.rule(utils.CHAIN_ID.RULE.LESS).test(/\.less$/);
4116
- const { excludes, options } = getLessLoaderOptions(
4117
- config.tools.less,
4118
- config.output.sourceMap.css,
4119
- api.context.rootPath
4120
- );
4121
- for (const item of excludes) {
4122
- rule.exclude.add(item);
4123
- }
4124
- await applyCSSRule2({
4125
- rule,
4126
- utils,
4127
- config,
4128
- context: api.context,
4129
- importLoaders: 2
4130
- });
4131
- rule.use(utils.CHAIN_ID.USE.LESS).loader(getCompiledPath("less-loader")).options(options);
4132
- });
4133
- }
4134
- };
4135
- }
4136
- var import_node_path21, import_shared37, getLessLoaderOptions;
4137
- var init_less = __esm({
4138
- "src/plugins/less.ts"() {
4139
- "use strict";
4140
- import_node_path21 = __toESM(require("path"));
4141
- import_shared37 = require("@rsbuild/shared");
4142
- init_helpers();
4143
- getLessLoaderOptions = (rsbuildLessConfig, isUseCssSourceMap, rootPath) => {
4144
- const excludes = [];
4145
- const addExcludes = (items) => {
4146
- excludes.push(...(0, import_shared37.castArray)(items));
4147
- };
4148
- const defaultLessLoaderOptions = {
4149
- lessOptions: {
4150
- javascriptEnabled: true,
4151
- // let less resolve from node_modules in the current root directory,
4152
- // Avoid resolving from wrong node_modules.
4153
- paths: [import_node_path21.default.join(rootPath, "node_modules")]
4154
- },
4155
- sourceMap: isUseCssSourceMap,
4156
- implementation: (0, import_shared37.getSharedPkgCompiledPath)("less")
4157
- };
4158
- const mergeFn = (defaults, userOptions) => {
4159
- const getLessOptions = () => {
4160
- if (defaults.lessOptions && userOptions.lessOptions) {
4161
- return (0, import_shared37.deepmerge)(defaults.lessOptions, userOptions.lessOptions);
4162
- }
4163
- return userOptions.lessOptions || defaults.lessOptions;
4164
- };
4165
- return {
4166
- ...defaults,
4167
- ...userOptions,
4168
- lessOptions: getLessOptions()
4169
- };
4170
- };
4171
- const mergedOptions = (0, import_shared37.mergeChainedOptions)({
4172
- defaults: defaultLessLoaderOptions,
4173
- options: rsbuildLessConfig,
4174
- utils: { addExcludes },
4175
- mergeFn
4176
- });
4177
- return {
4178
- options: mergedOptions,
4179
- excludes
4180
- };
4181
- };
4182
- }
4183
- });
4184
-
4185
- // src/plugins/sass.ts
4186
- var sass_exports = {};
4187
- __export(sass_exports, {
4188
- patchCompilerGlobalLocation: () => patchCompilerGlobalLocation,
4189
- pluginSass: () => pluginSass
4190
- });
4191
- function patchGlobalLocation() {
4192
- if (!global.location) {
4193
- const href = (0, import_node_url2.pathToFileURL)(process.cwd()).href + import_node_path22.default.sep;
4194
- const location = Object.freeze({ [GLOBAL_PATCHED_SYMBOL]: true, href });
4195
- global.location = location;
4196
- }
4197
- }
4198
- function unpatchGlobalLocation() {
4199
- if (global.location?.[GLOBAL_PATCHED_SYMBOL]) {
4200
- delete global.location;
4201
- }
4202
- }
4203
- function patchCompilerGlobalLocation(compiler) {
4204
- compiler.hooks.run.tap("PatchGlobalLocation", patchGlobalLocation);
4205
- compiler.hooks.watchRun.tap("PatchGlobalLocation", patchGlobalLocation);
4206
- compiler.hooks.watchClose.tap("PatchGlobalLocation", unpatchGlobalLocation);
4207
- compiler.hooks.done.tap("PatchGlobalLocation", unpatchGlobalLocation);
4208
- }
4209
- function pluginSass() {
4210
- return {
4211
- name: "rsbuild:sass",
4212
- setup(api) {
4213
- api.onAfterCreateCompiler(({ compiler }) => {
4214
- patchCompilerGlobalLocation(compiler);
4215
- });
4216
- api.modifyBundlerChain(async (chain, utils) => {
4217
- const config = api.getNormalizedConfig();
4218
- const { applyCSSRule: applyCSSRule2 } = await Promise.resolve().then(() => (init_css(), css_exports));
4219
- const { excludes, options } = getSassLoaderOptions(
4220
- config.tools.sass,
4221
- // source-maps required for loaders preceding resolve-url-loader
4222
- // otherwise the resolve-url-loader will throw an error
4223
- true
4224
- );
4225
- const rule = chain.module.rule(utils.CHAIN_ID.RULE.SASS).test(/\.s(?:a|c)ss$/);
4226
- for (const item of excludes) {
4227
- rule.exclude.add(item);
4228
- }
4229
- await applyCSSRule2({
4230
- rule,
4231
- utils,
4232
- config,
4233
- context: api.context,
4234
- // postcss-loader, resolve-url-loader, sass-loader
4235
- importLoaders: 3
4236
- });
4237
- rule.use(utils.CHAIN_ID.USE.RESOLVE_URL).loader(getCompiledPath("resolve-url-loader")).options({
4238
- join: await getResolveUrlJoinFn(),
4239
- // 'resolve-url-loader' relies on 'adjust-sourcemap-loader',
4240
- // it has performance regression issues in some scenarios,
4241
- // so we need to disable the sourceMap option.
4242
- sourceMap: false
4243
- }).end().use(utils.CHAIN_ID.USE.SASS).loader((0, import_shared38.getSharedPkgCompiledPath)("sass-loader")).options(options);
4244
- });
4245
- }
4246
- };
4247
- }
4248
- var import_node_path22, import_node_url2, import_shared38, GLOBAL_PATCHED_SYMBOL, getSassLoaderOptions, getResolveUrlJoinFn;
4249
- var init_sass = __esm({
4250
- "src/plugins/sass.ts"() {
4251
- "use strict";
4252
- import_node_path22 = __toESM(require("path"));
4253
- import_node_url2 = require("url");
4254
- import_shared38 = require("@rsbuild/shared");
4255
- init_helpers();
4256
- GLOBAL_PATCHED_SYMBOL = Symbol("GLOBAL_PATCHED_SYMBOL");
4257
- getSassLoaderOptions = (rsbuildSassConfig, isUseCssSourceMap) => {
4258
- const excludes = [];
4259
- const addExcludes = (items) => {
4260
- excludes.push(...(0, import_shared38.castArray)(items));
4261
- };
4262
- const mergeFn = (defaults, userOptions) => {
4263
- const getSassOptions = () => {
4264
- if (defaults.sassOptions && userOptions.sassOptions) {
4265
- return (0, import_shared38.deepmerge)(
4266
- defaults.sassOptions,
4267
- userOptions.sassOptions
4268
- );
4269
- }
4270
- return userOptions.sassOptions || defaults.sassOptions;
4271
- };
4272
- return {
4273
- ...defaults,
4274
- ...userOptions,
4275
- sassOptions: getSassOptions()
4276
- };
4277
- };
4278
- const mergedOptions = (0, import_shared38.mergeChainedOptions)({
4279
- defaults: {
4280
- sourceMap: isUseCssSourceMap,
4281
- implementation: (0, import_shared38.getSharedPkgCompiledPath)("sass")
4282
- },
4283
- options: rsbuildSassConfig,
4284
- utils: { addExcludes },
4285
- mergeFn
4286
- });
4287
- return {
4288
- options: mergedOptions,
4289
- excludes
4290
- };
4291
- };
4292
- getResolveUrlJoinFn = async () => {
4293
- const {
4294
- createJoinFunction,
4295
- asGenerator,
4296
- createJoinImplementation,
4297
- defaultJoinGenerator
4298
- } = await import("../compiled/resolve-url-loader/index.js");
4299
- const rsbuildGenerator = asGenerator((item, ...rest) => {
4300
- if (!item.uri.startsWith(".")) {
4301
- return [null];
4302
- }
4303
- return defaultJoinGenerator(item, ...rest);
4304
- });
4305
- return createJoinFunction(
4306
- "rsbuild-resolve-join-fn",
4307
- createJoinImplementation(rsbuildGenerator)
4308
- );
4309
- };
4310
- }
4311
- });
4312
-
4313
4099
  // src/plugins/server.ts
4314
4100
  var server_exports = {};
4315
4101
  __export(server_exports, {
4316
4102
  pluginServer: () => pluginServer
4317
4103
  });
4318
- var import_node_path23, import_shared39, pluginServer;
4104
+ var import_node_path21, import_shared37, pluginServer;
4319
4105
  var init_server = __esm({
4320
4106
  "src/plugins/server.ts"() {
4321
4107
  "use strict";
4322
- import_node_path23 = require("path");
4323
- import_shared39 = require("@rsbuild/shared");
4108
+ import_node_path21 = require("path");
4109
+ import_shared37 = require("@rsbuild/shared");
4324
4110
  pluginServer = () => ({
4325
4111
  name: "rsbuild:server",
4326
4112
  setup(api) {
@@ -4331,12 +4117,12 @@ var init_server = __esm({
4331
4117
  if (!copyOnBuild || !name) {
4332
4118
  return;
4333
4119
  }
4334
- const publicDir = (0, import_node_path23.isAbsolute)(name) ? name : (0, import_node_path23.join)(api.context.rootPath, name);
4335
- if (!import_shared39.fse.existsSync(publicDir)) {
4120
+ const publicDir = (0, import_node_path21.isAbsolute)(name) ? name : (0, import_node_path21.join)(api.context.rootPath, name);
4121
+ if (!import_shared37.fse.existsSync(publicDir)) {
4336
4122
  return;
4337
4123
  }
4338
4124
  try {
4339
- await import_shared39.fse.copy(publicDir, api.context.distPath, {
4125
+ await import_shared37.fse.copy(publicDir, api.context.distPath, {
4340
4126
  // dereference symlinks
4341
4127
  dereference: true
4342
4128
  });
@@ -4386,18 +4172,18 @@ function pluginModuleFederation() {
4386
4172
  chain.plugin("mf-patch-split-chunks").use(PatchSplitChunksPlugin, [options.name]);
4387
4173
  }
4388
4174
  const publicPath = chain.output.get("publicPath");
4389
- if (publicPath === import_shared40.DEFAULT_ASSET_PREFIX) {
4175
+ if (publicPath === import_shared38.DEFAULT_ASSET_PREFIX) {
4390
4176
  chain.output.set("publicPath", "auto");
4391
4177
  }
4392
4178
  });
4393
4179
  }
4394
4180
  };
4395
4181
  }
4396
- var import_shared40, import_core4, PatchSplitChunksPlugin;
4182
+ var import_shared38, import_core4, PatchSplitChunksPlugin;
4397
4183
  var init_moduleFederation = __esm({
4398
4184
  "src/plugins/moduleFederation.ts"() {
4399
4185
  "use strict";
4400
- import_shared40 = require("@rsbuild/shared");
4186
+ import_shared38 = require("@rsbuild/shared");
4401
4187
  import_core4 = require("@rspack/core");
4402
4188
  PatchSplitChunksPlugin = class {
4403
4189
  constructor(name) {
@@ -4605,8 +4391,6 @@ var init_plugins = __esm({
4605
4391
  performance: () => Promise.resolve().then(() => (init_performance(), performance_exports)).then((m) => m.pluginPerformance()),
4606
4392
  define: () => Promise.resolve().then(() => (init_define(), define_exports)).then((m) => m.pluginDefine()),
4607
4393
  css: () => Promise.resolve().then(() => (init_css(), css_exports)).then((m) => m.pluginCss()),
4608
- less: () => Promise.resolve().then(() => (init_less(), less_exports)).then((m) => m.pluginLess()),
4609
- sass: () => Promise.resolve().then(() => (init_sass(), sass_exports)).then((m) => m.pluginSass()),
4610
4394
  server: () => Promise.resolve().then(() => (init_server(), server_exports)).then((m) => m.pluginServer()),
4611
4395
  moduleFederation: () => Promise.resolve().then(() => (init_moduleFederation(), moduleFederation_exports)).then((m) => m.pluginModuleFederation()),
4612
4396
  manifest: () => Promise.resolve().then(() => (init_manifest(), manifest_exports)).then((m) => m.pluginManifest())
@@ -4627,9 +4411,9 @@ async function inspectConfig({
4627
4411
  inspectOptions = {}
4628
4412
  }) {
4629
4413
  if (inspectOptions.env) {
4630
- (0, import_shared41.setNodeEnv)(inspectOptions.env);
4631
- } else if (!(0, import_shared41.getNodeEnv)()) {
4632
- (0, import_shared41.setNodeEnv)("development");
4414
+ (0, import_shared39.setNodeEnv)(inspectOptions.env);
4415
+ } else if (!(0, import_shared39.getNodeEnv)()) {
4416
+ (0, import_shared39.setNodeEnv)("development");
4633
4417
  }
4634
4418
  const rspackConfigs = bundlerConfigs || (await initConfigs({
4635
4419
  context,
@@ -4640,21 +4424,21 @@ async function inspectConfig({
4640
4424
  ...context.normalizedConfig,
4641
4425
  pluginNames: pluginManager.getPlugins().map((p) => p.name)
4642
4426
  };
4643
- const rawRsbuildConfig = await (0, import_shared41.stringifyConfig)(
4427
+ const rawRsbuildConfig = await (0, import_shared39.stringifyConfig)(
4644
4428
  rsbuildDebugConfig,
4645
4429
  inspectOptions.verbose
4646
4430
  );
4647
4431
  const rawBundlerConfigs = await Promise.all(
4648
4432
  rspackConfigs.map(
4649
- (config) => (0, import_shared41.stringifyConfig)(config, inspectOptions.verbose)
4433
+ (config) => (0, import_shared39.stringifyConfig)(config, inspectOptions.verbose)
4650
4434
  )
4651
4435
  );
4652
4436
  let outputPath = inspectOptions.outputPath || context.distPath;
4653
- if (!(0, import_node_path24.isAbsolute)(outputPath)) {
4654
- outputPath = (0, import_node_path24.join)(context.rootPath, outputPath);
4437
+ if (!(0, import_node_path22.isAbsolute)(outputPath)) {
4438
+ outputPath = (0, import_node_path22.join)(context.rootPath, outputPath);
4655
4439
  }
4656
4440
  if (inspectOptions.writeToDisk) {
4657
- await (0, import_shared41.outputInspectConfigFiles)({
4441
+ await (0, import_shared39.outputInspectConfigFiles)({
4658
4442
  rsbuildConfig: context.normalizedConfig,
4659
4443
  rawRsbuildConfig,
4660
4444
  bundlerConfigs: rawBundlerConfigs,
@@ -4674,32 +4458,32 @@ async function inspectConfig({
4674
4458
  }
4675
4459
  };
4676
4460
  }
4677
- var import_node_path24, import_shared41;
4461
+ var import_node_path22, import_shared39;
4678
4462
  var init_inspectConfig = __esm({
4679
4463
  "src/provider/inspectConfig.ts"() {
4680
4464
  "use strict";
4681
- import_node_path24 = require("path");
4682
- import_shared41 = require("@rsbuild/shared");
4465
+ import_node_path22 = require("path");
4466
+ import_shared39 = require("@rsbuild/shared");
4683
4467
  init_initConfigs();
4684
4468
  }
4685
4469
  });
4686
4470
 
4687
4471
  // src/provider/rspackConfig.ts
4688
4472
  async function modifyRspackConfig(context, rspackConfig, utils) {
4689
- (0, import_shared42.debug)("modify Rspack config");
4473
+ (0, import_shared40.debug)("modify Rspack config");
4690
4474
  let [modifiedConfig] = await context.hooks.modifyRspackConfig.call(
4691
4475
  rspackConfig,
4692
4476
  utils
4693
4477
  );
4694
4478
  if (context.config.tools?.rspack) {
4695
- modifiedConfig = (0, import_shared42.mergeChainedOptions)({
4479
+ modifiedConfig = (0, import_shared40.mergeChainedOptions)({
4696
4480
  defaults: modifiedConfig,
4697
4481
  options: context.config.tools.rspack,
4698
4482
  utils,
4699
4483
  mergeFn: utils.mergeConfig
4700
4484
  });
4701
4485
  }
4702
- (0, import_shared42.debug)("modify Rspack config done");
4486
+ (0, import_shared40.debug)("modify Rspack config done");
4703
4487
  return modifiedConfig;
4704
4488
  }
4705
4489
  async function getConfigUtils(config, chainUtils) {
@@ -4709,7 +4493,7 @@ async function getConfigUtils(config, chainUtils) {
4709
4493
  rspack: import_core5.rspack,
4710
4494
  mergeConfig: merge2,
4711
4495
  addRules(rules) {
4712
- const ruleArr = (0, import_shared42.castArray)(rules);
4496
+ const ruleArr = (0, import_shared40.castArray)(rules);
4713
4497
  if (!config.module) {
4714
4498
  config.module = {};
4715
4499
  }
@@ -4719,14 +4503,14 @@ async function getConfigUtils(config, chainUtils) {
4719
4503
  config.module.rules.unshift(...ruleArr);
4720
4504
  },
4721
4505
  prependPlugins(plugins2) {
4722
- const pluginArr = (0, import_shared42.castArray)(plugins2);
4506
+ const pluginArr = (0, import_shared40.castArray)(plugins2);
4723
4507
  if (!config.plugins) {
4724
4508
  config.plugins = [];
4725
4509
  }
4726
4510
  config.plugins.unshift(...pluginArr);
4727
4511
  },
4728
4512
  appendPlugins(plugins2) {
4729
- const pluginArr = (0, import_shared42.castArray)(plugins2);
4513
+ const pluginArr = (0, import_shared40.castArray)(plugins2);
4730
4514
  if (!config.plugins) {
4731
4515
  config.plugins = [];
4732
4516
  }
@@ -4742,7 +4526,7 @@ async function getConfigUtils(config, chainUtils) {
4742
4526
  };
4743
4527
  }
4744
4528
  function getChainUtils(target) {
4745
- const nodeEnv = (0, import_shared42.getNodeEnv)();
4529
+ const nodeEnv = (0, import_shared40.getNodeEnv)();
4746
4530
  return {
4747
4531
  env: nodeEnv,
4748
4532
  target,
@@ -4751,7 +4535,7 @@ function getChainUtils(target) {
4751
4535
  isServer: target === "node",
4752
4536
  isWebWorker: target === "web-worker",
4753
4537
  isServiceWorker: target === "service-worker",
4754
- CHAIN_ID: import_shared42.CHAIN_ID,
4538
+ CHAIN_ID: import_shared40.CHAIN_ID,
4755
4539
  HtmlPlugin: getHTMLPlugin()
4756
4540
  };
4757
4541
  }
@@ -4767,7 +4551,7 @@ async function generateRspackConfig({
4767
4551
  ProvidePlugin,
4768
4552
  HotModuleReplacementPlugin
4769
4553
  } = import_core5.rspack;
4770
- const chain = await (0, import_shared42.modifyBundlerChain)(context, {
4554
+ const chain = await (0, import_shared40.modifyBundlerChain)(context, {
4771
4555
  ...chainUtils,
4772
4556
  bundler: {
4773
4557
  BannerPlugin,
@@ -4777,7 +4561,7 @@ async function generateRspackConfig({
4777
4561
  HotModuleReplacementPlugin
4778
4562
  }
4779
4563
  });
4780
- let rspackConfig = (0, import_shared42.chainToConfig)(chain);
4564
+ let rspackConfig = (0, import_shared40.chainToConfig)(chain);
4781
4565
  rspackConfig = await modifyRspackConfig(
4782
4566
  context,
4783
4567
  rspackConfig,
@@ -4785,11 +4569,11 @@ async function generateRspackConfig({
4785
4569
  );
4786
4570
  return rspackConfig;
4787
4571
  }
4788
- var import_shared42, import_core5;
4572
+ var import_shared40, import_core5;
4789
4573
  var init_rspackConfig = __esm({
4790
4574
  "src/provider/rspackConfig.ts"() {
4791
4575
  "use strict";
4792
- import_shared42 = require("@rsbuild/shared");
4576
+ import_shared40 = require("@rsbuild/shared");
4793
4577
  import_core5 = require("@rspack/core");
4794
4578
  init_pluginHelper();
4795
4579
  }
@@ -4797,13 +4581,13 @@ var init_rspackConfig = __esm({
4797
4581
 
4798
4582
  // src/provider/initConfigs.ts
4799
4583
  async function modifyRsbuildConfig(context) {
4800
- (0, import_shared43.debug)("modify Rsbuild config");
4584
+ (0, import_shared41.debug)("modify Rsbuild config");
4801
4585
  const [modified] = await context.hooks.modifyRsbuildConfig.call(
4802
4586
  context.config,
4803
4587
  { mergeRsbuildConfig }
4804
4588
  );
4805
4589
  context.config = modified;
4806
- (0, import_shared43.debug)("modify Rsbuild config done");
4590
+ (0, import_shared41.debug)("modify Rsbuild config done");
4807
4591
  }
4808
4592
  async function initRsbuildConfig({
4809
4593
  context,
@@ -4831,7 +4615,7 @@ async function initConfigs({
4831
4615
  const rspackConfigs = await Promise.all(
4832
4616
  targets.map((target) => generateRspackConfig({ target, context }))
4833
4617
  );
4834
- if ((0, import_shared43.isDebug)()) {
4618
+ if ((0, import_shared41.isDebug)()) {
4835
4619
  const inspect = () => {
4836
4620
  const inspectOptions = {
4837
4621
  verbose: true,
@@ -4852,11 +4636,11 @@ async function initConfigs({
4852
4636
  rspackConfigs
4853
4637
  };
4854
4638
  }
4855
- var import_shared43;
4639
+ var import_shared41;
4856
4640
  var init_initConfigs = __esm({
4857
4641
  "src/provider/initConfigs.ts"() {
4858
4642
  "use strict";
4859
- import_shared43 = require("@rsbuild/shared");
4643
+ import_shared41 = require("@rsbuild/shared");
4860
4644
  init_config();
4861
4645
  init_createContext();
4862
4646
  init_mergeConfig();
@@ -4878,7 +4662,7 @@ function applyHMREntry({
4878
4662
  clientConfig = {},
4879
4663
  liveReload = true
4880
4664
  }) {
4881
- if (!(0, import_shared44.isClientCompiler)(compiler)) {
4665
+ if (!(0, import_shared42.isClientCompiler)(compiler)) {
4882
4666
  return;
4883
4667
  }
4884
4668
  new compiler.webpack.DefinePlugin({
@@ -4891,13 +4675,13 @@ function applyHMREntry({
4891
4675
  }).apply(compiler);
4892
4676
  }
4893
4677
  }
4894
- var import_shared44, setupServerHooks, getDevMiddleware;
4678
+ var import_shared42, setupServerHooks, getDevMiddleware;
4895
4679
  var init_devMiddleware = __esm({
4896
4680
  "src/server/devMiddleware.ts"() {
4897
4681
  "use strict";
4898
- import_shared44 = require("@rsbuild/shared");
4682
+ import_shared42 = require("@rsbuild/shared");
4899
4683
  setupServerHooks = (compiler, hookCallbacks) => {
4900
- if ((0, import_shared44.isNodeCompiler)(compiler)) {
4684
+ if ((0, import_shared42.isNodeCompiler)(compiler)) {
4901
4685
  return;
4902
4686
  }
4903
4687
  const { compile, invalid, done } = compiler.hooks;
@@ -4920,7 +4704,7 @@ var init_devMiddleware = __esm({
4920
4704
  }
4921
4705
  setupServerHooks(compiler, callbacks);
4922
4706
  };
4923
- (0, import_shared44.applyToCompiler)(multiCompiler, setupCompiler);
4707
+ (0, import_shared42.applyToCompiler)(multiCompiler, setupCompiler);
4924
4708
  return webpackDevMiddleware(multiCompiler, restOptions);
4925
4709
  };
4926
4710
  };
@@ -4937,13 +4721,13 @@ async function createCompiler({
4937
4721
  context,
4938
4722
  rspackConfigs
4939
4723
  }) {
4940
- (0, import_shared45.debug)("create compiler");
4724
+ (0, import_shared43.debug)("create compiler");
4941
4725
  await context.hooks.onBeforeCreateCompiler.call({
4942
4726
  bundlerConfigs: rspackConfigs
4943
4727
  });
4944
4728
  if (!await isSatisfyRspackVersion(import_core6.rspack.rspackVersion)) {
4945
4729
  throw new Error(
4946
- `The current Rspack version does not meet the requirements, the minimum supported version of Rspack is ${import_shared45.color.green(
4730
+ `The current Rspack version does not meet the requirements, the minimum supported version of Rspack is ${import_shared43.color.green(
4947
4731
  rspackMinVersion
4948
4732
  )}`
4949
4733
  );
@@ -4954,18 +4738,18 @@ async function createCompiler({
4954
4738
  let isCompiling = false;
4955
4739
  const logRspackVersion = () => {
4956
4740
  if (!isVersionLogged) {
4957
- (0, import_shared45.debug)(`Use Rspack v${import_core6.rspack.rspackVersion}`);
4741
+ (0, import_shared43.debug)(`Use Rspack v${import_core6.rspack.rspackVersion}`);
4958
4742
  isVersionLogged = true;
4959
4743
  }
4960
4744
  };
4961
4745
  compiler.hooks.watchRun.tap("rsbuild:compiling", () => {
4962
4746
  logRspackVersion();
4963
4747
  if (!isCompiling) {
4964
- import_shared45.logger.start("Compiling...");
4748
+ import_shared43.logger.start("Compiling...");
4965
4749
  }
4966
4750
  isCompiling = true;
4967
4751
  });
4968
- if ((0, import_shared45.isProd)()) {
4752
+ if ((0, import_shared43.isProd)()) {
4969
4753
  compiler.hooks.run.tap("rsbuild:run", logRspackVersion);
4970
4754
  }
4971
4755
  const done = async (stats) => {
@@ -4975,10 +4759,10 @@ async function createCompiler({
4975
4759
  });
4976
4760
  const printTime = (c, index) => {
4977
4761
  if (c.time) {
4978
- const time = (0, import_shared45.prettyTime)(c.time / 1e3);
4762
+ const time = (0, import_shared43.prettyTime)(c.time / 1e3);
4979
4763
  const target = context.targets[index];
4980
- const name = import_shared45.TARGET_ID_MAP[target || "web"];
4981
- import_shared45.logger.ready(`${name} compiled in ${time}`);
4764
+ const name = import_shared43.TARGET_ID_MAP[target || "web"];
4765
+ import_shared43.logger.ready(`${name} compiled in ${time}`);
4982
4766
  }
4983
4767
  };
4984
4768
  if (!stats.hasErrors()) {
@@ -4992,12 +4776,12 @@ async function createCompiler({
4992
4776
  }
4993
4777
  const { message, level } = formatStats(stats, getStatsOptions(compiler));
4994
4778
  if (level === "error") {
4995
- import_shared45.logger.error(message);
4779
+ import_shared43.logger.error(message);
4996
4780
  }
4997
4781
  if (level === "warning") {
4998
- import_shared45.logger.warn(message);
4782
+ import_shared43.logger.warn(message);
4999
4783
  }
5000
- if ((0, import_shared45.isDev)()) {
4784
+ if ((0, import_shared43.isDev)()) {
5001
4785
  await context.hooks.onDevCompileDone.call({
5002
4786
  isFirstCompile,
5003
4787
  stats
@@ -5006,14 +4790,14 @@ async function createCompiler({
5006
4790
  isCompiling = false;
5007
4791
  isFirstCompile = false;
5008
4792
  };
5009
- (0, import_shared45.onCompileDone)(
4793
+ (0, import_shared43.onCompileDone)(
5010
4794
  compiler,
5011
4795
  done,
5012
4796
  // @ts-expect-error type mismatch
5013
4797
  import_core6.rspack.MultiStats
5014
4798
  );
5015
4799
  await context.hooks.onAfterCreateCompiler.call({ compiler });
5016
- (0, import_shared45.debug)("create compiler done");
4800
+ (0, import_shared43.debug)("create compiler done");
5017
4801
  return compiler;
5018
4802
  }
5019
4803
  async function createDevMiddleware(options, customCompiler) {
@@ -5033,11 +4817,11 @@ async function createDevMiddleware(options, customCompiler) {
5033
4817
  compiler
5034
4818
  };
5035
4819
  }
5036
- var import_shared45, import_core6;
4820
+ var import_shared43, import_core6;
5037
4821
  var init_createCompiler = __esm({
5038
4822
  "src/provider/createCompiler.ts"() {
5039
4823
  "use strict";
5040
- import_shared45 = require("@rsbuild/shared");
4824
+ import_shared43 = require("@rsbuild/shared");
5041
4825
  import_core6 = require("@rspack/core");
5042
4826
  init_helpers();
5043
4827
  init_initConfigs();
@@ -5049,11 +4833,11 @@ var progress_exports = {};
5049
4833
  __export(progress_exports, {
5050
4834
  pluginProgress: () => pluginProgress
5051
4835
  });
5052
- var import_shared46, import_core7, pluginProgress;
4836
+ var import_shared44, import_core7, pluginProgress;
5053
4837
  var init_progress = __esm({
5054
4838
  "src/plugins/progress.ts"() {
5055
4839
  "use strict";
5056
- import_shared46 = require("@rsbuild/shared");
4840
+ import_shared44 = require("@rsbuild/shared");
5057
4841
  import_core7 = require("@rspack/core");
5058
4842
  pluginProgress = () => ({
5059
4843
  name: "rsbuild:progress",
@@ -5061,11 +4845,11 @@ var init_progress = __esm({
5061
4845
  api.modifyBundlerChain(async (chain, { target, CHAIN_ID: CHAIN_ID3 }) => {
5062
4846
  const config = api.getNormalizedConfig();
5063
4847
  const options = config.dev.progressBar ?? // enable progress bar in production by default
5064
- (0, import_shared46.isProd)();
4848
+ (0, import_shared44.isProd)();
5065
4849
  if (!options) {
5066
4850
  return;
5067
4851
  }
5068
- const prefix = options !== true && options.id !== void 0 ? options.id : import_shared46.TARGET_ID_MAP[target];
4852
+ const prefix = options !== true && options.id !== void 0 ? options.id : import_shared44.TARGET_ID_MAP[target];
5069
4853
  chain.plugin(CHAIN_ID3.PLUGIN.PROGRESS).use(import_core7.rspack.ProgressPlugin, [
5070
4854
  {
5071
4855
  prefix,
@@ -5099,14 +4883,14 @@ async function getDefaultSwcConfig(config, rootPath, target) {
5099
4883
  },
5100
4884
  isModule: "unknown",
5101
4885
  env: {
5102
- targets: await (0, import_shared47.getBrowserslistWithDefault)(rootPath, config, target)
4886
+ targets: await (0, import_shared45.getBrowserslistWithDefault)(rootPath, config, target)
5103
4887
  }
5104
4888
  };
5105
4889
  }
5106
4890
  async function applyCoreJs(swcConfig, chain, polyfillMode) {
5107
4891
  const coreJsPath = require.resolve("core-js/package.json");
5108
- const version2 = (0, import_shared47.getCoreJsVersion)(coreJsPath);
5109
- const coreJsDir = import_node_path25.default.dirname(coreJsPath);
4892
+ const version2 = (0, import_shared45.getCoreJsVersion)(coreJsPath);
4893
+ const coreJsDir = import_node_path23.default.dirname(coreJsPath);
5110
4894
  swcConfig.env.coreJs = version2;
5111
4895
  if (polyfillMode === "usage") {
5112
4896
  swcConfig.env.shippedProposals = true;
@@ -5142,12 +4926,12 @@ function applySwcDecoratorConfig(swcConfig, config) {
5142
4926
  throw new Error("Unknown decorators version: ${version}");
5143
4927
  }
5144
4928
  }
5145
- var import_node_path25, import_shared47, builtinSwcLoaderName, pluginSwc;
4929
+ var import_node_path23, import_shared45, builtinSwcLoaderName, pluginSwc;
5146
4930
  var init_swc = __esm({
5147
4931
  "src/plugins/swc.ts"() {
5148
4932
  "use strict";
5149
- import_node_path25 = __toESM(require("path"));
5150
- import_shared47 = require("@rsbuild/shared");
4933
+ import_node_path23 = __toESM(require("path"));
4934
+ import_shared45 = require("@rsbuild/shared");
5151
4935
  init_constants();
5152
4936
  builtinSwcLoaderName = "builtin:swc-loader";
5153
4937
  pluginSwc = () => ({
@@ -5157,8 +4941,8 @@ var init_swc = __esm({
5157
4941
  order: "pre",
5158
4942
  handler: async (chain, { CHAIN_ID: CHAIN_ID3, target }) => {
5159
4943
  const config = api.getNormalizedConfig();
5160
- const rule = chain.module.rule(CHAIN_ID3.RULE.JS).test(import_shared47.SCRIPT_REGEX).type("javascript/auto");
5161
- (0, import_shared47.applyScriptCondition)({
4944
+ const rule = chain.module.rule(CHAIN_ID3.RULE.JS).test(import_shared45.SCRIPT_REGEX).type("javascript/auto");
4945
+ (0, import_shared45.applyScriptCondition)({
5162
4946
  rule,
5163
4947
  chain,
5164
4948
  config,
@@ -5176,10 +4960,10 @@ var init_swc = __esm({
5176
4960
  if (swcConfig.jsc?.externalHelpers) {
5177
4961
  chain.resolve.alias.set(
5178
4962
  "@swc/helpers",
5179
- import_node_path25.default.dirname(require.resolve("@swc/helpers/package.json"))
4963
+ import_node_path23.default.dirname(require.resolve("@swc/helpers/package.json"))
5180
4964
  );
5181
4965
  }
5182
- if ((0, import_shared47.isWebTarget)(target)) {
4966
+ if ((0, import_shared45.isWebTarget)(target)) {
5183
4967
  const polyfillMode = config.output.polyfill;
5184
4968
  if (polyfillMode === "off") {
5185
4969
  swcConfig.env.mode = void 0;
@@ -5188,15 +4972,15 @@ var init_swc = __esm({
5188
4972
  await applyCoreJs(swcConfig, chain, polyfillMode);
5189
4973
  }
5190
4974
  }
5191
- const mergedSwcConfig = (0, import_shared47.mergeChainedOptions)({
4975
+ const mergedSwcConfig = (0, import_shared45.mergeChainedOptions)({
5192
4976
  defaults: swcConfig,
5193
4977
  options: config.tools.swc,
5194
- mergeFn: import_shared47.deepmerge
4978
+ mergeFn: import_shared45.deepmerge
5195
4979
  });
5196
4980
  rule.use(CHAIN_ID3.USE.SWC).loader(builtinSwcLoaderName).options(mergedSwcConfig);
5197
4981
  chain.module.rule(CHAIN_ID3.RULE.JS_DATA_URI).mimetype({
5198
4982
  or: ["text/javascript", "application/javascript"]
5199
- }).resolve.set("fullySpecified", false).end().use(CHAIN_ID3.USE.SWC).loader(builtinSwcLoaderName).options((0, import_shared47.cloneDeep)(mergedSwcConfig));
4983
+ }).resolve.set("fullySpecified", false).end().use(CHAIN_ID3.USE.SWC).loader(builtinSwcLoaderName).options((0, import_shared45.cloneDeep)(mergedSwcConfig));
5200
4984
  }
5201
4985
  });
5202
4986
  }
@@ -5210,14 +4994,14 @@ __export(rspackProfile_exports, {
5210
4994
  pluginRspackProfile: () => pluginRspackProfile,
5211
4995
  stopProfiler: () => stopProfiler
5212
4996
  });
5213
- var import_node_inspector, import_node_path26, import_shared48, import_shared49, import_core8, stopProfiler, pluginRspackProfile;
4997
+ var import_node_inspector, import_node_path24, import_shared46, import_shared47, import_core8, stopProfiler, pluginRspackProfile;
5214
4998
  var init_rspackProfile = __esm({
5215
4999
  "src/plugins/rspackProfile.ts"() {
5216
5000
  "use strict";
5217
5001
  import_node_inspector = __toESM(require("inspector"));
5218
- import_node_path26 = __toESM(require("path"));
5219
- import_shared48 = require("@rsbuild/shared");
5220
- import_shared49 = require("@rsbuild/shared");
5002
+ import_node_path24 = __toESM(require("path"));
5003
+ import_shared46 = require("@rsbuild/shared");
5004
+ import_shared47 = require("@rsbuild/shared");
5221
5005
  import_core8 = require("@rspack/core");
5222
5006
  stopProfiler = (output, profileSession) => {
5223
5007
  if (!profileSession) {
@@ -5225,10 +5009,10 @@ var init_rspackProfile = __esm({
5225
5009
  }
5226
5010
  profileSession.post("Profiler.stop", (error, param) => {
5227
5011
  if (error) {
5228
- import_shared49.logger.error("Failed to generate JS CPU profile:", error);
5012
+ import_shared47.logger.error("Failed to generate JS CPU profile:", error);
5229
5013
  return;
5230
5014
  }
5231
- import_shared48.fse.writeFileSync(output, JSON.stringify(param.profile));
5015
+ import_shared46.fse.writeFileSync(output, JSON.stringify(param.profile));
5232
5016
  });
5233
5017
  };
5234
5018
  pluginRspackProfile = () => ({
@@ -5239,7 +5023,7 @@ var init_rspackProfile = __esm({
5239
5023
  return;
5240
5024
  }
5241
5025
  const timestamp = Date.now();
5242
- const profileDir = import_node_path26.default.join(
5026
+ const profileDir = import_node_path24.default.join(
5243
5027
  api.context.distPath,
5244
5028
  `rspack-profile-${timestamp}`
5245
5029
  );
@@ -5247,11 +5031,11 @@ var init_rspackProfile = __esm({
5247
5031
  const enableProfileTrace = RSPACK_PROFILE === "ALL" || RSPACK_PROFILE.includes("TRACE");
5248
5032
  const enableCPUProfile = RSPACK_PROFILE === "ALL" || RSPACK_PROFILE.includes("CPU");
5249
5033
  const enableLogging = RSPACK_PROFILE === "ALL" || RSPACK_PROFILE.includes("LOGGING");
5250
- const traceFilePath = import_node_path26.default.join(profileDir, "trace.json");
5251
- const cpuProfilePath = import_node_path26.default.join(profileDir, "jscpuprofile.json");
5252
- const loggingFilePath = import_node_path26.default.join(profileDir, "logging.json");
5034
+ const traceFilePath = import_node_path24.default.join(profileDir, "trace.json");
5035
+ const cpuProfilePath = import_node_path24.default.join(profileDir, "jscpuprofile.json");
5036
+ const loggingFilePath = import_node_path24.default.join(profileDir, "logging.json");
5253
5037
  const onStart = () => {
5254
- import_shared48.fse.ensureDirSync(profileDir);
5038
+ import_shared46.fse.ensureDirSync(profileDir);
5255
5039
  if (enableProfileTrace) {
5256
5040
  import_core8.rspack.experimental_registerGlobalTrace(
5257
5041
  "trace",
@@ -5275,7 +5059,7 @@ var init_rspackProfile = __esm({
5275
5059
  logging: "verbose",
5276
5060
  loggingTrace: true
5277
5061
  });
5278
- import_shared48.fse.writeFileSync(loggingFilePath, JSON.stringify(logging));
5062
+ import_shared46.fse.writeFileSync(loggingFilePath, JSON.stringify(logging));
5279
5063
  }
5280
5064
  });
5281
5065
  api.onExit(() => {
@@ -5283,7 +5067,7 @@ var init_rspackProfile = __esm({
5283
5067
  import_core8.rspack.experimental_cleanupGlobalTrace();
5284
5068
  }
5285
5069
  stopProfiler(cpuProfilePath, profileSession);
5286
- import_shared49.logger.info(`Saved Rspack profile file to ${profileDir}`);
5070
+ import_shared47.logger.info(`Saved Rspack profile file to ${profileDir}`);
5287
5071
  });
5288
5072
  }
5289
5073
  });
@@ -5291,13 +5075,13 @@ var init_rspackProfile = __esm({
5291
5075
  });
5292
5076
 
5293
5077
  // src/server/middlewares.ts
5294
- var import_node_path27, import_node_url3, import_shared50, faviconFallbackMiddleware, getStatusCodeColor, getRequestLoggerMiddleware, notFoundMiddleware, getHtmlFallbackMiddleware;
5078
+ var import_node_path25, import_node_url2, import_shared48, faviconFallbackMiddleware, getStatusCodeColor, getRequestLoggerMiddleware, notFoundMiddleware, getHtmlFallbackMiddleware;
5295
5079
  var init_middlewares = __esm({
5296
5080
  "src/server/middlewares.ts"() {
5297
5081
  "use strict";
5298
- import_node_path27 = __toESM(require("path"));
5299
- import_node_url3 = require("url");
5300
- import_shared50 = require("@rsbuild/shared");
5082
+ import_node_path25 = __toESM(require("path"));
5083
+ import_node_url2 = require("url");
5084
+ import_shared48 = require("@rsbuild/shared");
5301
5085
  faviconFallbackMiddleware = (req, res, next) => {
5302
5086
  if (req.url === "/favicon.ico") {
5303
5087
  res.statusCode = 204;
@@ -5308,16 +5092,16 @@ var init_middlewares = __esm({
5308
5092
  };
5309
5093
  getStatusCodeColor = (status) => {
5310
5094
  if (status >= 500) {
5311
- return import_shared50.color.red;
5095
+ return import_shared48.color.red;
5312
5096
  }
5313
5097
  if (status >= 400) {
5314
- return import_shared50.color.yellow;
5098
+ return import_shared48.color.yellow;
5315
5099
  }
5316
5100
  if (status >= 300) {
5317
- return import_shared50.color.cyan;
5101
+ return import_shared48.color.cyan;
5318
5102
  }
5319
5103
  if (status >= 200) {
5320
- return import_shared50.color.green;
5104
+ return import_shared48.color.green;
5321
5105
  }
5322
5106
  return (res) => res;
5323
5107
  };
@@ -5332,8 +5116,8 @@ var init_middlewares = __esm({
5332
5116
  const statusColor = getStatusCodeColor(status);
5333
5117
  const endAt = process.hrtime();
5334
5118
  const totalTime = (endAt[0] - _startAt[0]) * 1e3 + (endAt[1] - _startAt[1]) * 1e-6;
5335
- (0, import_shared50.debug)(
5336
- `${statusColor(status)} ${method} ${import_shared50.color.gray(url2)} ${import_shared50.color.gray(
5119
+ (0, import_shared48.debug)(
5120
+ `${statusColor(status)} ${method} ${import_shared48.color.gray(url2)} ${import_shared48.color.gray(
5337
5121
  `${totalTime.toFixed(3)} ms`
5338
5122
  )}`
5339
5123
  );
@@ -5360,10 +5144,10 @@ var init_middlewares = __esm({
5360
5144
  const { url: url2 } = req;
5361
5145
  let pathname = url2;
5362
5146
  try {
5363
- pathname = (0, import_node_url3.parse)(url2, false, true).pathname;
5147
+ pathname = (0, import_node_url2.parse)(url2, false, true).pathname;
5364
5148
  } catch (err) {
5365
- import_shared50.logger.error(
5366
- new Error(`Invalid URL: ${import_shared50.color.yellow(url2)}`, { cause: err })
5149
+ import_shared48.logger.error(
5150
+ new Error(`Invalid URL: ${import_shared48.color.yellow(url2)}`, { cause: err })
5367
5151
  );
5368
5152
  return next();
5369
5153
  }
@@ -5375,10 +5159,10 @@ var init_middlewares = __esm({
5375
5159
  });
5376
5160
  };
5377
5161
  const rewrite = (newUrl, isFallback = false) => {
5378
- if (isFallback && (0, import_shared50.isDebug)()) {
5379
- (0, import_shared50.debug)(
5380
- `${req.method} ${import_shared50.color.gray(
5381
- `${req.url} ${import_shared50.color.yellow("fallback")} to ${newUrl}`
5162
+ if (isFallback && (0, import_shared48.isDebug)()) {
5163
+ (0, import_shared48.debug)(
5164
+ `${req.method} ${import_shared48.color.gray(
5165
+ `${req.url} ${import_shared48.color.yellow("fallback")} to ${newUrl}`
5382
5166
  )}`
5383
5167
  );
5384
5168
  }
@@ -5392,7 +5176,7 @@ var init_middlewares = __esm({
5392
5176
  };
5393
5177
  if (pathname.endsWith("/")) {
5394
5178
  const newUrl = `${pathname}index.html`;
5395
- const filePath = import_node_path27.default.join(distPath, pathname, "index.html");
5179
+ const filePath = import_node_path25.default.join(distPath, pathname, "index.html");
5396
5180
  if (await isFileExists2(filePath)) {
5397
5181
  return rewrite(newUrl);
5398
5182
  }
@@ -5401,13 +5185,13 @@ var init_middlewares = __esm({
5401
5185
  !pathname.endsWith(".html")
5402
5186
  ) {
5403
5187
  const newUrl = `${pathname}.html`;
5404
- const filePath = import_node_path27.default.join(distPath, `${pathname}.html`);
5188
+ const filePath = import_node_path25.default.join(distPath, `${pathname}.html`);
5405
5189
  if (await isFileExists2(filePath)) {
5406
5190
  return rewrite(newUrl);
5407
5191
  }
5408
5192
  }
5409
5193
  if (htmlFallback === "index") {
5410
- if (await isFileExists2(import_node_path27.default.join(distPath, "index.html"))) {
5194
+ if (await isFileExists2(import_node_path25.default.join(distPath, "index.html"))) {
5411
5195
  return rewrite("/index.html", true);
5412
5196
  }
5413
5197
  }
@@ -5444,17 +5228,17 @@ function formatProxyOptions(proxyOptions) {
5444
5228
  ret.push(opts);
5445
5229
  }
5446
5230
  }
5447
- const handleError = (err) => import_shared51.logger.error(err);
5231
+ const handleError = (err) => import_shared49.logger.error(err);
5448
5232
  for (const opts of ret) {
5449
5233
  opts.onError ?? (opts.onError = handleError);
5450
5234
  }
5451
5235
  return ret;
5452
5236
  }
5453
- var import_shared51, import_http_proxy_middleware, createProxyMiddleware;
5237
+ var import_shared49, import_http_proxy_middleware, createProxyMiddleware;
5454
5238
  var init_proxy = __esm({
5455
5239
  "src/server/proxy.ts"() {
5456
5240
  "use strict";
5457
- import_shared51 = require("@rsbuild/shared");
5241
+ import_shared49 = require("@rsbuild/shared");
5458
5242
  import_http_proxy_middleware = require("@rsbuild/shared/http-proxy-middleware");
5459
5243
  createProxyMiddleware = (proxyOptions) => {
5460
5244
  const formattedOptionsList = formatProxyOptions(proxyOptions);
@@ -5495,13 +5279,13 @@ var init_proxy = __esm({
5495
5279
  });
5496
5280
 
5497
5281
  // src/server/getDevMiddlewares.ts
5498
- var import_node_path28, import_node_url4, import_shared52, applySetupMiddlewares, applyDefaultMiddlewares, getMiddlewares;
5282
+ var import_node_path26, import_node_url3, import_shared50, applySetupMiddlewares, applyDefaultMiddlewares, getMiddlewares;
5499
5283
  var init_getDevMiddlewares = __esm({
5500
5284
  "src/server/getDevMiddlewares.ts"() {
5501
5285
  "use strict";
5502
- import_node_path28 = require("path");
5503
- import_node_url4 = __toESM(require("url"));
5504
- import_shared52 = require("@rsbuild/shared");
5286
+ import_node_path26 = require("path");
5287
+ import_node_url3 = __toESM(require("url"));
5288
+ import_shared50 = require("@rsbuild/shared");
5505
5289
  init_middlewares();
5506
5290
  applySetupMiddlewares = (dev, compileMiddlewareAPI) => {
5507
5291
  const setupMiddlewares = dev.setupMiddlewares || [];
@@ -5541,8 +5325,8 @@ var init_getDevMiddlewares = __esm({
5541
5325
  }
5542
5326
  middlewares.push((req, res, next) => {
5543
5327
  res.setHeader("Access-Control-Allow-Origin", "*");
5544
- const path15 = req.url ? import_node_url4.default.parse(req.url).pathname : "";
5545
- if (path15?.includes("hot-update")) {
5328
+ const path13 = req.url ? import_node_url3.default.parse(req.url).pathname : "";
5329
+ if (path13?.includes("hot-update")) {
5546
5330
  res.setHeader("Access-Control-Allow-Credentials", "false");
5547
5331
  }
5548
5332
  const confHeaders = server.headers;
@@ -5582,7 +5366,7 @@ var init_getDevMiddlewares = __esm({
5582
5366
  if (server.publicDir !== false && server.publicDir?.name) {
5583
5367
  const { default: sirv2 } = await import("../compiled/sirv/index.js");
5584
5368
  const { name } = server.publicDir;
5585
- const publicDir = (0, import_node_path28.isAbsolute)(name) ? name : (0, import_node_path28.join)(pwd, name);
5369
+ const publicDir = (0, import_node_path26.isAbsolute)(name) ? name : (0, import_node_path26.join)(pwd, name);
5586
5370
  const assetMiddleware = sirv2(publicDir, {
5587
5371
  etag: true,
5588
5372
  dev: true
@@ -5592,7 +5376,7 @@ var init_getDevMiddlewares = __esm({
5592
5376
  const { distPath } = output;
5593
5377
  compileMiddlewareAPI && middlewares.push(
5594
5378
  getHtmlFallbackMiddleware({
5595
- distPath: (0, import_node_path28.isAbsolute)(distPath) ? distPath : (0, import_node_path28.join)(pwd, distPath),
5379
+ distPath: (0, import_node_path26.isAbsolute)(distPath) ? distPath : (0, import_node_path26.join)(pwd, distPath),
5596
5380
  callback: compileMiddlewareAPI.middleware,
5597
5381
  htmlFallback: server.htmlFallback,
5598
5382
  outputFileSystem
@@ -5618,7 +5402,7 @@ var init_getDevMiddlewares = __esm({
5618
5402
  getMiddlewares = async (options) => {
5619
5403
  const middlewares = [];
5620
5404
  const { compileMiddlewareAPI } = options;
5621
- if ((0, import_shared52.isDebug)()) {
5405
+ if ((0, import_shared50.isDebug)()) {
5622
5406
  middlewares.push(await getRequestLoggerMiddleware());
5623
5407
  }
5624
5408
  const { before, after } = applySetupMiddlewares(
@@ -5646,8 +5430,8 @@ var init_getDevMiddlewares = __esm({
5646
5430
  function getURLMessages(urls, routes) {
5647
5431
  if (routes.length === 1) {
5648
5432
  return urls.map(
5649
- ({ label, url: url2 }) => ` ${`> ${label.padEnd(10)}`}${import_shared53.color.cyan(
5650
- (0, import_shared53.normalizeUrl)(`${url2}${routes[0].pathname}`)
5433
+ ({ label, url: url2 }) => ` ${`> ${label.padEnd(10)}`}${import_shared51.color.cyan(
5434
+ (0, import_shared51.normalizeUrl)(`${url2}${routes[0].pathname}`)
5651
5435
  )}
5652
5436
  `
5653
5437
  ).join("");
@@ -5661,9 +5445,9 @@ function getURLMessages(urls, routes) {
5661
5445
  message += ` ${`> ${label}`}
5662
5446
  `;
5663
5447
  for (const r of routes) {
5664
- message += ` ${import_shared53.color.dim("-")} ${import_shared53.color.dim(
5448
+ message += ` ${import_shared51.color.dim("-")} ${import_shared51.color.dim(
5665
5449
  r.entryName.padEnd(maxNameLength + 4)
5666
- )}${import_shared53.color.cyan((0, import_shared53.normalizeUrl)(`${url2}${r.pathname}`))}
5450
+ )}${import_shared51.color.cyan((0, import_shared51.normalizeUrl)(`${url2}${r.pathname}`))}
5667
5451
  `;
5668
5452
  }
5669
5453
  });
@@ -5680,7 +5464,7 @@ function printServerURLs({
5680
5464
  return;
5681
5465
  }
5682
5466
  let urls = originalUrls;
5683
- if ((0, import_shared53.isFunction)(printUrls)) {
5467
+ if ((0, import_shared51.isFunction)(printUrls)) {
5684
5468
  const newUrls = printUrls({
5685
5469
  urls: urls.map((item) => item.url),
5686
5470
  port,
@@ -5704,17 +5488,17 @@ function printServerURLs({
5704
5488
  return;
5705
5489
  }
5706
5490
  const message = getURLMessages(urls, routes);
5707
- import_shared53.logger.log(message);
5491
+ import_shared51.logger.log(message);
5708
5492
  return message;
5709
5493
  }
5710
- var import_node_net, import_node_net2, import_node_os, import_shared53, formatPrefix, formatRoutes, HMR_SOCK_PATH, mergeDevOptions, getPort, getServerOptions, getDevOptions, getIpv4Interfaces, isLoopbackHost, getHostInUrl, concatUrl, LOCAL_LABEL, NETWORK_LABEL, getUrlLabel, getAddressUrls;
5494
+ var import_node_net, import_node_net2, import_node_os, import_shared51, formatPrefix, formatRoutes, HMR_SOCK_PATH, getPort, getServerConfig, getDevConfig, getIpv4Interfaces, isLoopbackHost, getHostInUrl, concatUrl, LOCAL_LABEL, NETWORK_LABEL, getUrlLabel, getAddressUrls;
5711
5495
  var init_helper = __esm({
5712
5496
  "src/server/helper.ts"() {
5713
5497
  "use strict";
5714
5498
  import_node_net = __toESM(require("net"));
5715
5499
  import_node_net2 = require("net");
5716
5500
  import_node_os = __toESM(require("os"));
5717
- import_shared53 = require("@rsbuild/shared");
5501
+ import_shared51 = require("@rsbuild/shared");
5718
5502
  formatPrefix = (prefix) => {
5719
5503
  if (!prefix) {
5720
5504
  return "/";
@@ -5735,25 +5519,6 @@ var init_helper = __esm({
5735
5519
  }).sort((a) => a.entryName === "index" ? -1 : 1);
5736
5520
  };
5737
5521
  HMR_SOCK_PATH = "/rsbuild-hmr";
5738
- mergeDevOptions = ({
5739
- rsbuildConfig,
5740
- port
5741
- }) => {
5742
- const defaultDevConfig = {
5743
- client: {
5744
- path: HMR_SOCK_PATH,
5745
- port: port.toString(),
5746
- // By default it is set to "location.hostname"
5747
- host: "",
5748
- // By default it is set to "location.protocol === 'https:' ? 'wss' : 'ws'""
5749
- protocol: void 0
5750
- },
5751
- writeToDisk: false,
5752
- liveReload: true
5753
- };
5754
- const devConfig = rsbuildConfig.dev ? (0, import_shared53.deepmerge)(defaultDevConfig, rsbuildConfig.dev) : defaultDevConfig;
5755
- return devConfig;
5756
- };
5757
5522
  getPort = async ({
5758
5523
  host,
5759
5524
  port,
@@ -5796,46 +5561,46 @@ var init_helper = __esm({
5796
5561
  );
5797
5562
  }
5798
5563
  if (!silent) {
5799
- import_shared53.logger.info(
5800
- `Port ${original} is in use, ${import_shared53.color.yellow(`using port ${port}.`)}
5564
+ import_shared51.logger.info(
5565
+ `Port ${original} is in use, ${import_shared51.color.yellow(`using port ${port}.`)}
5801
5566
  `
5802
5567
  );
5803
5568
  }
5804
5569
  }
5805
5570
  return port;
5806
5571
  };
5807
- getServerOptions = async ({
5808
- rsbuildConfig,
5572
+ getServerConfig = async ({
5573
+ config,
5809
5574
  getPortSilently
5810
5575
  }) => {
5811
- const host = rsbuildConfig.server?.host || import_shared53.DEFAULT_DEV_HOST;
5576
+ const host = config.server.host || import_shared51.DEFAULT_DEV_HOST;
5812
5577
  const port = await getPort({
5813
5578
  host,
5814
- port: rsbuildConfig.server?.port || import_shared53.DEFAULT_PORT,
5815
- strictPort: rsbuildConfig.server?.strictPort || false,
5579
+ port: config.server.port || import_shared51.DEFAULT_PORT,
5580
+ strictPort: config.server.strictPort || false,
5816
5581
  silent: getPortSilently
5817
5582
  });
5818
- const https = Boolean(rsbuildConfig.server?.https) || false;
5819
- return { port, host, https, serverConfig: rsbuildConfig.server || {} };
5583
+ const https = Boolean(config.server.https) || false;
5584
+ return { port, host, https };
5820
5585
  };
5821
- getDevOptions = async ({
5822
- rsbuildConfig,
5823
- getPortSilently
5586
+ getDevConfig = ({
5587
+ config,
5588
+ port
5824
5589
  }) => {
5825
- const { port, host, https, serverConfig } = await getServerOptions({
5826
- rsbuildConfig,
5827
- getPortSilently
5828
- });
5829
- const devConfig = mergeDevOptions({ rsbuildConfig, port });
5830
- const liveReload = devConfig.liveReload;
5831
- return {
5832
- devConfig,
5833
- serverConfig,
5834
- port,
5835
- host,
5836
- https,
5837
- liveReload
5590
+ const defaultDevConfig = {
5591
+ client: {
5592
+ path: HMR_SOCK_PATH,
5593
+ port: port.toString(),
5594
+ // By default it is set to "location.hostname"
5595
+ host: "",
5596
+ // By default it is set to "location.protocol === 'https:' ? 'wss' : 'ws'""
5597
+ protocol: void 0
5598
+ },
5599
+ writeToDisk: false,
5600
+ liveReload: true
5838
5601
  };
5602
+ const devConfig = config.dev ? (0, import_shared51.deepmerge)(defaultDevConfig, config.dev) : defaultDevConfig;
5603
+ return devConfig;
5839
5604
  };
5840
5605
  getIpv4Interfaces = () => {
5841
5606
  const interfaces = import_node_os.default.networkInterfaces();
@@ -5885,7 +5650,7 @@ var init_helper = __esm({
5885
5650
  port,
5886
5651
  host
5887
5652
  }) => {
5888
- if (host && host !== import_shared53.DEFAULT_DEV_HOST) {
5653
+ if (host && host !== import_shared51.DEFAULT_DEV_HOST) {
5889
5654
  return [
5890
5655
  {
5891
5656
  label: isLoopbackHost(host) ? LOCAL_LABEL : NETWORK_LABEL,
@@ -5999,11 +5764,11 @@ var init_watchFiles = __esm({
5999
5764
  });
6000
5765
 
6001
5766
  // src/server/socketServer.ts
6002
- var import_shared54, import_ws, SocketServer;
5767
+ var import_shared52, import_ws, SocketServer;
6003
5768
  var init_socketServer = __esm({
6004
5769
  "src/server/socketServer.ts"() {
6005
5770
  "use strict";
6006
- import_shared54 = require("@rsbuild/shared");
5771
+ import_shared52 = require("@rsbuild/shared");
6007
5772
  import_ws = __toESM(require("../compiled/ws/index.js"));
6008
5773
  init_helpers();
6009
5774
  SocketServer = class {
@@ -6030,7 +5795,7 @@ var init_socketServer = __esm({
6030
5795
  path: this.options.client?.path
6031
5796
  });
6032
5797
  this.wsServer.on("error", (err) => {
6033
- import_shared54.logger.error(err);
5798
+ import_shared52.logger.error(err);
6034
5799
  });
6035
5800
  this.timer = setInterval(() => {
6036
5801
  for (const socket of this.wsServer.clients) {
@@ -6246,24 +6011,28 @@ var devServer_exports = {};
6246
6011
  __export(devServer_exports, {
6247
6012
  createDevServer: () => createDevServer
6248
6013
  });
6249
- async function createDevServer(options, createDevMiddleware2, {
6014
+ async function createDevServer(options, createDevMiddleware2, config, {
6250
6015
  compiler: customCompiler,
6251
6016
  getPortSilently,
6252
6017
  runCompile = true
6253
6018
  } = {}) {
6254
- if (!(0, import_shared55.getNodeEnv)()) {
6255
- (0, import_shared55.setNodeEnv)("development");
6019
+ if (!(0, import_shared53.getNodeEnv)()) {
6020
+ (0, import_shared53.setNodeEnv)("development");
6256
6021
  }
6257
- (0, import_shared55.debug)("create dev server");
6258
- const rsbuildConfig = options.context.config;
6259
- const { devConfig, serverConfig, port, host, https } = await getDevOptions({
6260
- rsbuildConfig,
6022
+ (0, import_shared53.debug)("create dev server");
6023
+ const serverConfig = config.server;
6024
+ const { port, host, https } = await getServerConfig({
6025
+ config,
6261
6026
  getPortSilently
6262
6027
  });
6028
+ const devConfig = getDevConfig({
6029
+ config,
6030
+ port
6031
+ });
6263
6032
  const routes = formatRoutes(
6264
6033
  options.context.entry,
6265
- rsbuildConfig.output?.distPath?.html,
6266
- rsbuildConfig.html?.outputStructure
6034
+ config.output.distPath.html,
6035
+ config.html.outputStructure
6267
6036
  );
6268
6037
  options.context.devServer = {
6269
6038
  hostname: host,
@@ -6277,7 +6046,7 @@ async function createDevServer(options, createDevMiddleware2, {
6277
6046
  customCompiler
6278
6047
  );
6279
6048
  const { CompilerDevMiddleware: CompilerDevMiddleware2 } = await Promise.resolve().then(() => (init_compilerDevMiddleware(), compilerDevMiddleware_exports));
6280
- const publicPaths = (0, import_shared55.isMultiCompiler)(compiler) ? compiler.compilers.map(import_shared55.getPublicPathFromCompiler) : [(0, import_shared55.getPublicPathFromCompiler)(compiler)];
6049
+ const publicPaths = (0, import_shared53.isMultiCompiler)(compiler) ? compiler.compilers.map(import_shared53.getPublicPathFromCompiler) : [(0, import_shared53.getPublicPathFromCompiler)(compiler)];
6281
6050
  const compilerDevMiddleware = new CompilerDevMiddleware2({
6282
6051
  dev: devConfig,
6283
6052
  server: serverConfig,
@@ -6285,7 +6054,7 @@ async function createDevServer(options, createDevMiddleware2, {
6285
6054
  devMiddleware
6286
6055
  });
6287
6056
  compilerDevMiddleware.init();
6288
- outputFileSystem = ((0, import_shared55.isMultiCompiler)(compiler) ? compiler.compilers[0].outputFileSystem : compiler.outputFileSystem) || import_node_fs4.default;
6057
+ outputFileSystem = ((0, import_shared53.isMultiCompiler)(compiler) ? compiler.compilers[0].outputFileSystem : compiler.outputFileSystem) || import_node_fs4.default;
6289
6058
  return {
6290
6059
  middleware: compilerDevMiddleware.middleware,
6291
6060
  sockWrite: (...args) => compilerDevMiddleware.sockWrite(...args),
@@ -6327,7 +6096,7 @@ async function createDevServer(options, createDevMiddleware2, {
6327
6096
  dev: devConfig,
6328
6097
  server: serverConfig,
6329
6098
  output: {
6330
- distPath: rsbuildConfig.output?.distPath?.root || import_shared55.ROOT_DIST_DIR
6099
+ distPath: config.output.distPath.root || import_shared53.ROOT_DIST_DIR
6331
6100
  },
6332
6101
  outputFileSystem
6333
6102
  });
@@ -6348,7 +6117,7 @@ async function createDevServer(options, createDevMiddleware2, {
6348
6117
  https: serverConfig.https,
6349
6118
  middlewares
6350
6119
  });
6351
- (0, import_shared55.debug)("listen dev server");
6120
+ (0, import_shared53.debug)("listen dev server");
6352
6121
  return new Promise((resolve) => {
6353
6122
  httpServer.listen(
6354
6123
  {
@@ -6361,7 +6130,7 @@ async function createDevServer(options, createDevMiddleware2, {
6361
6130
  }
6362
6131
  middlewares.use(notFoundMiddleware);
6363
6132
  httpServer.on("upgrade", devMiddlewares.onUpgrade);
6364
- (0, import_shared55.debug)("listen dev server done");
6133
+ (0, import_shared53.debug)("listen dev server done");
6365
6134
  await server.afterListen();
6366
6135
  const closeServer = async () => {
6367
6136
  await server.close();
@@ -6392,15 +6161,15 @@ async function createDevServer(options, createDevMiddleware2, {
6392
6161
  await fileWatcher?.close();
6393
6162
  }
6394
6163
  };
6395
- (0, import_shared55.debug)("create dev server done");
6164
+ (0, import_shared53.debug)("create dev server done");
6396
6165
  return server;
6397
6166
  }
6398
- var import_node_fs4, import_shared55, import_connect;
6167
+ var import_node_fs4, import_shared53, import_connect;
6399
6168
  var init_devServer = __esm({
6400
6169
  "src/server/devServer.ts"() {
6401
6170
  "use strict";
6402
6171
  import_node_fs4 = __toESM(require("fs"));
6403
- import_shared55 = require("@rsbuild/shared");
6172
+ import_shared53 = require("@rsbuild/shared");
6404
6173
  import_connect = __toESM(require("@rsbuild/shared/connect"));
6405
6174
  init_getDevMiddlewares();
6406
6175
  init_helper();
@@ -6417,19 +6186,20 @@ __export(prodServer_exports, {
6417
6186
  RsbuildProdServer: () => RsbuildProdServer,
6418
6187
  startProdServer: () => startProdServer
6419
6188
  });
6420
- async function startProdServer(context, rsbuildConfig, { getPortSilently } = {}) {
6421
- if (!(0, import_shared56.getNodeEnv)()) {
6422
- (0, import_shared56.setNodeEnv)("production");
6189
+ async function startProdServer(context, config, { getPortSilently } = {}) {
6190
+ if (!(0, import_shared54.getNodeEnv)()) {
6191
+ (0, import_shared54.setNodeEnv)("production");
6423
6192
  }
6424
- const { serverConfig, port, host, https } = await getServerOptions({
6425
- rsbuildConfig,
6193
+ const { port, host, https } = await getServerConfig({
6194
+ config,
6426
6195
  getPortSilently
6427
6196
  });
6197
+ const serverConfig = config.server;
6428
6198
  const server = new RsbuildProdServer({
6429
6199
  pwd: context.rootPath,
6430
6200
  output: {
6431
- path: rsbuildConfig.output?.distPath?.root || import_shared56.ROOT_DIST_DIR,
6432
- assetPrefix: rsbuildConfig.output?.assetPrefix
6201
+ path: config.output.distPath.root || import_shared54.ROOT_DIST_DIR,
6202
+ assetPrefix: config.output.assetPrefix
6433
6203
  },
6434
6204
  serverConfig
6435
6205
  });
@@ -6448,8 +6218,8 @@ async function startProdServer(context, rsbuildConfig, { getPortSilently } = {})
6448
6218
  async () => {
6449
6219
  const routes = formatRoutes(
6450
6220
  context.entry,
6451
- rsbuildConfig.output?.distPath?.html,
6452
- rsbuildConfig.html?.outputStructure
6221
+ config.output.distPath.html,
6222
+ config.html.outputStructure
6453
6223
  );
6454
6224
  await context.hooks.onAfterStartProdServer.call({
6455
6225
  port,
@@ -6481,12 +6251,12 @@ async function startProdServer(context, rsbuildConfig, { getPortSilently } = {})
6481
6251
  );
6482
6252
  });
6483
6253
  }
6484
- var import_node_path29, import_shared56, import_connect2, import_sirv, RsbuildProdServer;
6254
+ var import_node_path27, import_shared54, import_connect2, import_sirv, RsbuildProdServer;
6485
6255
  var init_prodServer = __esm({
6486
6256
  "src/server/prodServer.ts"() {
6487
6257
  "use strict";
6488
- import_node_path29 = require("path");
6489
- import_shared56 = require("@rsbuild/shared");
6258
+ import_node_path27 = require("path");
6259
+ import_shared54 = require("@rsbuild/shared");
6490
6260
  import_connect2 = __toESM(require("@rsbuild/shared/connect"));
6491
6261
  import_sirv = __toESM(require("../compiled/sirv/index.js"));
6492
6262
  init_helper();
@@ -6506,7 +6276,7 @@ var init_prodServer = __esm({
6506
6276
  }
6507
6277
  async applyDefaultMiddlewares() {
6508
6278
  const { headers, proxy, historyApiFallback, compress } = this.options.serverConfig;
6509
- if ((0, import_shared56.isDebug)()) {
6279
+ if ((0, import_shared54.isDebug)()) {
6510
6280
  this.middlewares.use(await getRequestLoggerMiddleware());
6511
6281
  }
6512
6282
  if (compress) {
@@ -6547,11 +6317,11 @@ var init_prodServer = __esm({
6547
6317
  }
6548
6318
  applyStaticAssetMiddleware() {
6549
6319
  const {
6550
- output: { path: path15, assetPrefix },
6320
+ output: { path: path13, assetPrefix },
6551
6321
  serverConfig: { htmlFallback },
6552
6322
  pwd
6553
6323
  } = this.options;
6554
- const assetMiddleware = (0, import_sirv.default)((0, import_node_path29.join)(pwd, path15), {
6324
+ const assetMiddleware = (0, import_sirv.default)((0, import_node_path27.join)(pwd, path13), {
6555
6325
  etag: true,
6556
6326
  dev: true,
6557
6327
  ignores: ["favicon.ico"],
@@ -6581,17 +6351,17 @@ var build_exports = {};
6581
6351
  __export(build_exports, {
6582
6352
  build: () => build
6583
6353
  });
6584
- var import_shared57, import_core9, build;
6354
+ var import_shared55, import_core9, build;
6585
6355
  var init_build = __esm({
6586
6356
  "src/provider/build.ts"() {
6587
6357
  "use strict";
6588
- import_shared57 = require("@rsbuild/shared");
6358
+ import_shared55 = require("@rsbuild/shared");
6589
6359
  import_core9 = require("@rspack/core");
6590
6360
  init_createCompiler();
6591
6361
  init_initConfigs();
6592
6362
  build = async (initOptions, { mode = "production", watch, compiler: customCompiler } = {}) => {
6593
- if (!(0, import_shared57.getNodeEnv)()) {
6594
- (0, import_shared57.setNodeEnv)(mode);
6363
+ if (!(0, import_shared55.getNodeEnv)()) {
6364
+ (0, import_shared55.setNodeEnv)(mode);
6595
6365
  }
6596
6366
  const { context } = initOptions;
6597
6367
  let compiler;
@@ -6615,7 +6385,7 @@ var init_build = __esm({
6615
6385
  isFirstCompile = false;
6616
6386
  await p;
6617
6387
  };
6618
- (0, import_shared57.onCompileDone)(
6388
+ (0, import_shared55.onCompileDone)(
6619
6389
  compiler,
6620
6390
  onDone,
6621
6391
  // @ts-expect-error type mismatch
@@ -6624,7 +6394,7 @@ var init_build = __esm({
6624
6394
  if (watch) {
6625
6395
  compiler.watch({}, (err) => {
6626
6396
  if (err) {
6627
- import_shared57.logger.error(err);
6397
+ import_shared55.logger.error(err);
6628
6398
  }
6629
6399
  });
6630
6400
  return;
@@ -6650,11 +6420,11 @@ var provider_exports = {};
6650
6420
  __export(provider_exports, {
6651
6421
  rspackProvider: () => rspackProvider
6652
6422
  });
6653
- var import_shared58, rspackProvider;
6423
+ var import_shared56, rspackProvider;
6654
6424
  var init_provider = __esm({
6655
6425
  "src/provider/provider.ts"() {
6656
6426
  "use strict";
6657
- import_shared58 = require("@rsbuild/shared");
6427
+ import_shared56 = require("@rsbuild/shared");
6658
6428
  init_createContext();
6659
6429
  init_initPlugins();
6660
6430
  init_plugins();
@@ -6663,7 +6433,7 @@ var init_provider = __esm({
6663
6433
  pluginManager,
6664
6434
  rsbuildOptions
6665
6435
  }) => {
6666
- const rsbuildConfig = (0, import_shared58.pickRsbuildConfig)(rsbuildOptions.rsbuildConfig);
6436
+ const rsbuildConfig = (0, import_shared56.pickRsbuildConfig)(rsbuildOptions.rsbuildConfig);
6667
6437
  const context = await createContext(rsbuildOptions, rsbuildConfig, "rspack");
6668
6438
  const pluginAPI = getPluginAPI({ context, pluginManager });
6669
6439
  context.pluginAPI = pluginAPI;
@@ -6705,8 +6475,6 @@ var init_provider = __esm({
6705
6475
  plugins.nodeAddons(),
6706
6476
  plugins.define(),
6707
6477
  plugins.css(),
6708
- plugins.less(),
6709
- plugins.sass(),
6710
6478
  Promise.resolve().then(() => (init_minimize(), minimize_exports)).then((m) => m.pluginMinimize()),
6711
6479
  Promise.resolve().then(() => (init_progress(), progress_exports)).then((m) => m.pluginProgress()),
6712
6480
  Promise.resolve().then(() => (init_swc(), swc_exports)).then((m) => m.pluginSwc()),
@@ -6728,28 +6496,30 @@ var init_provider = __esm({
6728
6496
  async createDevServer(options) {
6729
6497
  const { createDevServer: createDevServer2 } = await Promise.resolve().then(() => (init_devServer(), devServer_exports));
6730
6498
  const { createDevMiddleware: createDevMiddleware2 } = await Promise.resolve().then(() => (init_createCompiler(), createCompiler_exports));
6731
- await initRsbuildConfig({ context, pluginManager });
6499
+ const config = await initRsbuildConfig({ context, pluginManager });
6732
6500
  return createDevServer2(
6733
6501
  { context, pluginManager, rsbuildOptions },
6734
6502
  createDevMiddleware2,
6503
+ config,
6735
6504
  options
6736
6505
  );
6737
6506
  },
6738
6507
  async startDevServer(options) {
6739
6508
  const { createDevServer: createDevServer2 } = await Promise.resolve().then(() => (init_devServer(), devServer_exports));
6740
6509
  const { createDevMiddleware: createDevMiddleware2 } = await Promise.resolve().then(() => (init_createCompiler(), createCompiler_exports));
6741
- await initRsbuildConfig({ context, pluginManager });
6510
+ const config = await initRsbuildConfig({ context, pluginManager });
6742
6511
  const server = await createDevServer2(
6743
6512
  { context, pluginManager, rsbuildOptions },
6744
6513
  createDevMiddleware2,
6514
+ config,
6745
6515
  options
6746
6516
  );
6747
6517
  return server.listen();
6748
6518
  },
6749
6519
  async preview(options) {
6750
6520
  const { startProdServer: startProdServer2 } = await Promise.resolve().then(() => (init_prodServer(), prodServer_exports));
6751
- await initRsbuildConfig({ context, pluginManager });
6752
- return startProdServer2(context, context.config, options);
6521
+ const config = await initRsbuildConfig({ context, pluginManager });
6522
+ return startProdServer2(context, config, options);
6753
6523
  },
6754
6524
  async build(options) {
6755
6525
  const { build: build2 } = await Promise.resolve().then(() => (init_build(), build_exports));
@@ -6806,17 +6576,17 @@ async function createRsbuild(options = {}) {
6806
6576
  pluginManager,
6807
6577
  rsbuildOptions
6808
6578
  });
6809
- (0, import_shared59.debug)("add default plugins");
6579
+ (0, import_shared57.debug)("add default plugins");
6810
6580
  await applyDefaultPlugins(pluginManager);
6811
- (0, import_shared59.debug)("add default plugins done");
6581
+ (0, import_shared57.debug)("add default plugins done");
6812
6582
  const rsbuild = {
6813
- ...(0, import_shared59.pick)(pluginManager, [
6583
+ ...(0, import_shared57.pick)(pluginManager, [
6814
6584
  "addPlugins",
6815
6585
  "getPlugins",
6816
6586
  "removePlugins",
6817
6587
  "isPluginExists"
6818
6588
  ]),
6819
- ...(0, import_shared59.pick)(pluginAPI, [
6589
+ ...(0, import_shared57.pick)(pluginAPI, [
6820
6590
  "onBeforeBuild",
6821
6591
  "onBeforeCreateCompiler",
6822
6592
  "onBeforeStartDevServer",
@@ -6847,11 +6617,11 @@ async function createRsbuild(options = {}) {
6847
6617
  }
6848
6618
  return rsbuild;
6849
6619
  }
6850
- var import_shared59, getRspackProvider;
6620
+ var import_shared57, getRspackProvider;
6851
6621
  var init_createRsbuild = __esm({
6852
6622
  "src/createRsbuild.ts"() {
6853
6623
  "use strict";
6854
- import_shared59 = require("@rsbuild/shared");
6624
+ import_shared57 = require("@rsbuild/shared");
6855
6625
  init_pluginManager();
6856
6626
  getRspackProvider = async () => {
6857
6627
  const { rspackProvider: rspackProvider2 } = await Promise.resolve().then(() => (init_provider(), provider_exports));
@@ -6874,7 +6644,7 @@ async function init({
6874
6644
  cwd: root,
6875
6645
  mode: cliOptions?.envMode
6876
6646
  });
6877
- if ((0, import_shared60.isDev)()) {
6647
+ if ((0, import_shared58.isDev)()) {
6878
6648
  onBeforeRestartServer(envs.cleanup);
6879
6649
  }
6880
6650
  const { content: config, filePath: configFilePath } = await loadConfig({
@@ -6914,17 +6684,17 @@ async function init({
6914
6684
  });
6915
6685
  } catch (err) {
6916
6686
  if (isRestart) {
6917
- import_shared60.logger.error(err);
6687
+ import_shared58.logger.error(err);
6918
6688
  } else {
6919
6689
  throw err;
6920
6690
  }
6921
6691
  }
6922
6692
  }
6923
- var import_shared60, commonOpts;
6693
+ var import_shared58, commonOpts;
6924
6694
  var init_init = __esm({
6925
6695
  "src/cli/init.ts"() {
6926
6696
  "use strict";
6927
- import_shared60 = require("@rsbuild/shared");
6697
+ import_shared58 = require("@rsbuild/shared");
6928
6698
  init_config();
6929
6699
  init_loadEnv();
6930
6700
  init_restart();
@@ -6936,16 +6706,13 @@ var init_init = __esm({
6936
6706
  var src_exports = {};
6937
6707
  __export(src_exports, {
6938
6708
  PLUGIN_CSS_NAME: () => PLUGIN_CSS_NAME,
6939
- PLUGIN_LESS_NAME: () => PLUGIN_LESS_NAME,
6940
- PLUGIN_SASS_NAME: () => PLUGIN_SASS_NAME,
6941
- PLUGIN_STYLUS_NAME: () => PLUGIN_STYLUS_NAME,
6942
6709
  PLUGIN_SWC_NAME: () => PLUGIN_SWC_NAME,
6943
6710
  __internalHelper: () => internal_exports,
6944
6711
  createRsbuild: () => createRsbuild,
6945
6712
  defineConfig: () => defineConfig,
6946
6713
  loadConfig: () => loadConfig,
6947
6714
  loadEnv: () => loadEnv,
6948
- logger: () => import_shared63.logger,
6715
+ logger: () => import_shared61.logger,
6949
6716
  mergeRsbuildConfig: () => mergeRsbuildConfig,
6950
6717
  rspack: () => import_core10.rspack,
6951
6718
  version: () => version
@@ -6956,7 +6723,6 @@ var import_core10 = require("@rspack/core");
6956
6723
  // src/internal.ts
6957
6724
  var internal_exports = {};
6958
6725
  __export(internal_exports, {
6959
- applyCSSRule: () => applyCSSRule,
6960
6726
  applySwcDecoratorConfig: () => applySwcDecoratorConfig,
6961
6727
  createContext: () => createContext,
6962
6728
  createDevServer: () => createDevServer,
@@ -6982,8 +6748,8 @@ __export(internal_exports, {
6982
6748
 
6983
6749
  // src/cli/commands.ts
6984
6750
  var import_node_fs5 = require("fs");
6985
- var import_node_path30 = require("path");
6986
- var import_shared61 = require("@rsbuild/shared");
6751
+ var import_node_path28 = require("path");
6752
+ var import_shared59 = require("@rsbuild/shared");
6987
6753
  var import_commander = require("../compiled/commander/index.js");
6988
6754
  init_init();
6989
6755
  var applyCommonOptions = (command) => {
@@ -6999,7 +6765,7 @@ var applyServerOptions = (command) => {
6999
6765
  command.option("-o --open [url]", "open the page in browser on startup").option("--port <port>", "specify a port number for server to listen").option("--host <host>", "specify the host that the server listens to");
7000
6766
  };
7001
6767
  function runCli() {
7002
- import_commander.program.name("rsbuild").usage("<command> [options]").version("0.7.0-beta.6");
6768
+ import_commander.program.name("rsbuild").usage("<command> [options]").version("0.7.0-beta.8");
7003
6769
  const devCommand = import_commander.program.command("dev");
7004
6770
  const buildCommand = import_commander.program.command("build");
7005
6771
  const previewCommand = import_commander.program.command("preview");
@@ -7013,8 +6779,8 @@ function runCli() {
7013
6779
  const rsbuild = await init({ cliOptions: options });
7014
6780
  await rsbuild?.startDevServer();
7015
6781
  } catch (err) {
7016
- import_shared61.logger.error("Failed to start dev server.");
7017
- import_shared61.logger.error(err);
6782
+ import_shared59.logger.error("Failed to start dev server.");
6783
+ import_shared59.logger.error(err);
7018
6784
  process.exit(1);
7019
6785
  }
7020
6786
  });
@@ -7025,8 +6791,8 @@ function runCli() {
7025
6791
  watch: options.watch
7026
6792
  });
7027
6793
  } catch (err) {
7028
- import_shared61.logger.error("Failed to build.");
7029
- import_shared61.logger.error(err);
6794
+ import_shared59.logger.error("Failed to build.");
6795
+ import_shared59.logger.error(err);
7030
6796
  process.exit(1);
7031
6797
  }
7032
6798
  });
@@ -7035,15 +6801,15 @@ function runCli() {
7035
6801
  const rsbuild = await init({ cliOptions: options });
7036
6802
  if (rsbuild && !(0, import_node_fs5.existsSync)(rsbuild.context.distPath)) {
7037
6803
  throw new Error(
7038
- `The output directory ${import_shared61.color.yellow(
6804
+ `The output directory ${import_shared59.color.yellow(
7039
6805
  rsbuild.context.distPath
7040
6806
  )} does not exist, please build the project before previewing.`
7041
6807
  );
7042
6808
  }
7043
6809
  await rsbuild?.preview();
7044
6810
  } catch (err) {
7045
- import_shared61.logger.error("Failed to start preview server.");
7046
- import_shared61.logger.error(err);
6811
+ import_shared59.logger.error("Failed to start preview server.");
6812
+ import_shared59.logger.error(err);
7047
6813
  process.exit(1);
7048
6814
  }
7049
6815
  });
@@ -7053,12 +6819,12 @@ function runCli() {
7053
6819
  await rsbuild?.inspectConfig({
7054
6820
  env: options.env,
7055
6821
  verbose: options.verbose,
7056
- outputPath: (0, import_node_path30.join)(rsbuild.context.distPath, options.output),
6822
+ outputPath: (0, import_node_path28.join)(rsbuild.context.distPath, options.output),
7057
6823
  writeToDisk: true
7058
6824
  });
7059
6825
  } catch (err) {
7060
- import_shared61.logger.error("Failed to inspect config.");
7061
- import_shared61.logger.error(err);
6826
+ import_shared59.logger.error("Failed to inspect config.");
6827
+ import_shared59.logger.error(err);
7062
6828
  process.exit(1);
7063
6829
  }
7064
6830
  });
@@ -7066,7 +6832,7 @@ function runCli() {
7066
6832
  }
7067
6833
 
7068
6834
  // src/cli/prepare.ts
7069
- var import_shared62 = require("@rsbuild/shared");
6835
+ var import_shared60 = require("@rsbuild/shared");
7070
6836
  function initNodeEnv() {
7071
6837
  if (!process.env.NODE_ENV) {
7072
6838
  const command = process.argv[2];
@@ -7079,7 +6845,7 @@ function prepareCli() {
7079
6845
  if (!npm_execpath || npm_execpath.includes("npx-cli.js") || npm_execpath.includes(".bun")) {
7080
6846
  console.log();
7081
6847
  }
7082
- import_shared62.logger.greet(` ${`Rsbuild v${"0.7.0-beta.6"}`}
6848
+ import_shared60.logger.greet(` ${`Rsbuild v${"0.7.0-beta.8"}`}
7083
6849
  `);
7084
6850
  }
7085
6851
 
@@ -7088,7 +6854,6 @@ init_createContext();
7088
6854
  init_pluginManager();
7089
6855
  init_initHooks();
7090
6856
  init_initConfigs();
7091
- init_css();
7092
6857
  init_initPlugins();
7093
6858
  init_pluginHelper();
7094
6859
  init_helpers();
@@ -7108,16 +6873,13 @@ init_plugins();
7108
6873
  init_loadEnv();
7109
6874
  init_createRsbuild();
7110
6875
  init_config();
7111
- var import_shared63 = require("@rsbuild/shared");
6876
+ var import_shared61 = require("@rsbuild/shared");
7112
6877
  init_mergeConfig();
7113
6878
  init_constants();
7114
- var version = "0.7.0-beta.6";
6879
+ var version = "0.7.0-beta.8";
7115
6880
  // Annotate the CommonJS export names for ESM import in node:
7116
6881
  0 && (module.exports = {
7117
6882
  PLUGIN_CSS_NAME,
7118
- PLUGIN_LESS_NAME,
7119
- PLUGIN_SASS_NAME,
7120
- PLUGIN_STYLUS_NAME,
7121
6883
  PLUGIN_SWC_NAME,
7122
6884
  __internalHelper,
7123
6885
  createRsbuild,