@rsbuild/core 0.7.3 → 0.7.4

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
@@ -114,19 +114,53 @@ var init_format = __esm({
114
114
  });
115
115
 
116
116
  // src/constants.ts
117
- var import_node_path, PLUGIN_SWC_NAME, PLUGIN_CSS_NAME, LOADER_PATH, STATIC_PATH, COMPILED_PATH, TS_CONFIG_FILE, HTML_REGEX, CSS_REGEX;
117
+ var import_node_path, ROOT_DIST_DIR, HTML_DIST_DIR, SERVER_DIST_DIR, SERVICE_WORKER_DIST_DIR, JS_DIST_DIR, CSS_DIST_DIR, SVG_DIST_DIR, FONT_DIST_DIR, WASM_DIST_DIR, IMAGE_DIST_DIR, MEDIA_DIST_DIR, LOADER_PATH, STATIC_PATH, COMPILED_PATH, TS_CONFIG_FILE, DEFAULT_PORT, DEFAULT_DATA_URL_SIZE, DEFAULT_MOUNT_ID, DEFAULT_DEV_HOST, HTML_REGEX, CSS_REGEX, PLUGIN_SWC_NAME, PLUGIN_CSS_NAME, FONT_EXTENSIONS, IMAGE_EXTENSIONS, VIDEO_EXTENSIONS, AUDIO_EXTENSIONS;
118
118
  var init_constants = __esm({
119
119
  "src/constants.ts"() {
120
120
  "use strict";
121
121
  import_node_path = require("path");
122
- PLUGIN_SWC_NAME = "rsbuild:swc";
123
- PLUGIN_CSS_NAME = "rsbuild:css";
122
+ ROOT_DIST_DIR = "dist";
123
+ HTML_DIST_DIR = "/";
124
+ SERVER_DIST_DIR = "server";
125
+ SERVICE_WORKER_DIST_DIR = "worker";
126
+ JS_DIST_DIR = "static/js";
127
+ CSS_DIST_DIR = "static/css";
128
+ SVG_DIST_DIR = "static/svg";
129
+ FONT_DIST_DIR = "static/font";
130
+ WASM_DIST_DIR = "static/wasm";
131
+ IMAGE_DIST_DIR = "static/image";
132
+ MEDIA_DIST_DIR = "static/media";
124
133
  LOADER_PATH = (0, import_node_path.join)(__dirname);
125
134
  STATIC_PATH = (0, import_node_path.join)(__dirname, "../static");
126
135
  COMPILED_PATH = (0, import_node_path.join)(__dirname, "../compiled");
127
136
  TS_CONFIG_FILE = "tsconfig.json";
137
+ DEFAULT_PORT = 3e3;
138
+ DEFAULT_DATA_URL_SIZE = 4096;
139
+ DEFAULT_MOUNT_ID = "root";
140
+ DEFAULT_DEV_HOST = "0.0.0.0";
128
141
  HTML_REGEX = /\.html$/;
129
142
  CSS_REGEX = /\.css$/;
143
+ PLUGIN_SWC_NAME = "rsbuild:swc";
144
+ PLUGIN_CSS_NAME = "rsbuild:css";
145
+ FONT_EXTENSIONS = ["woff", "woff2", "eot", "ttf", "otf", "ttc"];
146
+ IMAGE_EXTENSIONS = [
147
+ "png",
148
+ "jpg",
149
+ "jpeg",
150
+ "pjpeg",
151
+ "pjp",
152
+ "gif",
153
+ "bmp",
154
+ "webp",
155
+ "ico",
156
+ "apng",
157
+ "avif",
158
+ "tif",
159
+ "tiff",
160
+ "jfif"
161
+ ];
162
+ VIDEO_EXTENSIONS = ["mp4", "webm", "ogg", "mov"];
163
+ AUDIO_EXTENSIONS = ["mp3", "wav", "flac", "aac", "m4a", "opus"];
130
164
  }
131
165
  });
132
166
 
