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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -349,8 +349,8 @@ var init_mergeConfig = __esm({
349
349
  "provider"
350
350
  ];
351
351
  isOverridePath = (key) => OVERRIDE_PATH.includes(key);
352
- merge = (x, y, path16 = "") => {
353
- if (isOverridePath(path16)) {
352
+ merge = (x, y, path14 = "") => {
353
+ if (isOverridePath(path14)) {
354
354
  return y ?? x;
355
355
  }
356
356
  if (x === void 0) {
@@ -372,7 +372,7 @@ var init_mergeConfig = __esm({
372
372
  const merged = {};
373
373
  const keys = /* @__PURE__ */ new Set([...Object.keys(x), ...Object.keys(y)]);
374
374
  for (const key of keys) {
375
- const childPath = path16 ? `${path16}.${key}` : key;
375
+ const childPath = path14 ? `${path14}.${key}` : key;
376
376
  merged[key] = merge(x[key], y[key], childPath);
377
377
  }
378
378
  return merged;
@@ -501,10 +501,10 @@ async function watchFiles(files) {
501
501
  }
502
502
  async function loadConfig({
503
503
  cwd = process.cwd(),
504
- path: path16,
504
+ path: path14,
505
505
  envMode
506
506
  } = {}) {
507
- const configFilePath = resolveConfigPath(cwd, path16);
507
+ const configFilePath = resolveConfigPath(cwd, path14);
508
508
  if (!configFilePath) {
509
509
  return {
510
510
  content: {},
@@ -1095,7 +1095,7 @@ async function createContextByConfig(options, bundlerType, config = {}) {
1095
1095
  const context = {
1096
1096
  entry: getEntryObject(config, "web"),
1097
1097
  targets: config.output?.targets || [],
1098
- version: "0.7.0-beta.6",
1098
+ version: "0.7.0-beta.7",
1099
1099
  rootPath,
1100
1100
  distPath,
1101
1101
  cachePath,
@@ -3556,10 +3556,10 @@ var init_rsdoctor = __esm({
3556
3556
  const packageName = isRspack ? "@rsdoctor/rspack-plugin" : "@rsdoctor/webpack-plugin";
3557
3557
  let module;
3558
3558
  try {
3559
- const path16 = __require.resolve(packageName, {
3559
+ const path14 = __require.resolve(packageName, {
3560
3560
  paths: [api.context.rootPath]
3561
3561
  });
3562
- module = await import(path16);
3562
+ module = await import(path14);
3563
3563
  } catch (err) {
3564
3564
  logger8.warn(
3565
3565
  `\`process.env.RSDOCTOR\` enabled, please install ${color9.bold(color9.yellow(packageName))} package.`
@@ -4253,228 +4253,6 @@ var init_define = __esm({
4253
4253
  }
4254
4254
  });
4255
4255
 
4256
- // src/plugins/less.ts
4257
- var less_exports = {};
4258
- __export(less_exports, {
4259
- pluginLess: () => pluginLess
4260
- });
4261
- import path11 from "path";
4262
- import {
4263
- castArray as castArray6,
4264
- deepmerge as deepmerge4,
4265
- getSharedPkgCompiledPath,
4266
- mergeChainedOptions as mergeChainedOptions5
4267
- } from "@rsbuild/shared";
4268
- function pluginLess() {
4269
- return {
4270
- name: "rsbuild:less",
4271
- setup(api) {
4272
- api.modifyBundlerChain(async (chain, utils) => {
4273
- const config = api.getNormalizedConfig();
4274
- const { applyCSSRule: applyCSSRule2 } = await Promise.resolve().then(() => (init_css(), css_exports));
4275
- const rule = chain.module.rule(utils.CHAIN_ID.RULE.LESS).test(/\.less$/);
4276
- const { excludes, options } = getLessLoaderOptions(
4277
- config.tools.less,
4278
- config.output.sourceMap.css,
4279
- api.context.rootPath
4280
- );
4281
- for (const item of excludes) {
4282
- rule.exclude.add(item);
4283
- }
4284
- await applyCSSRule2({
4285
- rule,
4286
- utils,
4287
- config,
4288
- context: api.context,
4289
- importLoaders: 2
4290
- });
4291
- rule.use(utils.CHAIN_ID.USE.LESS).loader(getCompiledPath("less-loader")).options(options);
4292
- });
4293
- }
4294
- };
4295
- }
4296
- var getLessLoaderOptions;
4297
- var init_less = __esm({
4298
- "src/plugins/less.ts"() {
4299
- "use strict";
4300
- init_esm();
4301
- init_helpers();
4302
- getLessLoaderOptions = (rsbuildLessConfig, isUseCssSourceMap, rootPath) => {
4303
- const excludes = [];
4304
- const addExcludes = (items) => {
4305
- excludes.push(...castArray6(items));
4306
- };
4307
- const defaultLessLoaderOptions = {
4308
- lessOptions: {
4309
- javascriptEnabled: true,
4310
- // let less resolve from node_modules in the current root directory,
4311
- // Avoid resolving from wrong node_modules.
4312
- paths: [path11.join(rootPath, "node_modules")]
4313
- },
4314
- sourceMap: isUseCssSourceMap,
4315
- implementation: getSharedPkgCompiledPath("less")
4316
- };
4317
- const mergeFn = (defaults, userOptions) => {
4318
- const getLessOptions = () => {
4319
- if (defaults.lessOptions && userOptions.lessOptions) {
4320
- return deepmerge4(defaults.lessOptions, userOptions.lessOptions);
4321
- }
4322
- return userOptions.lessOptions || defaults.lessOptions;
4323
- };
4324
- return {
4325
- ...defaults,
4326
- ...userOptions,
4327
- lessOptions: getLessOptions()
4328
- };
4329
- };
4330
- const mergedOptions = mergeChainedOptions5({
4331
- defaults: defaultLessLoaderOptions,
4332
- options: rsbuildLessConfig,
4333
- utils: { addExcludes },
4334
- mergeFn
4335
- });
4336
- return {
4337
- options: mergedOptions,
4338
- excludes
4339
- };
4340
- };
4341
- }
4342
- });
4343
-
4344
- // src/plugins/sass.ts
4345
- var sass_exports = {};
4346
- __export(sass_exports, {
4347
- patchCompilerGlobalLocation: () => patchCompilerGlobalLocation,
4348
- pluginSass: () => pluginSass
4349
- });
4350
- import path12 from "path";
4351
- import { pathToFileURL } from "url";
4352
- import {
4353
- castArray as castArray7,
4354
- deepmerge as deepmerge5,
4355
- getSharedPkgCompiledPath as getSharedPkgCompiledPath2,
4356
- mergeChainedOptions as mergeChainedOptions6
4357
- } from "@rsbuild/shared";
4358
- function patchGlobalLocation() {
4359
- if (!global.location) {
4360
- const href = pathToFileURL(process.cwd()).href + path12.sep;
4361
- const location = Object.freeze({ [GLOBAL_PATCHED_SYMBOL]: true, href });
4362
- global.location = location;
4363
- }
4364
- }
4365
- function unpatchGlobalLocation() {
4366
- if (global.location?.[GLOBAL_PATCHED_SYMBOL]) {
4367
- delete global.location;
4368
- }
4369
- }
4370
- function patchCompilerGlobalLocation(compiler) {
4371
- compiler.hooks.run.tap("PatchGlobalLocation", patchGlobalLocation);
4372
- compiler.hooks.watchRun.tap("PatchGlobalLocation", patchGlobalLocation);
4373
- compiler.hooks.watchClose.tap("PatchGlobalLocation", unpatchGlobalLocation);
4374
- compiler.hooks.done.tap("PatchGlobalLocation", unpatchGlobalLocation);
4375
- }
4376
- function pluginSass() {
4377
- return {
4378
- name: "rsbuild:sass",
4379
- setup(api) {
4380
- api.onAfterCreateCompiler(({ compiler }) => {
4381
- patchCompilerGlobalLocation(compiler);
4382
- });
4383
- api.modifyBundlerChain(async (chain, utils) => {
4384
- const config = api.getNormalizedConfig();
4385
- const { applyCSSRule: applyCSSRule2 } = await Promise.resolve().then(() => (init_css(), css_exports));
4386
- const { excludes, options } = getSassLoaderOptions(
4387
- config.tools.sass,
4388
- // source-maps required for loaders preceding resolve-url-loader
4389
- // otherwise the resolve-url-loader will throw an error
4390
- true
4391
- );
4392
- const rule = chain.module.rule(utils.CHAIN_ID.RULE.SASS).test(/\.s(?:a|c)ss$/);
4393
- for (const item of excludes) {
4394
- rule.exclude.add(item);
4395
- }
4396
- await applyCSSRule2({
4397
- rule,
4398
- utils,
4399
- config,
4400
- context: api.context,
4401
- // postcss-loader, resolve-url-loader, sass-loader
4402
- importLoaders: 3
4403
- });
4404
- rule.use(utils.CHAIN_ID.USE.RESOLVE_URL).loader(getCompiledPath("resolve-url-loader")).options({
4405
- join: await getResolveUrlJoinFn(),
4406
- // 'resolve-url-loader' relies on 'adjust-sourcemap-loader',
4407
- // it has performance regression issues in some scenarios,
4408
- // so we need to disable the sourceMap option.
4409
- sourceMap: false
4410
- }).end().use(utils.CHAIN_ID.USE.SASS).loader(getSharedPkgCompiledPath2("sass-loader")).options(options);
4411
- });
4412
- }
4413
- };
4414
- }
4415
- var GLOBAL_PATCHED_SYMBOL, getSassLoaderOptions, getResolveUrlJoinFn;
4416
- var init_sass = __esm({
4417
- "src/plugins/sass.ts"() {
4418
- "use strict";
4419
- init_esm();
4420
- init_helpers();
4421
- GLOBAL_PATCHED_SYMBOL = Symbol("GLOBAL_PATCHED_SYMBOL");
4422
- getSassLoaderOptions = (rsbuildSassConfig, isUseCssSourceMap) => {
4423
- const excludes = [];
4424
- const addExcludes = (items) => {
4425
- excludes.push(...castArray7(items));
4426
- };
4427
- const mergeFn = (defaults, userOptions) => {
4428
- const getSassOptions = () => {
4429
- if (defaults.sassOptions && userOptions.sassOptions) {
4430
- return deepmerge5(
4431
- defaults.sassOptions,
4432
- userOptions.sassOptions
4433
- );
4434
- }
4435
- return userOptions.sassOptions || defaults.sassOptions;
4436
- };
4437
- return {
4438
- ...defaults,
4439
- ...userOptions,
4440
- sassOptions: getSassOptions()
4441
- };
4442
- };
4443
- const mergedOptions = mergeChainedOptions6({
4444
- defaults: {
4445
- sourceMap: isUseCssSourceMap,
4446
- implementation: getSharedPkgCompiledPath2("sass")
4447
- },
4448
- options: rsbuildSassConfig,
4449
- utils: { addExcludes },
4450
- mergeFn
4451
- });
4452
- return {
4453
- options: mergedOptions,
4454
- excludes
4455
- };
4456
- };
4457
- getResolveUrlJoinFn = async () => {
4458
- const {
4459
- createJoinFunction,
4460
- asGenerator,
4461
- createJoinImplementation,
4462
- defaultJoinGenerator
4463
- } = await import("../compiled/resolve-url-loader/index.js");
4464
- const rsbuildGenerator = asGenerator((item, ...rest) => {
4465
- if (!item.uri.startsWith(".")) {
4466
- return [null];
4467
- }
4468
- return defaultJoinGenerator(item, ...rest);
4469
- });
4470
- return createJoinFunction(
4471
- "rsbuild-resolve-join-fn",
4472
- createJoinImplementation(rsbuildGenerator)
4473
- );
4474
- };
4475
- }
4476
- });
4477
-
4478
4256
  // src/plugins/server.ts
4479
4257
  var server_exports = {};
4480
4258
  __export(server_exports, {
@@ -4776,8 +4554,6 @@ var init_plugins = __esm({
4776
4554
  performance: () => Promise.resolve().then(() => (init_performance(), performance_exports)).then((m) => m.pluginPerformance()),
4777
4555
  define: () => Promise.resolve().then(() => (init_define(), define_exports)).then((m) => m.pluginDefine()),
4778
4556
  css: () => Promise.resolve().then(() => (init_css(), css_exports)).then((m) => m.pluginCss()),
4779
- less: () => Promise.resolve().then(() => (init_less(), less_exports)).then((m) => m.pluginLess()),
4780
- sass: () => Promise.resolve().then(() => (init_sass(), sass_exports)).then((m) => m.pluginSass()),
4781
4557
  server: () => Promise.resolve().then(() => (init_server(), server_exports)).then((m) => m.pluginServer()),
4782
4558
  moduleFederation: () => Promise.resolve().then(() => (init_moduleFederation(), moduleFederation_exports)).then((m) => m.pluginModuleFederation()),
4783
4559
  manifest: () => Promise.resolve().then(() => (init_manifest(), manifest_exports)).then((m) => m.pluginManifest())
@@ -4863,11 +4639,11 @@ var init_inspectConfig = __esm({
4863
4639
  // src/provider/rspackConfig.ts
4864
4640
  import {
4865
4641
  CHAIN_ID as CHAIN_ID2,
4866
- castArray as castArray8,
4642
+ castArray as castArray6,
4867
4643
  chainToConfig,
4868
4644
  debug as debug3,
4869
4645
  getNodeEnv as getNodeEnv5,
4870
- mergeChainedOptions as mergeChainedOptions7,
4646
+ mergeChainedOptions as mergeChainedOptions5,
4871
4647
  modifyBundlerChain
4872
4648
  } from "@rsbuild/shared";
4873
4649
  import { rspack as rspack5 } from "@rspack/core";
@@ -4878,7 +4654,7 @@ async function modifyRspackConfig(context, rspackConfig, utils) {
4878
4654
  utils
4879
4655
  );
4880
4656
  if (context.config.tools?.rspack) {
4881
- modifiedConfig = mergeChainedOptions7({
4657
+ modifiedConfig = mergeChainedOptions5({
4882
4658
  defaults: modifiedConfig,
4883
4659
  options: context.config.tools.rspack,
4884
4660
  utils,
@@ -4895,7 +4671,7 @@ async function getConfigUtils(config, chainUtils) {
4895
4671
  rspack: rspack5,
4896
4672
  mergeConfig: merge2,
4897
4673
  addRules(rules) {
4898
- const ruleArr = castArray8(rules);
4674
+ const ruleArr = castArray6(rules);
4899
4675
  if (!config.module) {
4900
4676
  config.module = {};
4901
4677
  }
@@ -4905,14 +4681,14 @@ async function getConfigUtils(config, chainUtils) {
4905
4681
  config.module.rules.unshift(...ruleArr);
4906
4682
  },
4907
4683
  prependPlugins(plugins2) {
4908
- const pluginArr = castArray8(plugins2);
4684
+ const pluginArr = castArray6(plugins2);
4909
4685
  if (!config.plugins) {
4910
4686
  config.plugins = [];
4911
4687
  }
4912
4688
  config.plugins.unshift(...pluginArr);
4913
4689
  },
4914
4690
  appendPlugins(plugins2) {
4915
- const pluginArr = castArray8(plugins2);
4691
+ const pluginArr = castArray6(plugins2);
4916
4692
  if (!config.plugins) {
4917
4693
  config.plugins = [];
4918
4694
  }
@@ -5286,16 +5062,16 @@ __export(swc_exports, {
5286
5062
  applySwcDecoratorConfig: () => applySwcDecoratorConfig,
5287
5063
  pluginSwc: () => pluginSwc
5288
5064
  });
5289
- import path13 from "path";
5065
+ import path11 from "path";
5290
5066
  import {
5291
5067
  SCRIPT_REGEX,
5292
5068
  applyScriptCondition,
5293
5069
  cloneDeep,
5294
- deepmerge as deepmerge6,
5070
+ deepmerge as deepmerge4,
5295
5071
  getBrowserslistWithDefault as getBrowserslistWithDefault3,
5296
5072
  getCoreJsVersion,
5297
5073
  isWebTarget,
5298
- mergeChainedOptions as mergeChainedOptions8
5074
+ mergeChainedOptions as mergeChainedOptions6
5299
5075
  } from "@rsbuild/shared";
5300
5076
  async function getDefaultSwcConfig(config, rootPath, target) {
5301
5077
  return {
@@ -5319,7 +5095,7 @@ async function getDefaultSwcConfig(config, rootPath, target) {
5319
5095
  async function applyCoreJs(swcConfig, chain, polyfillMode) {
5320
5096
  const coreJsPath = __require.resolve("core-js/package.json");
5321
5097
  const version2 = getCoreJsVersion(coreJsPath);
5322
- const coreJsDir = path13.dirname(coreJsPath);
5098
+ const coreJsDir = path11.dirname(coreJsPath);
5323
5099
  swcConfig.env.coreJs = version2;
5324
5100
  if (polyfillMode === "usage") {
5325
5101
  swcConfig.env.shippedProposals = true;
@@ -5388,7 +5164,7 @@ var init_swc = __esm({
5388
5164
  if (swcConfig.jsc?.externalHelpers) {
5389
5165
  chain.resolve.alias.set(
5390
5166
  "@swc/helpers",
5391
- path13.dirname(__require.resolve("@swc/helpers/package.json"))
5167
+ path11.dirname(__require.resolve("@swc/helpers/package.json"))
5392
5168
  );
5393
5169
  }
5394
5170
  if (isWebTarget(target)) {
@@ -5400,10 +5176,10 @@ var init_swc = __esm({
5400
5176
  await applyCoreJs(swcConfig, chain, polyfillMode);
5401
5177
  }
5402
5178
  }
5403
- const mergedSwcConfig = mergeChainedOptions8({
5179
+ const mergedSwcConfig = mergeChainedOptions6({
5404
5180
  defaults: swcConfig,
5405
5181
  options: config.tools.swc,
5406
- mergeFn: deepmerge6
5182
+ mergeFn: deepmerge4
5407
5183
  });
5408
5184
  rule.use(CHAIN_ID3.USE.SWC).loader(builtinSwcLoaderName).options(mergedSwcConfig);
5409
5185
  chain.module.rule(CHAIN_ID3.RULE.JS_DATA_URI).mimetype({
@@ -5423,7 +5199,7 @@ __export(rspackProfile_exports, {
5423
5199
  stopProfiler: () => stopProfiler
5424
5200
  });
5425
5201
  import inspector from "inspector";
5426
- import path14 from "path";
5202
+ import path12 from "path";
5427
5203
  import { fse as fse7 } from "@rsbuild/shared";
5428
5204
  import { logger as logger10 } from "@rsbuild/shared";
5429
5205
  import { rspack as rspack8 } from "@rspack/core";
@@ -5452,7 +5228,7 @@ var init_rspackProfile = __esm({
5452
5228
  return;
5453
5229
  }
5454
5230
  const timestamp = Date.now();
5455
- const profileDir = path14.join(
5231
+ const profileDir = path12.join(
5456
5232
  api.context.distPath,
5457
5233
  `rspack-profile-${timestamp}`
5458
5234
  );
@@ -5460,9 +5236,9 @@ var init_rspackProfile = __esm({
5460
5236
  const enableProfileTrace = RSPACK_PROFILE === "ALL" || RSPACK_PROFILE.includes("TRACE");
5461
5237
  const enableCPUProfile = RSPACK_PROFILE === "ALL" || RSPACK_PROFILE.includes("CPU");
5462
5238
  const enableLogging = RSPACK_PROFILE === "ALL" || RSPACK_PROFILE.includes("LOGGING");
5463
- const traceFilePath = path14.join(profileDir, "trace.json");
5464
- const cpuProfilePath = path14.join(profileDir, "jscpuprofile.json");
5465
- const loggingFilePath = path14.join(profileDir, "logging.json");
5239
+ const traceFilePath = path12.join(profileDir, "trace.json");
5240
+ const cpuProfilePath = path12.join(profileDir, "jscpuprofile.json");
5241
+ const loggingFilePath = path12.join(profileDir, "logging.json");
5466
5242
  const onStart = () => {
5467
5243
  fse7.ensureDirSync(profileDir);
5468
5244
  if (enableProfileTrace) {
@@ -5504,7 +5280,7 @@ var init_rspackProfile = __esm({
5504
5280
  });
5505
5281
 
5506
5282
  // src/server/middlewares.ts
5507
- import path15 from "path";
5283
+ import path13 from "path";
5508
5284
  import { parse as parse2 } from "url";
5509
5285
  import {
5510
5286
  color as color11,
@@ -5611,7 +5387,7 @@ var init_middlewares = __esm({
5611
5387
  };
5612
5388
  if (pathname.endsWith("/")) {
5613
5389
  const newUrl = `${pathname}index.html`;
5614
- const filePath = path15.join(distPath, pathname, "index.html");
5390
+ const filePath = path13.join(distPath, pathname, "index.html");
5615
5391
  if (await isFileExists2(filePath)) {
5616
5392
  return rewrite(newUrl);
5617
5393
  }
@@ -5620,13 +5396,13 @@ var init_middlewares = __esm({
5620
5396
  !pathname.endsWith(".html")
5621
5397
  ) {
5622
5398
  const newUrl = `${pathname}.html`;
5623
- const filePath = path15.join(distPath, `${pathname}.html`);
5399
+ const filePath = path13.join(distPath, `${pathname}.html`);
5624
5400
  if (await isFileExists2(filePath)) {
5625
5401
  return rewrite(newUrl);
5626
5402
  }
5627
5403
  }
5628
5404
  if (htmlFallback === "index") {
5629
- if (await isFileExists2(path15.join(distPath, "index.html"))) {
5405
+ if (await isFileExists2(path13.join(distPath, "index.html"))) {
5630
5406
  return rewrite("/index.html", true);
5631
5407
  }
5632
5408
  }
@@ -5766,8 +5542,8 @@ var init_getDevMiddlewares = __esm({
5766
5542
  }
5767
5543
  middlewares.push((req, res, next) => {
5768
5544
  res.setHeader("Access-Control-Allow-Origin", "*");
5769
- const path16 = req.url ? url.parse(req.url).pathname : "";
5770
- if (path16?.includes("hot-update")) {
5545
+ const path14 = req.url ? url.parse(req.url).pathname : "";
5546
+ if (path14?.includes("hot-update")) {
5771
5547
  res.setHeader("Access-Control-Allow-Credentials", "false");
5772
5548
  }
5773
5549
  const confHeaders = server.headers;
@@ -5875,7 +5651,7 @@ import {
5875
5651
  DEFAULT_DEV_HOST as DEFAULT_DEV_HOST3,
5876
5652
  DEFAULT_PORT as DEFAULT_PORT3,
5877
5653
  color as color12,
5878
- deepmerge as deepmerge7,
5654
+ deepmerge as deepmerge5,
5879
5655
  isFunction as isFunction7,
5880
5656
  logger as logger13,
5881
5657
  normalizeUrl
@@ -5944,7 +5720,7 @@ function printServerURLs({
5944
5720
  logger13.log(message);
5945
5721
  return message;
5946
5722
  }
5947
- var formatPrefix, formatRoutes, HMR_SOCK_PATH, mergeDevOptions, getPort, getServerOptions, getDevOptions, getIpv4Interfaces, isLoopbackHost, getHostInUrl, concatUrl, LOCAL_LABEL, NETWORK_LABEL, getUrlLabel, getAddressUrls;
5723
+ var formatPrefix, formatRoutes, HMR_SOCK_PATH, getPort, getServerConfig, getDevConfig, getIpv4Interfaces, isLoopbackHost, getHostInUrl, concatUrl, LOCAL_LABEL, NETWORK_LABEL, getUrlLabel, getAddressUrls;
5948
5724
  var init_helper = __esm({
5949
5725
  "src/server/helper.ts"() {
5950
5726
  "use strict";
@@ -5969,25 +5745,6 @@ var init_helper = __esm({
5969
5745
  }).sort((a) => a.entryName === "index" ? -1 : 1);
5970
5746
  };
5971
5747
  HMR_SOCK_PATH = "/rsbuild-hmr";
5972
- mergeDevOptions = ({
5973
- rsbuildConfig,
5974
- port
5975
- }) => {
5976
- const defaultDevConfig = {
5977
- client: {
5978
- path: HMR_SOCK_PATH,
5979
- port: port.toString(),
5980
- // By default it is set to "location.hostname"
5981
- host: "",
5982
- // By default it is set to "location.protocol === 'https:' ? 'wss' : 'ws'""
5983
- protocol: void 0
5984
- },
5985
- writeToDisk: false,
5986
- liveReload: true
5987
- };
5988
- const devConfig = rsbuildConfig.dev ? deepmerge7(defaultDevConfig, rsbuildConfig.dev) : defaultDevConfig;
5989
- return devConfig;
5990
- };
5991
5748
  getPort = async ({
5992
5749
  host,
5993
5750
  port,
@@ -6038,38 +5795,38 @@ var init_helper = __esm({
6038
5795
  }
6039
5796
  return port;
6040
5797
  };
6041
- getServerOptions = async ({
6042
- rsbuildConfig,
5798
+ getServerConfig = async ({
5799
+ config,
6043
5800
  getPortSilently
6044
5801
  }) => {
6045
- const host = rsbuildConfig.server?.host || DEFAULT_DEV_HOST3;
5802
+ const host = config.server.host || DEFAULT_DEV_HOST3;
6046
5803
  const port = await getPort({
6047
5804
  host,
6048
- port: rsbuildConfig.server?.port || DEFAULT_PORT3,
6049
- strictPort: rsbuildConfig.server?.strictPort || false,
5805
+ port: config.server.port || DEFAULT_PORT3,
5806
+ strictPort: config.server.strictPort || false,
6050
5807
  silent: getPortSilently
6051
5808
  });
6052
- const https = Boolean(rsbuildConfig.server?.https) || false;
6053
- return { port, host, https, serverConfig: rsbuildConfig.server || {} };
5809
+ const https = Boolean(config.server.https) || false;
5810
+ return { port, host, https };
6054
5811
  };
6055
- getDevOptions = async ({
6056
- rsbuildConfig,
6057
- getPortSilently
5812
+ getDevConfig = ({
5813
+ config,
5814
+ port
6058
5815
  }) => {
6059
- const { port, host, https, serverConfig } = await getServerOptions({
6060
- rsbuildConfig,
6061
- getPortSilently
6062
- });
6063
- const devConfig = mergeDevOptions({ rsbuildConfig, port });
6064
- const liveReload = devConfig.liveReload;
6065
- return {
6066
- devConfig,
6067
- serverConfig,
6068
- port,
6069
- host,
6070
- https,
6071
- liveReload
5816
+ const defaultDevConfig = {
5817
+ client: {
5818
+ path: HMR_SOCK_PATH,
5819
+ port: port.toString(),
5820
+ // By default it is set to "location.hostname"
5821
+ host: "",
5822
+ // By default it is set to "location.protocol === 'https:' ? 'wss' : 'ws'""
5823
+ protocol: void 0
5824
+ },
5825
+ writeToDisk: false,
5826
+ liveReload: true
6072
5827
  };
5828
+ const devConfig = config.dev ? deepmerge5(defaultDevConfig, config.dev) : defaultDevConfig;
5829
+ return devConfig;
6073
5830
  };
6074
5831
  getIpv4Interfaces = () => {
6075
5832
  const interfaces = os.networkInterfaces();
@@ -6494,7 +6251,7 @@ import {
6494
6251
  setNodeEnv as setNodeEnv2
6495
6252
  } from "@rsbuild/shared";
6496
6253
  import connect from "@rsbuild/shared/connect";
6497
- async function createDevServer(options, createDevMiddleware2, {
6254
+ async function createDevServer(options, createDevMiddleware2, config, {
6498
6255
  compiler: customCompiler,
6499
6256
  getPortSilently,
6500
6257
  runCompile = true
@@ -6503,15 +6260,19 @@ async function createDevServer(options, createDevMiddleware2, {
6503
6260
  setNodeEnv2("development");
6504
6261
  }
6505
6262
  debug7("create dev server");
6506
- const rsbuildConfig = options.context.config;
6507
- const { devConfig, serverConfig, port, host, https } = await getDevOptions({
6508
- rsbuildConfig,
6263
+ const serverConfig = config.server;
6264
+ const { port, host, https } = await getServerConfig({
6265
+ config,
6509
6266
  getPortSilently
6510
6267
  });
6268
+ const devConfig = getDevConfig({
6269
+ config,
6270
+ port
6271
+ });
6511
6272
  const routes = formatRoutes(
6512
6273
  options.context.entry,
6513
- rsbuildConfig.output?.distPath?.html,
6514
- rsbuildConfig.html?.outputStructure
6274
+ config.output.distPath.html,
6275
+ config.html.outputStructure
6515
6276
  );
6516
6277
  options.context.devServer = {
6517
6278
  hostname: host,
@@ -6575,7 +6336,7 @@ async function createDevServer(options, createDevMiddleware2, {
6575
6336
  dev: devConfig,
6576
6337
  server: serverConfig,
6577
6338
  output: {
6578
- distPath: rsbuildConfig.output?.distPath?.root || ROOT_DIST_DIR2
6339
+ distPath: config.output.distPath.root || ROOT_DIST_DIR2
6579
6340
  },
6580
6341
  outputFileSystem
6581
6342
  });
@@ -6671,19 +6432,20 @@ import {
6671
6432
  } from "@rsbuild/shared";
6672
6433
  import connect2 from "@rsbuild/shared/connect";
6673
6434
  import sirv from "../compiled/sirv/index.js";
6674
- async function startProdServer(context, rsbuildConfig, { getPortSilently } = {}) {
6435
+ async function startProdServer(context, config, { getPortSilently } = {}) {
6675
6436
  if (!getNodeEnv7()) {
6676
6437
  setNodeEnv3("production");
6677
6438
  }
6678
- const { serverConfig, port, host, https } = await getServerOptions({
6679
- rsbuildConfig,
6439
+ const { port, host, https } = await getServerConfig({
6440
+ config,
6680
6441
  getPortSilently
6681
6442
  });
6443
+ const serverConfig = config.server;
6682
6444
  const server = new RsbuildProdServer({
6683
6445
  pwd: context.rootPath,
6684
6446
  output: {
6685
- path: rsbuildConfig.output?.distPath?.root || ROOT_DIST_DIR3,
6686
- assetPrefix: rsbuildConfig.output?.assetPrefix
6447
+ path: config.output.distPath.root || ROOT_DIST_DIR3,
6448
+ assetPrefix: config.output.assetPrefix
6687
6449
  },
6688
6450
  serverConfig
6689
6451
  });
@@ -6702,8 +6464,8 @@ async function startProdServer(context, rsbuildConfig, { getPortSilently } = {})
6702
6464
  async () => {
6703
6465
  const routes = formatRoutes(
6704
6466
  context.entry,
6705
- rsbuildConfig.output?.distPath?.html,
6706
- rsbuildConfig.html?.outputStructure
6467
+ config.output.distPath.html,
6468
+ config.html.outputStructure
6707
6469
  );
6708
6470
  await context.hooks.onAfterStartProdServer.call({
6709
6471
  port,
@@ -6798,11 +6560,11 @@ var init_prodServer = __esm({
6798
6560
  }
6799
6561
  applyStaticAssetMiddleware() {
6800
6562
  const {
6801
- output: { path: path16, assetPrefix },
6563
+ output: { path: path14, assetPrefix },
6802
6564
  serverConfig: { htmlFallback },
6803
6565
  pwd
6804
6566
  } = this.options;
6805
- const assetMiddleware = sirv(join11(pwd, path16), {
6567
+ const assetMiddleware = sirv(join11(pwd, path14), {
6806
6568
  etag: true,
6807
6569
  dev: true,
6808
6570
  ignores: ["favicon.ico"],
@@ -6960,8 +6722,6 @@ var init_provider = __esm({
6960
6722
  plugins.nodeAddons(),
6961
6723
  plugins.define(),
6962
6724
  plugins.css(),
6963
- plugins.less(),
6964
- plugins.sass(),
6965
6725
  Promise.resolve().then(() => (init_minimize(), minimize_exports)).then((m) => m.pluginMinimize()),
6966
6726
  Promise.resolve().then(() => (init_progress(), progress_exports)).then((m) => m.pluginProgress()),
6967
6727
  Promise.resolve().then(() => (init_swc(), swc_exports)).then((m) => m.pluginSwc()),
@@ -6983,28 +6743,30 @@ var init_provider = __esm({
6983
6743
  async createDevServer(options) {
6984
6744
  const { createDevServer: createDevServer2 } = await Promise.resolve().then(() => (init_devServer(), devServer_exports));
6985
6745
  const { createDevMiddleware: createDevMiddleware2 } = await Promise.resolve().then(() => (init_createCompiler(), createCompiler_exports));
6986
- await initRsbuildConfig({ context, pluginManager });
6746
+ const config = await initRsbuildConfig({ context, pluginManager });
6987
6747
  return createDevServer2(
6988
6748
  { context, pluginManager, rsbuildOptions },
6989
6749
  createDevMiddleware2,
6750
+ config,
6990
6751
  options
6991
6752
  );
6992
6753
  },
6993
6754
  async startDevServer(options) {
6994
6755
  const { createDevServer: createDevServer2 } = await Promise.resolve().then(() => (init_devServer(), devServer_exports));
6995
6756
  const { createDevMiddleware: createDevMiddleware2 } = await Promise.resolve().then(() => (init_createCompiler(), createCompiler_exports));
6996
- await initRsbuildConfig({ context, pluginManager });
6757
+ const config = await initRsbuildConfig({ context, pluginManager });
6997
6758
  const server = await createDevServer2(
6998
6759
  { context, pluginManager, rsbuildOptions },
6999
6760
  createDevMiddleware2,
6761
+ config,
7000
6762
  options
7001
6763
  );
7002
6764
  return server.listen();
7003
6765
  },
7004
6766
  async preview(options) {
7005
6767
  const { startProdServer: startProdServer2 } = await Promise.resolve().then(() => (init_prodServer(), prodServer_exports));
7006
- await initRsbuildConfig({ context, pluginManager });
7007
- return startProdServer2(context, context.config, options);
6768
+ const config = await initRsbuildConfig({ context, pluginManager });
6769
+ return startProdServer2(context, config, options);
7008
6770
  },
7009
6771
  async build(options) {
7010
6772
  const { build: build2 } = await Promise.resolve().then(() => (init_build(), build_exports));
@@ -7244,7 +7006,7 @@ var applyServerOptions = (command) => {
7244
7006
  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");
7245
7007
  };
7246
7008
  function runCli() {
7247
- program.name("rsbuild").usage("<command> [options]").version("0.7.0-beta.6");
7009
+ program.name("rsbuild").usage("<command> [options]").version("0.7.0-beta.7");
7248
7010
  const devCommand = program.command("dev");
7249
7011
  const buildCommand = program.command("build");
7250
7012
  const previewCommand = program.command("preview");
@@ -7325,7 +7087,7 @@ function prepareCli() {
7325
7087
  if (!npm_execpath || npm_execpath.includes("npx-cli.js") || npm_execpath.includes(".bun")) {
7326
7088
  console.log();
7327
7089
  }
7328
- logger18.greet(` ${`Rsbuild v${"0.7.0-beta.6"}`}
7090
+ logger18.greet(` ${`Rsbuild v${"0.7.0-beta.7"}`}
7329
7091
  `);
7330
7092
  }
7331
7093
 
@@ -7358,7 +7120,7 @@ init_config();
7358
7120
  init_mergeConfig();
7359
7121
  init_constants();
7360
7122
  import { logger as logger19 } from "@rsbuild/shared";
7361
- var version = "0.7.0-beta.6";
7123
+ var version = "0.7.0-beta.7";
7362
7124
  export {
7363
7125
  PLUGIN_CSS_NAME,
7364
7126
  PLUGIN_LESS_NAME,