@@ -355,6 +389,7 @@ var init_mergeConfig = __esm({
355
389
  "output.cssModules.auto",
356
390
  "output.targets",
357
391
  "output.emitAssets",
392
+ "server.open",
358
393
  "server.printUrls",
359
394
  "dev.startUrl",
360
395
  "provider"
@@ -541,6 +576,55 @@ async function loadConfig({
541
576
  throw err;
542
577
  }
543
578
  }
579
+ async function outputInspectConfigFiles({
580
+ rsbuildConfig,
581
+ rawRsbuildConfig,
582
+ bundlerConfigs,
583
+ inspectOptions,
584
+ configType
585
+ }) {
586
+ const { outputPath } = inspectOptions;
587
+ const files = [
588
+ {
589
+ path: (0, import_node_path4.join)(outputPath, "rsbuild.config.mjs"),
590
+ label: "Rsbuild Config",
591
+ content: rawRsbuildConfig
592
+ },
593
+ ...bundlerConfigs.map((content, index) => {
594
+ const suffix = rsbuildConfig.output.targets[index];
595
+ const outputFile = `${configType}.config.${suffix}.mjs`;
596
+ let outputFilePath = (0, import_node_path4.join)(outputPath, outputFile);
597
+ if (import_shared5.fse.existsSync(outputFilePath)) {
598
+ outputFilePath = outputFilePath.replace(/\.mjs$/, `.${Date.now()}.mjs`);
599
+ }
600
+ return {
601
+ path: outputFilePath,
602
+ label: `${(0, import_shared5.upperFirst)(configType)} Config (${suffix})`,
603
+ content
604
+ };
605
+ })
606
+ ];
607
+ await Promise.all(
608
+ files.map(
609
+ (item) => import_shared5.fse.outputFile(item.path, `export default ${item.content}`)
610
+ )
611
+ );
612
+ const fileInfos = files.map(
613
+ (item) => ` - ${import_shared5.color.bold(import_shared5.color.yellow(item.label))}: ${import_shared5.color.underline(
614
+ item.path
615
+ )}`
616
+ ).join("\n");
617
+ import_shared5.logger.success(
618
+ `Inspect config succeed, open following files to view the content:
619
+
620
+ ${fileInfos}
621
+ `
622
+ );
623
+ }
624
+ async function stringifyConfig(config, verbose) {
625
+ const stringify = import_shared5.RspackChain.toString;
626
+ return stringify(config, { verbose });
627
+ }
544
628
  var import_node_fs, import_node_path4, import_shared5, getDefaultDevConfig, getDefaultServerConfig, getDefaultSourceConfig, getDefaultHtmlConfig, getDefaultSecurityConfig, getDefaultToolsConfig, getDefaultPerformanceConfig, getDefaultOutputConfig, createDefaultConfig, withDefaultConfig, normalizeConfig, resolveConfigPath;
545
629
  var init_config = __esm({
546
630
  "src/config.ts"() {
@@ -562,8 +646,9 @@ var init_config = __esm({
562
646
  }
563
647
  });
564
648
  getDefaultServerConfig = () => ({
565
- port: import_shared5.DEFAULT_PORT,
566
- host: import_shared5.DEFAULT_DEV_HOST,
649
+ port: DEFAULT_PORT,
650
+ host: DEFAULT_DEV_HOST,
651
+ open: false,
567
652
  htmlFallback: "index",
568
653
  compress: true,
569
654
  printUrls: true,
@@ -590,7 +675,7 @@ var init_config = __esm({
590
675
  },
591
676
  title: "Rsbuild App",
592
677
  inject: "head",
593
- mountId: import_shared5.DEFAULT_MOUNT_ID,
678
+ mountId: DEFAULT_MOUNT_ID,
594
679
  crossorigin: false,
595
680
  outputStructure: "flat",
596
681
  scriptLoading: "defer"
@@ -622,27 +707,27 @@ var init_config = __esm({
622
707
  getDefaultOutputConfig = () => ({
623
708
  targets: ["web"],
624
709
  distPath: {
625
- root: import_shared5.ROOT_DIST_DIR,
626
- js: import_shared5.JS_DIST_DIR,
627
- css: import_shared5.CSS_DIST_DIR,
628
- svg: import_shared5.SVG_DIST_DIR,
629
- font: import_shared5.FONT_DIST_DIR,
630
- html: import_shared5.HTML_DIST_DIR,
631
- wasm: import_shared5.WASM_DIST_DIR,
632
- image: import_shared5.IMAGE_DIST_DIR,
633
- media: import_shared5.MEDIA_DIST_DIR,
634
- server: import_shared5.SERVER_DIST_DIR,
635
- worker: import_shared5.SERVICE_WORKER_DIST_DIR
710
+ root: ROOT_DIST_DIR,
711
+ js: JS_DIST_DIR,
712
+ css: CSS_DIST_DIR,
713
+ svg: SVG_DIST_DIR,
714
+ font: FONT_DIST_DIR,
715
+ html: HTML_DIST_DIR,
716
+ wasm: WASM_DIST_DIR,
717
+ image: IMAGE_DIST_DIR,
718
+ media: MEDIA_DIST_DIR,
719
+ server: SERVER_DIST_DIR,
720
+ worker: SERVICE_WORKER_DIST_DIR
636
721
  },
637
722
  assetPrefix: import_shared5.DEFAULT_ASSET_PREFIX,
638
723
  filename: {},
639
724
  charset: "ascii",
640
725
  polyfill: "usage",
641
726
  dataUriLimit: {
642
- svg: import_shared5.DEFAULT_DATA_URL_SIZE,
643
- font: import_shared5.DEFAULT_DATA_URL_SIZE,
644
- image: import_shared5.DEFAULT_DATA_URL_SIZE,
645
- media: import_shared5.DEFAULT_DATA_URL_SIZE
727
+ svg: DEFAULT_DATA_URL_SIZE,
728
+ font: DEFAULT_DATA_URL_SIZE,
729
+ image: DEFAULT_DATA_URL_SIZE,
730
+ media: DEFAULT_DATA_URL_SIZE
646
731
  },
647
732
  legalComments: "linked",
648
733
  injectStyles: false,
@@ -918,7 +1003,7 @@ async function createContextByConfig(options, bundlerType, config = {}) {
918
1003
  return {
919
1004
  entry: getEntryObject(config, "web"),
920
1005
  targets: config.output?.targets || [],
921
- version: "0.7.3",
1006
+ version: "0.7.4",
922
1007
  rootPath,
923
1008
  distPath,
924
1009
  cachePath,
@@ -1335,13 +1420,13 @@ async function inspectConfig({
1335
1420
  ...context.normalizedConfig,
1336
1421
  pluginNames: pluginManager.getPlugins().map((p) => p.name)
1337
1422
  };
1338
- const rawRsbuildConfig = await (0, import_shared12.stringifyConfig)(
1423
+ const rawRsbuildConfig = await stringifyConfig(
1339
1424
  rsbuildDebugConfig,
1340
1425
  inspectOptions.verbose
1341
1426
  );
1342
1427
  const rawBundlerConfigs = await Promise.all(
1343
1428
  rspackConfigs.map(
1344
- (config) => (0, import_shared12.stringifyConfig)(config, inspectOptions.verbose)
1429
+ (config) => stringifyConfig(config, inspectOptions.verbose)
1345
1430
  )
1346
1431
  );
1347
1432
  let outputPath = inspectOptions.outputPath || context.distPath;
@@ -1349,7 +1434,7 @@ async function inspectConfig({
1349
1434
  outputPath = (0, import_node_path8.join)(context.rootPath, outputPath);
1350
1435
  }
1351
1436
  if (inspectOptions.writeToDisk) {
1352
- await (0, import_shared12.outputInspectConfigFiles)({
1437
+ await outputInspectConfigFiles({
1353
1438
  rsbuildConfig: context.normalizedConfig,
1354
1439
  rawRsbuildConfig,
1355
1440
  bundlerConfigs: rawBundlerConfigs,
@@ -1375,6 +1460,7 @@ var init_inspectConfig = __esm({
1375
1460
  "use strict";
1376
1461
  import_node_path8 = require("path");
1377
1462
  import_shared12 = require("@rsbuild/shared");
1463
+ init_config();
1378
1464
  init_initConfigs();
1379
1465
  }
1380
1466
  });
@@ -2163,6 +2249,7 @@ var init_helper = __esm({
2163
2249
  import_node_net = __toESM(require("net"));
2164
2250
  import_node_os = __toESM(require("os"));
2165
2251
  import_shared20 = require("@rsbuild/shared");
2252
+ init_constants();
2166
2253
  formatPrefix = (prefix) => {
2167
2254
  if (!prefix) {
2168
2255
  return "/";
@@ -2237,10 +2324,10 @@ var init_helper = __esm({
2237
2324
  config,
2238
2325
  getPortSilently
2239
2326
  }) => {
2240
- const host = config.server.host || import_shared20.DEFAULT_DEV_HOST;
2327
+ const host = config.server.host || DEFAULT_DEV_HOST;
2241
2328
  const port = await getPort({
2242
2329
  host,
2243
- port: config.server.port || import_shared20.DEFAULT_PORT,
2330
+ port: config.server.port || DEFAULT_PORT,
2244
2331
  strictPort: config.server.strictPort || false,
2245
2332
  silent: getPortSilently
2246
2333
  });
@@ -2314,7 +2401,7 @@ var init_helper = __esm({
2314
2401
  port,
2315
2402
  host
2316
2403
  }) => {
2317
- if (host && host !== import_shared20.DEFAULT_DEV_HOST) {
2404
+ if (host && host !== DEFAULT_DEV_HOST) {
2318
2405
  return [
2319
2406
  {
2320
2407
  label: isLoopbackHost(host) ? LOCAL_LABEL : NETWORK_LABEL,
@@ -2776,7 +2863,7 @@ async function createDevServer(options, createDevMiddleware2, config, {
2776
2863
  dev: devConfig,
2777
2864
  server: serverConfig,
2778
2865
  output: {
2779
- distPath: config.output.distPath.root || import_shared22.ROOT_DIST_DIR
2866
+ distPath: config.output.distPath.root || ROOT_DIST_DIR
2780
2867
  },
2781
2868
  outputFileSystem
2782
2869
  });
@@ -2851,6 +2938,7 @@ var init_devServer = __esm({
2851
2938
  "use strict";
2852
2939
  import_node_fs3 = __toESM(require("fs"));
2853
2940
  import_shared22 = require("@rsbuild/shared");
2941
+ init_constants();
2854
2942
  init_getDevMiddlewares();
2855
2943
  init_helper();
2856
2944
  init_httpServer();
@@ -2881,7 +2969,7 @@ async function startProdServer(context, config, { getPortSilently } = {}) {
2881
2969
  {
2882
2970
  pwd: context.rootPath,
2883
2971
  output: {
2884
- path: config.output.distPath.root || import_shared23.ROOT_DIST_DIR,
2972
+ path: config.output.distPath.root || ROOT_DIST_DIR,
2885
2973
  assetPrefix: config.output.assetPrefix
2886
2974
  },
2887
2975
  serverConfig
@@ -2942,6 +3030,7 @@ var init_prodServer = __esm({
2942
3030
  "use strict";
2943
3031
  import_node_path11 = require("path");
2944
3032
  import_shared23 = require("@rsbuild/shared");
3033
+ init_constants();
2945
3034
  init_helper();
2946
3035
  init_httpServer();
2947
3036
  init_middlewares();
@@ -3618,9 +3707,9 @@ function getPublicPath({
3618
3707
  publicPath = dev.assetPrefix;
3619
3708
  } else if (dev.assetPrefix === true) {
3620
3709
  const protocol = context.devServer?.https ? "https" : "http";
3621
- const hostname = context.devServer?.hostname || import_shared29.DEFAULT_DEV_HOST;
3622
- const port = context.devServer?.port || import_shared29.DEFAULT_PORT;
3623
- if (hostname === import_shared29.DEFAULT_DEV_HOST) {
3710
+ const hostname = context.devServer?.hostname || DEFAULT_DEV_HOST;
3711
+ const port = context.devServer?.port || DEFAULT_PORT;
3712
+ if (hostname === DEFAULT_DEV_HOST) {
3624
3713
  const localHostname = "localhost";
3625
3714
  publicPath = `${protocol}://${localHostname}:${port}/`;
3626
3715
  } else {
@@ -3636,6 +3725,7 @@ var init_output = __esm({
3636
3725
  import_node_path15 = require("path");
3637
3726
  import_shared29 = require("@rsbuild/shared");
3638
3727
  import_core5 = require("@rspack/core");
3728
+ init_constants();
3639
3729
  init_helpers();
3640
3730
  init_pluginHelper();
3641
3731
  init_css();
@@ -3653,7 +3743,18 @@ var init_output = __esm({
3653
3743
  const jsPath = (0, import_shared29.getDistPath)(config, "js");
3654
3744
  const jsAsyncPath = (0, import_shared29.getDistPath)(config, "jsAsync");
3655
3745
  const jsFilename = (0, import_shared29.getFilename)(config, "js", isProd5);
3656
- chain.output.path(api.context.distPath).filename(import_node_path15.posix.join(jsPath, jsFilename)).chunkFilename(import_node_path15.posix.join(jsAsyncPath, jsFilename)).publicPath(publicPath).pathinfo(false).hashFunction("xxhash64");
3746
+ const isJsFilenameFn = typeof jsFilename === "function";
3747
+ chain.output.path(api.context.distPath).filename(
3748
+ isJsFilenameFn ? (...args) => {
3749
+ const name = jsFilename(...args);
3750
+ return import_node_path15.posix.join(jsPath, name);
3751
+ } : import_node_path15.posix.join(jsPath, jsFilename)
3752
+ ).chunkFilename(
3753
+ isJsFilenameFn ? (...args) => {
3754
+ const name = jsFilename(...args);
3755
+ return import_node_path15.posix.join(jsAsyncPath, name);
3756
+ } : import_node_path15.posix.join(jsAsyncPath, jsFilename)
3757
+ ).publicPath(publicPath).pathinfo(false).hashFunction("xxhash64");
3657
3758
  if (isServer) {
3658
3759
  const serverPath = (0, import_shared29.getDistPath)(config, "server");
3659
3760
  chain.output.path(import_node_path15.posix.join(api.context.distPath, serverPath)).filename("[name].js").chunkFilename("[name].js").library({
@@ -4025,6 +4126,7 @@ var init_asset = __esm({
4025
4126
  "use strict";
4026
4127
  import_node_path18 = __toESM(require("path"));
4027
4128
  import_shared34 = require("@rsbuild/shared");
4129
+ init_constants();
4028
4130
  chainStaticAssetRule = ({
4029
4131
  emit,
4030
4132
  rule,
@@ -4067,14 +4169,14 @@ var init_asset = __esm({
4067
4169
  });
4068
4170
  };
4069
4171
  const emit = config.output.emitAssets({ target });
4070
- createAssetRule("image", import_shared34.IMAGE_EXTENSIONS, emit);
4172
+ createAssetRule("image", IMAGE_EXTENSIONS, emit);
4071
4173
  createAssetRule("svg", ["svg"], emit);
4072
4174
  createAssetRule(
4073
4175
  "media",
4074
- [...import_shared34.VIDEO_EXTENSIONS, ...import_shared34.AUDIO_EXTENSIONS],
4176
+ [...VIDEO_EXTENSIONS, ...AUDIO_EXTENSIONS],
4075
4177
  emit
4076
4178
  );
4077
- createAssetRule("font", import_shared34.FONT_EXTENSIONS, emit);
4179
+ createAssetRule("font", FONT_EXTENSIONS, emit);
4078
4180
  });
4079
4181
  }
4080
4182
  });
@@ -4371,20 +4473,18 @@ var init_HtmlBasicPlugin = __esm({
4371
4473
  addTitleTag(headTags, data.plugin.options?.title);
4372
4474
  }
4373
4475
  addFavicon(headTags, favicon);
4374
- const result = await this.modifyTagsFn(
4375
- {
4376
- headTags: headTags.map(formatBasicTag),
4377
- bodyTags: bodyTags.map(formatBasicTag)
4378
- },
4379
- {
4380
- compilation,
4381
- assetPrefix: data.publicPath,
4382
- filename: data.outputName
4383
- }
4384
- );
4476
+ const tags = {
4477
+ headTags: headTags.map(formatBasicTag),
4478
+ bodyTags: bodyTags.map(formatBasicTag)
4479
+ };
4480
+ const modified = this.modifyTagsFn ? await this.modifyTagsFn(tags, {
4481
+ compilation,
4482
+ assetPrefix: data.publicPath,
4483
+ filename: data.outputName
4484
+ }) : tags;
4385
4485
  Object.assign(data, {
4386
- headTags: result.headTags.map(fromBasicTag),
4387
- bodyTags: result.bodyTags.map(fromBasicTag)
4486
+ headTags: modified.headTags.map(fromBasicTag),
4487
+ bodyTags: modified.bodyTags.map(fromBasicTag)
4388
4488
  });
4389
4489
  if (tagConfig) {
4390
4490
  const hash = compilation.hash ?? "";
@@ -5310,10 +5410,7 @@ var init_splitChunks = __esm({
5310
5410
  rootPath: api.context.rootPath,
5311
5411
  polyfill: config.output.polyfill
5312
5412
  });
5313
- chain.optimization.splitChunks(
5314
- // @ts-expect-error splitChunks type mismatch
5315
- splitChunksOptions
5316
- );
5413
+ chain.optimization.splitChunks(splitChunksOptions);
5317
5414
  }
5318
5415
  );
5319
5416
  }
@@ -5321,12 +5418,13 @@ var init_splitChunks = __esm({
5321
5418
  }
5322
5419
  });
5323
5420
 
5324
- // src/plugins/startUrl.ts
5325
- var startUrl_exports = {};
5326
- __export(startUrl_exports, {
5421
+ // src/plugins/open.ts
5422
+ var open_exports = {};
5423
+ __export(open_exports, {
5327
5424
  openBrowser: () => openBrowser,
5328
- pluginStartUrl: () => pluginStartUrl,
5329
- replacePlaceholder: () => replacePlaceholder
5425
+ pluginOpen: () => pluginOpen,
5426
+ replacePlaceholder: () => replacePlaceholder,
5427
+ resolveUrl: () => resolveUrl
5330
5428
  });
5331
5429
  async function openBrowser(url2) {
5332
5430
  const shouldTryOpenChromeWithAppleScript = process.platform === "darwin";
@@ -5360,30 +5458,45 @@ async function openBrowser(url2) {
5360
5458
  return false;
5361
5459
  }
5362
5460
  }
5363
- function pluginStartUrl() {
5461
+ function resolveUrl(str, base) {
5462
+ if ((0, import_shared44.canParse)(str)) {
5463
+ return str;
5464
+ }
5465
+ try {
5466
+ const url2 = new URL(str, base);
5467
+ return url2.href;
5468
+ } catch (e) {
5469
+ throw new Error(
5470
+ "[rsbuild:open]: Invalid input: not a valid URL or pathname"
5471
+ );
5472
+ }
5473
+ }
5474
+ function pluginOpen() {
5364
5475
  return {
5365
- name: "rsbuild:start-url",
5476
+ name: "rsbuild:open",
5366
5477
  setup(api) {
5367
5478
  const onStartServer = async (params) => {
5368
5479
  const { port, routes } = params;
5369
5480
  const config = api.getNormalizedConfig();
5370
- const { startUrl, beforeStartUrl } = config.dev;
5481
+ const { beforeStartUrl } = config.dev;
5482
+ const open = config.server.open || config.dev.startUrl;
5371
5483
  const { https } = api.context.devServer || {};
5372
5484
  const isCodesandbox = process.env.CSB === "true";
5373
- const shouldOpen = Boolean(startUrl) && !isCodesandbox;
5485
+ const shouldOpen = Boolean(open) && !isCodesandbox;
5374
5486
  if (!shouldOpen) {
5375
5487
  return;
5376
5488
  }
5377
5489
  const urls = [];
5378
- if (startUrl === true || !startUrl) {
5379
- const protocol = https ? "https" : "http";
5490
+ const protocol = https ? "https" : "http";
5491
+ const baseUrl = `${protocol}://localhost:${port}`;
5492
+ if (open === true || !open) {
5380
5493
  if (routes.length) {
5381
- urls.push(`${protocol}://localhost:${port}${routes[0].pathname}`);
5494
+ urls.push(`${baseUrl}${routes[0].pathname}`);
5382
5495
  }
5383
5496
  } else {
5384
5497
  urls.push(
5385
- ...(0, import_shared44.castArray)(startUrl).map(
5386
- (item) => replacePlaceholder(item, port)
5498
+ ...(0, import_shared44.castArray)(open).map(
5499
+ (item) => resolveUrl(replacePlaceholder(item, port), baseUrl)
5387
5500
  )
5388
5501
  );
5389
5502
  }
@@ -5409,8 +5522,8 @@ function pluginStartUrl() {
5409
5522
  };
5410
5523
  }
5411
5524
  var import_node_child_process, import_node_util, import_shared44, execAsync, supportedChromiumBrowsers, getTargetBrowser, replacePlaceholder, openedURLs;
5412
- var init_startUrl = __esm({
5413
- "src/plugins/startUrl.ts"() {
5525
+ var init_open = __esm({
5526
+ "src/plugins/open.ts"() {
5414
5527
  "use strict";
5415
5528
  import_node_child_process = require("child_process");
5416
5529
  import_node_util = require("util");
@@ -5818,16 +5931,16 @@ function determineAsValue({
5818
5931
  if (["css"].includes(extension)) {
5819
5932
  return "style";
5820
5933
  }
5821
- if (import_shared49.IMAGE_EXTENSIONS.includes(extension)) {
5934
+ if (IMAGE_EXTENSIONS.includes(extension)) {
5822
5935
  return "image";
5823
5936
  }
5824
- if (import_shared49.VIDEO_EXTENSIONS.includes(extension)) {
5937
+ if (VIDEO_EXTENSIONS.includes(extension)) {
5825
5938
  return "video";
5826
5939
  }
5827
- if (import_shared49.AUDIO_EXTENSIONS.includes(extension)) {
5940
+ if (AUDIO_EXTENSIONS.includes(extension)) {
5828
5941
  return "audio";
5829
5942
  }
5830
- if (import_shared49.FONT_EXTENSIONS.includes(extension)) {
5943
+ if (FONT_EXTENSIONS.includes(extension)) {
5831
5944
  return "font";
5832
5945
  }
5833
5946
  if (["vtt"].includes(extension)) {
@@ -5835,13 +5948,13 @@ function determineAsValue({
5835
5948
  }
5836
5949
  return "script";
5837
5950
  }
5838
- var import_node_path25, import_node_url3, import_shared49;
5951
+ var import_node_path25, import_node_url3;
5839
5952
  var init_determineAsValue = __esm({
5840
5953
  "src/rspack/preload/helpers/determineAsValue.ts"() {
5841
5954
  "use strict";
5842
5955
  import_node_path25 = __toESM(require("path"));
5843
5956
  import_node_url3 = require("url");
5844
- import_shared49 = require("@rsbuild/shared");
5957
+ init_constants();
5845
5958
  }
5846
5959
  });
5847
5960
 
@@ -5949,10 +6062,10 @@ function generateLinks(options, type, compilation, htmlPluginData, HTMLCount) {
5949
6062
  );
5950
6063
  const sortedFilteredFiles = filteredFiles.sort();
5951
6064
  const links = [];
5952
- const publicPath = (0, import_shared50.getPublicPathFromCompiler)(compilation.compiler);
6065
+ const publicPath = (0, import_shared49.getPublicPathFromCompiler)(compilation.compiler);
5953
6066
  const { crossOriginLoading } = compilation.compiler.options.output;
5954
6067
  for (const file of sortedFilteredFiles) {
5955
- const href = (0, import_shared50.withPublicPath)(file, publicPath);
6068
+ const href = (0, import_shared49.withPublicPath)(file, publicPath);
5956
6069
  const attributes = {
5957
6070
  href,
5958
6071
  rel: type
@@ -5980,11 +6093,11 @@ function generateLinks(options, type, compilation, htmlPluginData, HTMLCount) {
5980
6093
  }
5981
6094
  return links;
5982
6095
  }
5983
- var import_shared50, defaultOptions, HtmlPreloadOrPrefetchPlugin;
6096
+ var import_shared49, defaultOptions, HtmlPreloadOrPrefetchPlugin;
5984
6097
  var init_HtmlPreloadOrPrefetchPlugin = __esm({
5985
6098
  "src/rspack/preload/HtmlPreloadOrPrefetchPlugin.ts"() {
5986
6099
  "use strict";
5987
- import_shared50 = require("@rsbuild/shared");
6100
+ import_shared49 = require("@rsbuild/shared");
5988
6101
  init_pluginHelper();
5989
6102
  init_helpers2();
5990
6103
  defaultOptions = {
@@ -6006,7 +6119,7 @@ var init_HtmlPreloadOrPrefetchPlugin = __esm({
6006
6119
  apply(compiler) {
6007
6120
  compiler.hooks.compilation.tap(this.constructor.name, (compilation) => {
6008
6121
  getHTMLPlugin().getHooks(compilation).beforeAssetTagGeneration.tap(
6009
- `HTML${(0, import_shared50.upperFirst)(this.type)}Plugin`,
6122
+ `HTML${(0, import_shared49.upperFirst)(this.type)}Plugin`,
6010
6123
  (htmlPluginData) => {
6011
6124
  this.resourceHints = generateLinks(
6012
6125
  this.options,
@@ -6019,7 +6132,7 @@ var init_HtmlPreloadOrPrefetchPlugin = __esm({
6019
6132
  }
6020
6133
  );
6021
6134
  getHTMLPlugin().getHooks(compilation).alterAssetTags.tap(
6022
- `HTML${(0, import_shared50.upperFirst)(this.type)}Plugin`,
6135
+ `HTML${(0, import_shared49.upperFirst)(this.type)}Plugin`,
6023
6136
  (htmlPluginData) => {
6024
6137
  if (this.resourceHints) {
6025
6138
  htmlPluginData.assetTags.styles = [
@@ -6044,11 +6157,11 @@ var resourceHints_exports = {};
6044
6157
  __export(resourceHints_exports, {
6045
6158
  pluginResourceHints: () => pluginResourceHints
6046
6159
  });
6047
- var import_shared51, generateLinks2, pluginResourceHints;
6160
+ var import_shared50, generateLinks2, pluginResourceHints;
6048
6161
  var init_resourceHints = __esm({
6049
6162
  "src/plugins/resourceHints.ts"() {
6050
6163
  "use strict";
6051
- import_shared51 = require("@rsbuild/shared");
6164
+ import_shared50 = require("@rsbuild/shared");
6052
6165
  generateLinks2 = (options, rel) => options.map((option) => ({
6053
6166
  tag: "link",
6054
6167
  attrs: {
@@ -6083,7 +6196,7 @@ var init_resourceHints = __esm({
6083
6196
  const {
6084
6197
  performance: { preload, prefetch }
6085
6198
  } = config;
6086
- if ((0, import_shared51.isHtmlDisabled)(config, target)) {
6199
+ if ((0, import_shared50.isHtmlDisabled)(config, target)) {
6087
6200
  return;
6088
6201
  }
6089
6202
  const HTMLCount = chain.entryPoints.values().length;
@@ -6146,12 +6259,12 @@ var server_exports = {};
6146
6259
  __export(server_exports, {
6147
6260
  pluginServer: () => pluginServer
6148
6261
  });
6149
- var import_node_path26, import_shared52, pluginServer;
6262
+ var import_node_path26, import_shared51, pluginServer;
6150
6263
  var init_server = __esm({
6151
6264
  "src/plugins/server.ts"() {
6152
6265
  "use strict";
6153
6266
  import_node_path26 = require("path");
6154
- import_shared52 = require("@rsbuild/shared");
6267
+ import_shared51 = require("@rsbuild/shared");
6155
6268
  pluginServer = () => ({
6156
6269
  name: "rsbuild:server",
6157
6270
  setup(api) {
@@ -6163,11 +6276,11 @@ var init_server = __esm({
6163
6276
  return;
6164
6277
  }
6165
6278
  const publicDir = (0, import_node_path26.isAbsolute)(name) ? name : (0, import_node_path26.join)(api.context.rootPath, name);
6166
- if (!import_shared52.fse.existsSync(publicDir)) {
6279
+ if (!import_shared51.fse.existsSync(publicDir)) {
6167
6280
  return;
6168
6281
  }
6169
6282
  try {
6170
- await import_shared52.fse.copy(publicDir, api.context.distPath, {
6283
+ await import_shared51.fse.copy(publicDir, api.context.distPath, {
6171
6284
  // dereference symlinks
6172
6285
  dereference: true
6173
6286
  });
@@ -6281,7 +6394,6 @@ var init_manifest = __esm({
6281
6394
  name: "rsbuild:manifest",
6282
6395
  setup(api) {
6283
6396
  api.modifyBundlerChain(async (chain, { CHAIN_ID: CHAIN_ID3 }) => {
6284
- const htmlPaths = api.getHTMLPaths();
6285
6397
  const {
6286
6398
  output: { manifest }
6287
6399
  } = api.getNormalizedConfig();
@@ -6290,6 +6402,7 @@ var init_manifest = __esm({
6290
6402
  }
6291
6403
  const fileName = typeof manifest === "string" ? manifest : "manifest.json";
6292
6404
  const { RspackManifestPlugin } = await import("../compiled/rspack-manifest-plugin/index.js");
6405
+ const htmlPaths = api.getHTMLPaths();
6293
6406
  chain.plugin(CHAIN_ID3.PLUGIN.MANIFEST).use(RspackManifestPlugin, [
6294
6407
  {
6295
6408
  fileName,
@@ -6334,18 +6447,18 @@ function pluginModuleFederation() {
6334
6447
  chain.plugin("mf-patch-split-chunks").use(PatchSplitChunksPlugin, [options.name]);
6335
6448
  }
6336
6449
  const publicPath = chain.output.get("publicPath");
6337
- if (publicPath === import_shared53.DEFAULT_ASSET_PREFIX) {
6450
+ if (publicPath === import_shared52.DEFAULT_ASSET_PREFIX) {
6338
6451
  chain.output.set("publicPath", "auto");
6339
6452
  }
6340
6453
  });
6341
6454
  }
6342
6455
  };
6343
6456
  }
6344
- var import_shared53, import_core8, PatchSplitChunksPlugin;
6457
+ var import_shared52, import_core8, PatchSplitChunksPlugin;
6345
6458
  var init_moduleFederation = __esm({
6346
6459
  "src/plugins/moduleFederation.ts"() {
6347
6460
  "use strict";
6348
- import_shared53 = require("@rsbuild/shared");
6461
+ import_shared52 = require("@rsbuild/shared");
6349
6462
  import_core8 = require("@rspack/core");
6350
6463
  PatchSplitChunksPlugin = class {
6351
6464
  constructor(name) {
@@ -6413,14 +6526,14 @@ __export(rspackProfile_exports, {
6413
6526
  pluginRspackProfile: () => pluginRspackProfile,
6414
6527
  stopProfiler: () => stopProfiler
6415
6528
  });
6416
- var import_node_inspector, import_node_path27, import_shared54, import_shared55, import_core9, stopProfiler, pluginRspackProfile;
6529
+ var import_node_inspector, import_node_path27, import_shared53, import_shared54, import_core9, stopProfiler, pluginRspackProfile;
6417
6530
  var init_rspackProfile = __esm({
6418
6531
  "src/plugins/rspackProfile.ts"() {
6419
6532
  "use strict";
6420
6533
  import_node_inspector = __toESM(require("inspector"));
6421
6534
  import_node_path27 = __toESM(require("path"));
6535
+ import_shared53 = require("@rsbuild/shared");
6422
6536
  import_shared54 = require("@rsbuild/shared");
6423
- import_shared55 = require("@rsbuild/shared");
6424
6537
  import_core9 = require("@rspack/core");
6425
6538
  stopProfiler = (output, profileSession) => {
6426
6539
  if (!profileSession) {
@@ -6428,10 +6541,10 @@ var init_rspackProfile = __esm({
6428
6541
  }
6429
6542
  profileSession.post("Profiler.stop", (error, param) => {
6430
6543
  if (error) {
6431
- import_shared55.logger.error("Failed to generate JS CPU profile:", error);
6544
+ import_shared54.logger.error("Failed to generate JS CPU profile:", error);
6432
6545
  return;
6433
6546
  }
6434
- import_shared54.fse.writeFileSync(output, JSON.stringify(param.profile));
6547
+ import_shared53.fse.writeFileSync(output, JSON.stringify(param.profile));
6435
6548
  });
6436
6549
  };
6437
6550
  pluginRspackProfile = () => ({
@@ -6457,7 +6570,7 @@ var init_rspackProfile = __esm({
6457
6570
  const cpuProfilePath = import_node_path27.default.join(profileDir, "jscpuprofile.json");
6458
6571
  const loggingFilePath = import_node_path27.default.join(profileDir, "logging.json");
6459
6572
  const onStart = () => {
6460
- import_shared54.fse.ensureDirSync(profileDir);
6573
+ import_shared53.fse.ensureDirSync(profileDir);
6461
6574
  if (enableProfileTrace) {
6462
6575
  import_core9.rspack.experimental_registerGlobalTrace(
6463
6576
  "trace",
@@ -6481,7 +6594,7 @@ var init_rspackProfile = __esm({
6481
6594
  logging: "verbose",
6482
6595
  loggingTrace: true
6483
6596
  });
6484
- import_shared54.fse.writeFileSync(loggingFilePath, JSON.stringify(logging));
6597
+ import_shared53.fse.writeFileSync(loggingFilePath, JSON.stringify(logging));
6485
6598
  }
6486
6599
  });
6487
6600
  api.onExit(() => {
@@ -6489,7 +6602,7 @@ var init_rspackProfile = __esm({
6489
6602
  import_core9.rspack.experimental_cleanupGlobalTrace();
6490
6603
  }
6491
6604
  stopProfiler(cpuProfilePath, profileSession);
6492
- import_shared55.logger.info(`Saved Rspack profile file to ${profileDir}`);
6605
+ import_shared54.logger.info(`Saved Rspack profile file to ${profileDir}`);
6493
6606
  });
6494
6607
  }
6495
6608
  });
@@ -6501,11 +6614,11 @@ var lazyCompilation_exports = {};
6501
6614
  __export(lazyCompilation_exports, {
6502
6615
  pluginLazyCompilation: () => pluginLazyCompilation
6503
6616
  });
6504
- var import_shared56, pluginLazyCompilation;
6617
+ var import_shared55, pluginLazyCompilation;
6505
6618
  var init_lazyCompilation = __esm({
6506
6619
  "src/plugins/lazyCompilation.ts"() {
6507
6620
  "use strict";
6508
- import_shared56 = require("@rsbuild/shared");
6621
+ import_shared55 = require("@rsbuild/shared");
6509
6622
  pluginLazyCompilation = () => ({
6510
6623
  name: "rsbuild:lazy-compilation",
6511
6624
  setup(api) {
@@ -6518,12 +6631,10 @@ var init_lazyCompilation = __esm({
6518
6631
  if (!options) {
6519
6632
  return;
6520
6633
  }
6521
- const clientRegExp = /[\\/]core[\\/]dist[\\/]client[\\/]/;
6522
6634
  const cssRegExp = /\.(?:css|less|sass|scss|styl|stylus)$/;
6523
6635
  const isExcludedModule = (name) => {
6524
6636
  return (
6525
- // alway include Rsbuild client code, such as HMR
6526
- clientRegExp.test(name) || // exclude CSS files because Rspack does not support it yet
6637
+ // exclude CSS files because Rspack does not support it yet
6527
6638
  // TODO: remove this after Rspack supporting it
6528
6639
  cssRegExp.test(name)
6529
6640
  );
@@ -6553,7 +6664,7 @@ var init_lazyCompilation = __esm({
6553
6664
  if (!name || isExcludedModule(name)) {
6554
6665
  return false;
6555
6666
  }
6556
- if ((0, import_shared56.isRegExp)(test)) {
6667
+ if ((0, import_shared55.isRegExp)(test)) {
6557
6668
  return name ? test.test(name) : false;
6558
6669
  }
6559
6670
  return test(module2);
@@ -6575,18 +6686,18 @@ var sri_exports = {};
6575
6686
  __export(sri_exports, {
6576
6687
  pluginSri: () => pluginSri
6577
6688
  });
6578
- var import_node_crypto2, import_shared57, getAssetName, pluginSri;
6689
+ var import_node_crypto2, import_shared56, getAssetName, pluginSri;
6579
6690
  var init_sri = __esm({
6580
6691
  "src/plugins/sri.ts"() {
6581
6692
  "use strict";
6582
6693
  import_node_crypto2 = __toESM(require("crypto"));
6583
- import_shared57 = require("@rsbuild/shared");
6694
+ import_shared56 = require("@rsbuild/shared");
6584
6695
  init_constants();
6585
6696
  getAssetName = (url2, assetPrefix) => {
6586
6697
  if (url2.startsWith(assetPrefix)) {
6587
- return (0, import_shared57.removeLeadingSlash)(url2.replace(assetPrefix, ""));
6698
+ return (0, import_shared56.removeLeadingSlash)(url2.replace(assetPrefix, ""));
6588
6699
  }
6589
- return (0, import_shared57.removeLeadingSlash)(url2);
6700
+ return (0, import_shared56.removeLeadingSlash)(url2);
6590
6701
  };
6591
6702
  pluginSri = () => ({
6592
6703
  name: "rsbuild:sri",
@@ -6595,7 +6706,7 @@ var init_sri = __esm({
6595
6706
  const getAlgorithm = () => {
6596
6707
  const config = api.getNormalizedConfig();
6597
6708
  const { sri } = config.security;
6598
- const enable = sri.enable === "auto" ? (0, import_shared57.isProd)() : sri.enable;
6709
+ const enable = sri.enable === "auto" ? (0, import_shared56.isProd)() : sri.enable;
6599
6710
  if (!enable) {
6600
6711
  return null;
6601
6712
  }
@@ -6662,7 +6773,7 @@ var init_sri = __esm({
6662
6773
  `integrity="${integrity}"`
6663
6774
  );
6664
6775
  } else {
6665
- import_shared57.logger.debug(
6776
+ import_shared56.logger.debug(
6666
6777
  `[rsbuild:sri] failed to generate integrity for ${assetName}.`
6667
6778
  );
6668
6779
  replacedHtml = replacedHtml.replace(
@@ -6715,7 +6826,7 @@ var init_sri = __esm({
6715
6826
  }
6716
6827
  api.modifyBundlerChain((chain, { target }) => {
6717
6828
  const config = api.getNormalizedConfig();
6718
- if ((0, import_shared57.isHtmlDisabled)(config, target)) {
6829
+ if ((0, import_shared56.isHtmlDisabled)(config, target)) {
6719
6830
  return;
6720
6831
  }
6721
6832
  const algorithm = getAlgorithm();
@@ -6734,11 +6845,11 @@ var nonce_exports = {};
6734
6845
  __export(nonce_exports, {
6735
6846
  pluginNonce: () => pluginNonce
6736
6847
  });
6737
- var import_shared58, pluginNonce;
6848
+ var import_shared57, pluginNonce;
6738
6849
  var init_nonce = __esm({
6739
6850
  "src/plugins/nonce.ts"() {
6740
6851
  "use strict";
6741
- import_shared58 = require("@rsbuild/shared");
6852
+ import_shared57 = require("@rsbuild/shared");
6742
6853
  pluginNonce = () => ({
6743
6854
  name: "rsbuild:nonce",
6744
6855
  setup(api) {
@@ -6747,7 +6858,7 @@ var init_nonce = __esm({
6747
6858
  if (!nonce) {
6748
6859
  return;
6749
6860
  }
6750
- (0, import_shared58.applyToCompiler)(compiler, (compiler2) => {
6861
+ (0, import_shared57.applyToCompiler)(compiler, (compiler2) => {
6751
6862
  const { plugins } = compiler2.options;
6752
6863
  const hasHTML = plugins.some(
6753
6864
  (plugin) => plugin && plugin.constructor.name === "HtmlBasicPlugin"
@@ -6755,7 +6866,7 @@ var init_nonce = __esm({
6755
6866
  if (!hasHTML) {
6756
6867
  return;
6757
6868
  }
6758
- const injectCode = (0, import_shared58.createVirtualModule)(
6869
+ const injectCode = (0, import_shared57.createVirtualModule)(
6759
6870
  `__webpack_nonce__ = "${nonce}";`
6760
6871
  );
6761
6872
  new compiler2.webpack.EntryPlugin(compiler2.context, injectCode, {
@@ -6813,7 +6924,7 @@ async function applyDefaultPlugins(pluginManager, context) {
6813
6924
  const { pluginSwc: pluginSwc2 } = await Promise.resolve().then(() => (init_swc(), swc_exports));
6814
6925
  const { pluginExternals: pluginExternals2 } = await Promise.resolve().then(() => (init_externals(), externals_exports));
6815
6926
  const { pluginSplitChunks: pluginSplitChunks2 } = await Promise.resolve().then(() => (init_splitChunks(), splitChunks_exports));
6816
- const { pluginStartUrl: pluginStartUrl2 } = await Promise.resolve().then(() => (init_startUrl(), startUrl_exports));
6927
+ const { pluginOpen: pluginOpen2 } = await Promise.resolve().then(() => (init_open(), open_exports));
6817
6928
  const { pluginInlineChunk: pluginInlineChunk2 } = await Promise.resolve().then(() => (init_inlineChunk(), inlineChunk_exports));
6818
6929
  const { pluginBundleAnalyzer: pluginBundleAnalyzer2 } = await Promise.resolve().then(() => (init_bundleAnalyzer(), bundleAnalyzer_exports));
6819
6930
  const { pluginRsdoctor: pluginRsdoctor2 } = await Promise.resolve().then(() => (init_rsdoctor(), rsdoctor_exports));
@@ -6851,7 +6962,7 @@ async function applyDefaultPlugins(pluginManager, context) {
6851
6962
  pluginSwc2(),
6852
6963
  pluginExternals2(),
6853
6964
  pluginSplitChunks2(),
6854
- pluginStartUrl2(),
6965
+ pluginOpen2(),
6855
6966
  pluginInlineChunk2(),
6856
6967
  pluginBundleAnalyzer2(),
6857
6968
  pluginRsdoctor2(),
@@ -6881,9 +6992,9 @@ async function createRsbuild(options = {}) {
6881
6992
  );
6882
6993
  const pluginAPI = getPluginAPI({ context, pluginManager });
6883
6994
  context.pluginAPI = pluginAPI;
6884
- (0, import_shared59.debug)("add default plugins");
6995
+ (0, import_shared58.debug)("add default plugins");
6885
6996
  await applyDefaultPlugins(pluginManager, context);
6886
- (0, import_shared59.debug)("add default plugins done");
6997
+ (0, import_shared58.debug)("add default plugins done");
6887
6998
  const provider = rsbuildConfig.provider || await getRspackProvider();
6888
6999
  const providerInstance = await provider({
6889
7000
  context,
@@ -6892,13 +7003,13 @@ async function createRsbuild(options = {}) {
6892
7003
  setCssExtractPlugin
6893
7004
  });
6894
7005
  const rsbuild = {
6895
- ...(0, import_shared59.pick)(pluginManager, [
7006
+ ...(0, import_shared58.pick)(pluginManager, [
6896
7007
  "addPlugins",
6897
7008
  "getPlugins",
6898
7009
  "removePlugins",
6899
7010
  "isPluginExists"
6900
7011
  ]),
6901
- ...(0, import_shared59.pick)(pluginAPI, [
7012
+ ...(0, import_shared58.pick)(pluginAPI, [
6902
7013
  "onBeforeBuild",
6903
7014
  "onBeforeCreateCompiler",
6904
7015
  "onBeforeStartDevServer",
@@ -6914,7 +7025,7 @@ async function createRsbuild(options = {}) {
6914
7025
  "getRsbuildConfig",
6915
7026
  "getNormalizedConfig"
6916
7027
  ]),
6917
- ...(0, import_shared59.pick)(providerInstance, [
7028
+ ...(0, import_shared58.pick)(providerInstance, [
6918
7029
  "build",
6919
7030
  "preview",
6920
7031
  "initConfigs",
@@ -6931,11 +7042,11 @@ async function createRsbuild(options = {}) {
6931
7042
  }
6932
7043
  return rsbuild;
6933
7044
  }
6934
- var import_shared59, getRspackProvider, pickRsbuildConfig;
7045
+ var import_shared58, getRspackProvider, pickRsbuildConfig;
6935
7046
  var init_createRsbuild = __esm({
6936
7047
  "src/createRsbuild.ts"() {
6937
7048
  "use strict";
6938
- import_shared59 = require("@rsbuild/shared");
7049
+ import_shared58 = require("@rsbuild/shared");
6939
7050
  init_createContext();
6940
7051
  init_initPlugins();
6941
7052
  init_pluginHelper();
@@ -6957,7 +7068,7 @@ var init_createRsbuild = __esm({
6957
7068
  "moduleFederation",
6958
7069
  "_privateMeta"
6959
7070
  ];
6960
- return (0, import_shared59.pick)(rsbuildConfig, keys);
7071
+ return (0, import_shared58.pick)(rsbuildConfig, keys);
6961
7072
  };
6962
7073
  }
6963
7074
  });
@@ -6976,7 +7087,7 @@ async function init({
6976
7087
  cwd: root,
6977
7088
  mode: cliOptions?.envMode
6978
7089
  });
6979
- if ((0, import_shared60.isDev)()) {
7090
+ if ((0, import_shared59.isDev)()) {
6980
7091
  onBeforeRestartServer(envs.cleanup);
6981
7092
  }
6982
7093
  const { content: config, filePath: configFilePath } = await loadConfig({
@@ -6998,9 +7109,9 @@ async function init({
6998
7109
  ...envs.publicVars,
6999
7110
  ...config.source.define
7000
7111
  };
7001
- if (commonOpts.open && !config.dev?.startUrl) {
7002
- config.dev ||= {};
7003
- config.dev.startUrl = commonOpts.open;
7112
+ if (commonOpts.open && !config.server?.open) {
7113
+ config.server ||= {};
7114
+ config.server.open = commonOpts.open;
7004
7115
  }
7005
7116
  if (commonOpts.host) {
7006
7117
  config.server ||= {};
@@ -7016,17 +7127,17 @@ async function init({
7016
7127
  });
7017
7128
  } catch (err) {
7018
7129
  if (isRestart) {
7019
- import_shared60.logger.error(err);
7130
+ import_shared59.logger.error(err);
7020
7131
  } else {
7021
7132
  throw err;
7022
7133
  }
7023
7134
  }
7024
7135
  }
7025
- var import_shared60, commonOpts;
7136
+ var import_shared59, commonOpts;
7026
7137
  var init_init = __esm({
7027
7138
  "src/cli/init.ts"() {
7028
7139
  "use strict";
7029
- import_shared60 = require("@rsbuild/shared");
7140
+ import_shared59 = require("@rsbuild/shared");
7030
7141
  init_config();
7031
7142
  init_loadEnv();
7032
7143
  init_restart();
@@ -7044,7 +7155,7 @@ __export(src_exports, {
7044
7155
  defineConfig: () => defineConfig,
7045
7156
  loadConfig: () => loadConfig,
7046
7157
  loadEnv: () => loadEnv,
7047
- logger: () => import_shared63.logger,
7158
+ logger: () => import_shared62.logger,
7048
7159
  mergeRsbuildConfig: () => mergeRsbuildConfig,
7049
7160
  rspack: () => import_core10.rspack,
7050
7161
  version: () => version
@@ -7067,16 +7178,18 @@ __export(internal_exports, {
7067
7178
  initHooks: () => initHooks,
7068
7179
  initPlugins: () => initPlugins,
7069
7180
  initRsbuildConfig: () => initRsbuildConfig,
7181
+ outputInspectConfigFiles: () => outputInspectConfigFiles,
7070
7182
  prepareCli: () => prepareCli,
7071
7183
  runCli: () => runCli,
7072
7184
  setHTMLPlugin: () => setHTMLPlugin,
7073
- startProdServer: () => startProdServer
7185
+ startProdServer: () => startProdServer,
7186
+ stringifyConfig: () => stringifyConfig
7074
7187
  });
7075
7188
 
7076
7189
  // src/cli/commands.ts
7077
7190
  var import_node_fs5 = require("fs");
7078
7191
  var import_node_path28 = require("path");
7079
- var import_shared61 = require("@rsbuild/shared");
7192
+ var import_shared60 = require("@rsbuild/shared");
7080
7193
  var import_commander = require("../compiled/commander/index.js");
7081
7194
  init_helpers();
7082
7195
  init_init();
@@ -7093,7 +7206,7 @@ var applyServerOptions = (command) => {
7093
7206
  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");
7094
7207
  };
7095
7208
  function runCli() {
7096
- import_commander.program.name("rsbuild").usage("<command> [options]").version("0.7.3");
7209
+ import_commander.program.name("rsbuild").usage("<command> [options]").version("0.7.4");
7097
7210
  const devCommand = import_commander.program.command("dev");
7098
7211
  const buildCommand = import_commander.program.command("build");
7099
7212
  const previewCommand = import_commander.program.command("preview");
@@ -7107,8 +7220,8 @@ function runCli() {
7107
7220
  const rsbuild = await init({ cliOptions: options });
7108
7221
  await rsbuild?.startDevServer();
7109
7222
  } catch (err) {
7110
- import_shared61.logger.error("Failed to start dev server.");
7111
- import_shared61.logger.error(err);
7223
+ import_shared60.logger.error("Failed to start dev server.");
7224
+ import_shared60.logger.error(err);
7112
7225
  process.exit(1);
7113
7226
  }
7114
7227
  });
@@ -7119,8 +7232,8 @@ function runCli() {
7119
7232
  watch: options.watch
7120
7233
  });
7121
7234
  } catch (err) {
7122
- import_shared61.logger.error("Failed to build.");
7123
- import_shared61.logger.error(err);
7235
+ import_shared60.logger.error("Failed to build.");
7236
+ import_shared60.logger.error(err);
7124
7237
  process.exit(1);
7125
7238
  }
7126
7239
  });
@@ -7131,14 +7244,14 @@ function runCli() {
7131
7244
  const { distPath } = rsbuild.context;
7132
7245
  if (!(0, import_node_fs5.existsSync)(distPath)) {
7133
7246
  throw new Error(
7134
- `The output directory ${import_shared61.color.yellow(
7247
+ `The output directory ${import_shared60.color.yellow(
7135
7248
  distPath
7136
7249
  )} does not exist, please build the project before previewing.`
7137
7250
  );
7138
7251
  }
7139
7252
  if (isEmptyDir(distPath)) {
7140
7253
  throw new Error(
7141
- `The output directory ${import_shared61.color.yellow(
7254
+ `The output directory ${import_shared60.color.yellow(
7142
7255
  distPath
7143
7256
  )} is empty, please build the project before previewing.`
7144
7257
  );
@@ -7146,8 +7259,8 @@ function runCli() {
7146
7259
  }
7147
7260
  await rsbuild?.preview();
7148
7261
  } catch (err) {
7149
- import_shared61.logger.error("Failed to start preview server.");
7150
- import_shared61.logger.error(err);
7262
+ import_shared60.logger.error("Failed to start preview server.");
7263
+ import_shared60.logger.error(err);
7151
7264
  process.exit(1);
7152
7265
  }
7153
7266
  });
@@ -7161,8 +7274,8 @@ function runCli() {
7161
7274
  writeToDisk: true
7162
7275
  });
7163
7276
  } catch (err) {
7164
- import_shared61.logger.error("Failed to inspect config.");
7165
- import_shared61.logger.error(err);
7277
+ import_shared60.logger.error("Failed to inspect config.");
7278
+ import_shared60.logger.error(err);
7166
7279
  process.exit(1);
7167
7280
  }
7168
7281
  });
@@ -7170,7 +7283,7 @@ function runCli() {
7170
7283
  }
7171
7284
 
7172
7285
  // src/cli/prepare.ts
7173
- var import_shared62 = require("@rsbuild/shared");
7286
+ var import_shared61 = require("@rsbuild/shared");
7174
7287
  function initNodeEnv() {
7175
7288
  if (!process.env.NODE_ENV) {
7176
7289
  const command = process.argv[2];
@@ -7183,7 +7296,7 @@ function prepareCli() {
7183
7296
  if (!npm_execpath || npm_execpath.includes("npx-cli.js") || npm_execpath.includes(".bun")) {
7184
7297
  console.log();
7185
7298
  }
7186
- import_shared62.logger.greet(` ${`Rsbuild v${"0.7.3"}`}
7299
+ import_shared61.logger.greet(` ${`Rsbuild v${"0.7.4"}`}
7187
7300
  `);
7188
7301
  }
7189
7302
 
@@ -7191,6 +7304,7 @@ function prepareCli() {
7191
7304
  init_pluginManager();
7192
7305
  init_initHooks();
7193
7306
  init_initConfigs();
7307
+ init_config();
7194
7308
  init_pluginHelper();
7195
7309
  init_helpers();
7196
7310
  init_rspackConfig();
@@ -7206,10 +7320,10 @@ init_prodServer();
7206
7320
  init_loadEnv();
7207
7321
  init_createRsbuild();
7208
7322
  init_config();
7209
- var import_shared63 = require("@rsbuild/shared");
7323
+ var import_shared62 = require("@rsbuild/shared");
7210
7324
  init_mergeConfig();
7211
7325
  init_constants();
7212
- var version = "0.7.3";
7326
+ var version = "0.7.4";
7213
7327
  // Annotate the CommonJS export names for ESM import in node:
7214
7328
  0 && (module.exports = {
7215
7329
  PLUGIN_CSS_NAME,