@rsbuild/core 0.7.4 → 0.7.5

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.
@@ -1,19 +1,19 @@
1
1
  /******/ (() => { // webpackBootstrap
2
2
  /******/ var __webpack_modules__ = ({
3
3
 
4
- /***/ 4458:
4
+ /***/ 7685:
5
5
  /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
6
6
 
7
7
  "use strict";
8
8
 
9
9
 
10
- const loader = __nccwpck_require__(8773);
10
+ const loader = __nccwpck_require__(6944);
11
11
  module.exports = loader.default;
12
- module.exports.defaultGetLocalIdent = __nccwpck_require__(256).defaultGetLocalIdent;
12
+ module.exports.defaultGetLocalIdent = __nccwpck_require__(1525).defaultGetLocalIdent;
13
13
 
14
14
  /***/ }),
15
15
 
16
- /***/ 8773:
16
+ /***/ 6944:
17
17
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
18
18
 
19
19
  "use strict";
@@ -26,9 +26,9 @@ exports["default"] = loader;
26
26
  var _postcss = _interopRequireDefault(__nccwpck_require__(977));
27
27
  var _package = _interopRequireDefault(__nccwpck_require__(5446));
28
28
  var _semver = __nccwpck_require__(1280);
29
- var _options = _interopRequireDefault(__nccwpck_require__(8962));
30
- var _plugins = __nccwpck_require__(9270);
31
- var _utils = __nccwpck_require__(256);
29
+ var _options = _interopRequireDefault(__nccwpck_require__(7361));
30
+ var _plugins = __nccwpck_require__(3449);
31
+ var _utils = __nccwpck_require__(1525);
32
32
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
33
33
  /*
34
34
  MIT License http://www.opensource.org/licenses/mit-license.php
@@ -198,7 +198,7 @@ async function loader(content, map, meta) {
198
198
 
199
199
  /***/ }),
200
200
 
201
- /***/ 9270:
201
+ /***/ 3449:
202
202
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
203
203
 
204
204
  "use strict";
@@ -225,14 +225,14 @@ Object.defineProperty(exports, "urlParser", ({
225
225
  return _postcssUrlParser.default;
226
226
  }
227
227
  }));
228
- var _postcssImportParser = _interopRequireDefault(__nccwpck_require__(2442));
229
- var _postcssIcssParser = _interopRequireDefault(__nccwpck_require__(1927));
230
- var _postcssUrlParser = _interopRequireDefault(__nccwpck_require__(1950));
228
+ var _postcssImportParser = _interopRequireDefault(__nccwpck_require__(9142));
229
+ var _postcssIcssParser = _interopRequireDefault(__nccwpck_require__(1734));
230
+ var _postcssUrlParser = _interopRequireDefault(__nccwpck_require__(188));
231
231
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
232
232
 
233
233
  /***/ }),
234
234
 
235
- /***/ 1927:
235
+ /***/ 1734:
236
236
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
237
237
 
238
238
  "use strict";
@@ -243,7 +243,7 @@ Object.defineProperty(exports, "__esModule", ({
243
243
  }));
244
244
  exports["default"] = void 0;
245
245
  var _icssUtils = __nccwpck_require__(3275);
246
- var _utils = __nccwpck_require__(256);
246
+ var _utils = __nccwpck_require__(1525);
247
247
  const plugin = (options = {}) => {
248
248
  return {
249
249
  postcssPlugin: "postcss-icss-parser",
@@ -352,7 +352,7 @@ var _default = exports["default"] = plugin;
352
352
 
353
353
  /***/ }),
354
354
 
355
- /***/ 2442:
355
+ /***/ 9142:
356
356
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
357
357
 
358
358
  "use strict";
@@ -363,7 +363,7 @@ Object.defineProperty(exports, "__esModule", ({
363
363
  }));
364
364
  exports["default"] = void 0;
365
365
  var _postcssValueParser = _interopRequireDefault(__nccwpck_require__(1036));
366
- var _utils = __nccwpck_require__(256);
366
+ var _utils = __nccwpck_require__(1525);
367
367
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
368
368
  function isIgnoredAfterName(atRule) {
369
369
  if (atRule.raws && atRule.raws.afterName && atRule.raws.afterName.trim().length > 0) {
@@ -652,7 +652,7 @@ var _default = exports["default"] = plugin;
652
652
 
653
653
  /***/ }),
654
654
 
655
- /***/ 1950:
655
+ /***/ 188:
656
656
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
657
657
 
658
658
  "use strict";
@@ -663,7 +663,7 @@ Object.defineProperty(exports, "__esModule", ({
663
663
  }));
664
664
  exports["default"] = void 0;
665
665
  var _postcssValueParser = _interopRequireDefault(__nccwpck_require__(1036));
666
- var _utils = __nccwpck_require__(256);
666
+ var _utils = __nccwpck_require__(1525);
667
667
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
668
668
  const isUrlFunc = /url/i;
669
669
  const isImageSetFunc = /^(?:-webkit-)?image-set$/i;
@@ -1015,7 +1015,7 @@ var _default = exports["default"] = plugin;
1015
1015
 
1016
1016
  /***/ }),
1017
1017
 
1018
- /***/ 256:
1018
+ /***/ 1525:
1019
1019
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
1020
1020
 
1021
1021
  "use strict";
@@ -7318,7 +7318,7 @@ module.exports = require("util");
7318
7318
 
7319
7319
  /***/ }),
7320
7320
 
7321
- /***/ 8962:
7321
+ /***/ 7361:
7322
7322
  /***/ ((module) => {
7323
7323
 
7324
7324
  "use strict";
@@ -7376,7 +7376,7 @@ module.exports = JSON.parse('{"name":"postcss","version":"8.4.38","description":
7376
7376
  /******/ // startup
7377
7377
  /******/ // Load entry module and return exports
7378
7378
  /******/ // This entry module is referenced by other modules so it can't be inlined
7379
- /******/ var __webpack_exports__ = __nccwpck_require__(4458);
7379
+ /******/ var __webpack_exports__ = __nccwpck_require__(7685);
7380
7380
  /******/ module.exports = __webpack_exports__;
7381
7381
  /******/
7382
7382
  /******/ })()
@@ -7709,17 +7709,17 @@ module.exports.createColors = createColors
7709
7709
 
7710
7710
  /***/ }),
7711
7711
 
7712
- /***/ 1595:
7712
+ /***/ 2094:
7713
7713
  /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
7714
7714
 
7715
7715
  "use strict";
7716
7716
 
7717
7717
 
7718
- module.exports = __nccwpck_require__(920)["default"];
7718
+ module.exports = __nccwpck_require__(6799)["default"];
7719
7719
 
7720
7720
  /***/ }),
7721
7721
 
7722
- /***/ 920:
7722
+ /***/ 6799:
7723
7723
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
7724
7724
 
7725
7725
  "use strict";
@@ -7732,8 +7732,8 @@ __webpack_unused_export__ = ({
7732
7732
  exports["default"] = loader;
7733
7733
  var _path = _interopRequireDefault(__nccwpck_require__(1017));
7734
7734
  var _package = _interopRequireDefault(__nccwpck_require__(5446));
7735
- var _options = _interopRequireDefault(__nccwpck_require__(9489));
7736
- var _utils = __nccwpck_require__(1949);
7735
+ var _options = _interopRequireDefault(__nccwpck_require__(4004));
7736
+ var _utils = __nccwpck_require__(2636);
7737
7737
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
7738
7738
  let hasExplicitDependencyOnPostCSS = false;
7739
7739
 
@@ -7899,7 +7899,7 @@ async function loader(content, sourceMap, meta) {
7899
7899
 
7900
7900
  /***/ }),
7901
7901
 
7902
- /***/ 1949:
7902
+ /***/ 2636:
7903
7903
  /***/ ((module, exports, __nccwpck_require__) => {
7904
7904
 
7905
7905
  "use strict";
@@ -9150,7 +9150,7 @@ function highlight(code, options = {}) {
9150
9150
 
9151
9151
  /***/ }),
9152
9152
 
9153
- /***/ 9489:
9153
+ /***/ 4004:
9154
9154
  /***/ ((module) => {
9155
9155
 
9156
9156
  "use strict";
@@ -9278,7 +9278,7 @@ module.exports = JSON.parse('{"name":"postcss","version":"8.4.38","description":
9278
9278
  /******/ // startup
9279
9279
  /******/ // Load entry module and return exports
9280
9280
  /******/ // This entry module used 'module' so it can't be inlined
9281
- /******/ var __webpack_exports__ = __nccwpck_require__(1595);
9281
+ /******/ var __webpack_exports__ = __nccwpck_require__(2094);
9282
9282
  /******/ module.exports = __webpack_exports__;
9283
9283
  /******/
9284
9284
  /******/ })()
@@ -1,7 +1,7 @@
1
1
  /******/ (() => { // webpackBootstrap
2
2
  /******/ var __webpack_modules__ = ({
3
3
 
4
- /***/ 8280:
4
+ /***/ 7903:
5
5
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
6
6
 
7
7
  "use strict";
@@ -105,7 +105,7 @@ exports.transformFiles = transformFiles;
105
105
 
106
106
  /***/ }),
107
107
 
108
- /***/ 4134:
108
+ /***/ 5836:
109
109
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
110
110
 
111
111
  "use strict";
@@ -116,7 +116,7 @@ const fs_1 = __nccwpck_require__(7147);
116
116
  const path_1 = __nccwpck_require__(1017);
117
117
  const tapable_1 = __nccwpck_require__(4260);
118
118
  const webpack_sources_1 = __nccwpck_require__(5433);
119
- const helpers_1 = __nccwpck_require__(8280);
119
+ const helpers_1 = __nccwpck_require__(7903);
120
120
  const compilerHookMap = new WeakMap();
121
121
  const getCompilerHooks = (compiler) => {
122
122
  let hooks = compilerHookMap.get(compiler);
@@ -7751,7 +7751,7 @@ var exports = __webpack_exports__;
7751
7751
  Object.defineProperty(exports, "__esModule", ({ value: true }));
7752
7752
  exports.RspackManifestPlugin = exports.WebpackManifestPlugin = exports.getCompilerHooks = void 0;
7753
7753
  const path_1 = __nccwpck_require__(1017);
7754
- const hooks_1 = __nccwpck_require__(4134);
7754
+ const hooks_1 = __nccwpck_require__(5836);
7755
7755
  Object.defineProperty(exports, "getCompilerHooks", ({ enumerable: true, get: function () { return hooks_1.getCompilerHooks; } }));
7756
7756
  const emitCountMap = new Map();
7757
7757
  const defaults = {
package/dist/index.cjs CHANGED
@@ -1003,7 +1003,7 @@ async function createContextByConfig(options, bundlerType, config = {}) {
1003
1003
  return {
1004
1004
  entry: getEntryObject(config, "web"),
1005
1005
  targets: config.output?.targets || [],
1006
- version: "0.7.4",
1006
+ version: "0.7.5",
1007
1007
  rootPath,
1008
1008
  distPath,
1009
1009
  cachePath,
@@ -5078,7 +5078,7 @@ async function getDefaultSwcConfig(config, rootPath, target) {
5078
5078
  }
5079
5079
  };
5080
5080
  }
5081
- async function applyCoreJs(swcConfig, chain, polyfillMode) {
5081
+ async function applyCoreJs(swcConfig, polyfillMode) {
5082
5082
  const coreJsPath = require.resolve("core-js/package.json");
5083
5083
  const version2 = (0, import_shared42.getCoreJsVersion)(coreJsPath);
5084
5084
  const coreJsDir = import_node_path23.default.dirname(coreJsPath);
@@ -5086,9 +5086,7 @@ async function applyCoreJs(swcConfig, chain, polyfillMode) {
5086
5086
  if (polyfillMode === "usage") {
5087
5087
  swcConfig.env.shippedProposals = true;
5088
5088
  }
5089
- chain.resolve.alias.merge({
5090
- "core-js": coreJsDir
5091
- });
5089
+ return coreJsDir;
5092
5090
  }
5093
5091
  function applyTransformImport(swcConfig, pluginImport) {
5094
5092
  if (pluginImport !== false && pluginImport) {
@@ -5134,6 +5132,9 @@ var init_swc = __esm({
5134
5132
  handler: async (chain, { CHAIN_ID: CHAIN_ID3, target }) => {
5135
5133
  const config = api.getNormalizedConfig();
5136
5134
  const rule = chain.module.rule(CHAIN_ID3.RULE.JS).test(import_shared42.SCRIPT_REGEX).type("javascript/auto");
5135
+ const dataUriRule = chain.module.rule(CHAIN_ID3.RULE.JS_DATA_URI).mimetype({
5136
+ or: ["text/javascript", "application/javascript"]
5137
+ });
5137
5138
  (0, import_shared42.applyScriptCondition)({
5138
5139
  rule,
5139
5140
  chain,
@@ -5161,7 +5162,10 @@ var init_swc = __esm({
5161
5162
  swcConfig.env.mode = void 0;
5162
5163
  } else {
5163
5164
  swcConfig.env.mode = polyfillMode;
5164
- await applyCoreJs(swcConfig, chain, polyfillMode);
5165
+ const coreJsDir = await applyCoreJs(swcConfig, polyfillMode);
5166
+ for (const item of [rule, dataUriRule]) {
5167
+ item.resolve.alias.set("core-js", coreJsDir);
5168
+ }
5165
5169
  }
5166
5170
  }
5167
5171
  const mergedSwcConfig = (0, import_shared42.reduceConfigs)({
@@ -5170,9 +5174,7 @@ var init_swc = __esm({
5170
5174
  mergeFn: import_shared42.deepmerge
5171
5175
  });
5172
5176
  rule.use(CHAIN_ID3.USE.SWC).loader(builtinSwcLoaderName).options(mergedSwcConfig);
5173
- chain.module.rule(CHAIN_ID3.RULE.JS_DATA_URI).mimetype({
5174
- or: ["text/javascript", "application/javascript"]
5175
- }).resolve.set("fullySpecified", false).end().use(CHAIN_ID3.USE.SWC).loader(builtinSwcLoaderName).options((0, import_shared42.cloneDeep)(mergedSwcConfig));
5177
+ dataUriRule.resolve.set("fullySpecified", false).end().use(CHAIN_ID3.USE.SWC).loader(builtinSwcLoaderName).options((0, import_shared42.cloneDeep)(mergedSwcConfig));
5176
5178
  }
5177
5179
  });
5178
5180
  }
@@ -5478,25 +5480,24 @@ function pluginOpen() {
5478
5480
  const onStartServer = async (params) => {
5479
5481
  const { port, routes } = params;
5480
5482
  const config = api.getNormalizedConfig();
5481
- const { beforeStartUrl } = config.dev;
5482
- const open = config.server.open || config.dev.startUrl;
5483
5483
  const { https } = api.context.devServer || {};
5484
+ const { targets, before } = normalizeOpenConfig(config);
5484
5485
  const isCodesandbox = process.env.CSB === "true";
5485
- const shouldOpen = Boolean(open) && !isCodesandbox;
5486
+ const shouldOpen = targets !== void 0 && !isCodesandbox;
5486
5487
  if (!shouldOpen) {
5487
5488
  return;
5488
5489
  }
5489
5490
  const urls = [];
5490
5491
  const protocol = https ? "https" : "http";
5491
5492
  const baseUrl = `${protocol}://localhost:${port}`;
5492
- if (open === true || !open) {
5493
+ if (!targets.length) {
5493
5494
  if (routes.length) {
5494
5495
  urls.push(`${baseUrl}${routes[0].pathname}`);
5495
5496
  }
5496
5497
  } else {
5497
5498
  urls.push(
5498
- ...(0, import_shared44.castArray)(open).map(
5499
- (item) => resolveUrl(replacePlaceholder(item, port), baseUrl)
5499
+ ...targets.map(
5500
+ (target) => resolveUrl(replacePlaceholder(target, port), baseUrl)
5500
5501
  )
5501
5502
  );
5502
5503
  }
@@ -5508,20 +5509,17 @@ function pluginOpen() {
5508
5509
  }
5509
5510
  }
5510
5511
  };
5511
- if (beforeStartUrl) {
5512
- Promise.all((0, import_shared44.castArray)(beforeStartUrl).map((fn) => fn())).then(
5513
- openUrls
5514
- );
5515
- } else {
5516
- openUrls();
5512
+ if (before) {
5513
+ await before();
5517
5514
  }
5515
+ openUrls();
5518
5516
  };
5519
5517
  api.onAfterStartDevServer(onStartServer);
5520
5518
  api.onAfterStartProdServer(onStartServer);
5521
5519
  }
5522
5520
  };
5523
5521
  }
5524
- var import_node_child_process, import_node_util, import_shared44, execAsync, supportedChromiumBrowsers, getTargetBrowser, replacePlaceholder, openedURLs;
5522
+ var import_node_child_process, import_node_util, import_shared44, execAsync, supportedChromiumBrowsers, getTargetBrowser, replacePlaceholder, openedURLs, normalizeOpenConfig;
5525
5523
  var init_open = __esm({
5526
5524
  "src/plugins/open.ts"() {
5527
5525
  "use strict";
@@ -5550,6 +5548,26 @@ var init_open = __esm({
5550
5548
  };
5551
5549
  replacePlaceholder = (url2, port) => url2.replace(/<port>/g, String(port));
5552
5550
  openedURLs = [];
5551
+ normalizeOpenConfig = (config) => {
5552
+ const open = config.server.open || config.dev.startUrl;
5553
+ const { beforeStartUrl } = config.dev;
5554
+ if (open === false) {
5555
+ return {};
5556
+ }
5557
+ if (open === true) {
5558
+ return { targets: [], before: beforeStartUrl };
5559
+ }
5560
+ if (typeof open === "string") {
5561
+ return { targets: [open], before: beforeStartUrl };
5562
+ }
5563
+ if (Array.isArray(open)) {
5564
+ return { targets: open, before: beforeStartUrl };
5565
+ }
5566
+ return {
5567
+ targets: open.target ? (0, import_shared44.castArray)(open.target) : [],
5568
+ before: open.before
5569
+ };
5570
+ };
5553
5571
  }
5554
5572
  });
5555
5573
 
@@ -7206,7 +7224,7 @@ var applyServerOptions = (command) => {
7206
7224
  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");
7207
7225
  };
7208
7226
  function runCli() {
7209
- import_commander.program.name("rsbuild").usage("<command> [options]").version("0.7.4");
7227
+ import_commander.program.name("rsbuild").usage("<command> [options]").version("0.7.5");
7210
7228
  const devCommand = import_commander.program.command("dev");
7211
7229
  const buildCommand = import_commander.program.command("build");
7212
7230
  const previewCommand = import_commander.program.command("preview");
@@ -7296,7 +7314,7 @@ function prepareCli() {
7296
7314
  if (!npm_execpath || npm_execpath.includes("npx-cli.js") || npm_execpath.includes(".bun")) {
7297
7315
  console.log();
7298
7316
  }
7299
- import_shared61.logger.greet(` ${`Rsbuild v${"0.7.4"}`}
7317
+ import_shared61.logger.greet(` ${`Rsbuild v${"0.7.5"}`}
7300
7318
  `);
7301
7319
  }
7302
7320
 
@@ -7323,7 +7341,7 @@ init_config();
7323
7341
  var import_shared62 = require("@rsbuild/shared");
7324
7342
  init_mergeConfig();
7325
7343
  init_constants();
7326
- var version = "0.7.4";
7344
+ var version = "0.7.5";
7327
7345
  // Annotate the CommonJS export names for ESM import in node:
7328
7346
  0 && (module.exports = {
7329
7347
  PLUGIN_CSS_NAME,
package/dist/index.js CHANGED
@@ -1042,7 +1042,7 @@ async function createContextByConfig(options, bundlerType, config = {}) {
1042
1042
  return {
1043
1043
  entry: getEntryObject(config, "web"),
1044
1044
  targets: config.output?.targets || [],
1045
- version: "0.7.4",
1045
+ version: "0.7.5",
1046
1046
  rootPath,
1047
1047
  distPath,
1048
1048
  cachePath,
@@ -5249,7 +5249,7 @@ async function getDefaultSwcConfig(config, rootPath, target) {
5249
5249
  }
5250
5250
  };
5251
5251
  }
5252
- async function applyCoreJs(swcConfig, chain, polyfillMode) {
5252
+ async function applyCoreJs(swcConfig, polyfillMode) {
5253
5253
  const coreJsPath = __require.resolve("core-js/package.json");
5254
5254
  const version2 = getCoreJsVersion(coreJsPath);
5255
5255
  const coreJsDir = path11.dirname(coreJsPath);
@@ -5257,9 +5257,7 @@ async function applyCoreJs(swcConfig, chain, polyfillMode) {
5257
5257
  if (polyfillMode === "usage") {
5258
5258
  swcConfig.env.shippedProposals = true;
5259
5259
  }
5260
- chain.resolve.alias.merge({
5261
- "core-js": coreJsDir
5262
- });
5260
+ return coreJsDir;
5263
5261
  }
5264
5262
  function applyTransformImport(swcConfig, pluginImport) {
5265
5263
  if (pluginImport !== false && pluginImport) {
@@ -5304,6 +5302,9 @@ var init_swc = __esm({
5304
5302
  handler: async (chain, { CHAIN_ID: CHAIN_ID3, target }) => {
5305
5303
  const config = api.getNormalizedConfig();
5306
5304
  const rule = chain.module.rule(CHAIN_ID3.RULE.JS).test(SCRIPT_REGEX).type("javascript/auto");
5305
+ const dataUriRule = chain.module.rule(CHAIN_ID3.RULE.JS_DATA_URI).mimetype({
5306
+ or: ["text/javascript", "application/javascript"]
5307
+ });
5307
5308
  applyScriptCondition({
5308
5309
  rule,
5309
5310
  chain,
@@ -5331,7 +5332,10 @@ var init_swc = __esm({
5331
5332
  swcConfig.env.mode = void 0;
5332
5333
  } else {
5333
5334
  swcConfig.env.mode = polyfillMode;
5334
- await applyCoreJs(swcConfig, chain, polyfillMode);
5335
+ const coreJsDir = await applyCoreJs(swcConfig, polyfillMode);
5336
+ for (const item of [rule, dataUriRule]) {
5337
+ item.resolve.alias.set("core-js", coreJsDir);
5338
+ }
5335
5339
  }
5336
5340
  }
5337
5341
  const mergedSwcConfig = reduceConfigs2({
@@ -5340,9 +5344,7 @@ var init_swc = __esm({
5340
5344
  mergeFn: deepmerge5
5341
5345
  });
5342
5346
  rule.use(CHAIN_ID3.USE.SWC).loader(builtinSwcLoaderName).options(mergedSwcConfig);
5343
- chain.module.rule(CHAIN_ID3.RULE.JS_DATA_URI).mimetype({
5344
- or: ["text/javascript", "application/javascript"]
5345
- }).resolve.set("fullySpecified", false).end().use(CHAIN_ID3.USE.SWC).loader(builtinSwcLoaderName).options(cloneDeep(mergedSwcConfig));
5347
+ dataUriRule.resolve.set("fullySpecified", false).end().use(CHAIN_ID3.USE.SWC).loader(builtinSwcLoaderName).options(cloneDeep(mergedSwcConfig));
5346
5348
  }
5347
5349
  });
5348
5350
  }
@@ -5661,25 +5663,24 @@ function pluginOpen() {
5661
5663
  const onStartServer = async (params) => {
5662
5664
  const { port, routes } = params;
5663
5665
  const config = api.getNormalizedConfig();
5664
- const { beforeStartUrl } = config.dev;
5665
- const open = config.server.open || config.dev.startUrl;
5666
5666
  const { https } = api.context.devServer || {};
5667
+ const { targets, before } = normalizeOpenConfig(config);
5667
5668
  const isCodesandbox = process.env.CSB === "true";
5668
- const shouldOpen = Boolean(open) && !isCodesandbox;
5669
+ const shouldOpen = targets !== void 0 && !isCodesandbox;
5669
5670
  if (!shouldOpen) {
5670
5671
  return;
5671
5672
  }
5672
5673
  const urls = [];
5673
5674
  const protocol = https ? "https" : "http";
5674
5675
  const baseUrl = `${protocol}://localhost:${port}`;
5675
- if (open === true || !open) {
5676
+ if (!targets.length) {
5676
5677
  if (routes.length) {
5677
5678
  urls.push(`${baseUrl}${routes[0].pathname}`);
5678
5679
  }
5679
5680
  } else {
5680
5681
  urls.push(
5681
- ...castArray6(open).map(
5682
- (item) => resolveUrl(replacePlaceholder(item, port), baseUrl)
5682
+ ...targets.map(
5683
+ (target) => resolveUrl(replacePlaceholder(target, port), baseUrl)
5683
5684
  )
5684
5685
  );
5685
5686
  }
@@ -5691,20 +5692,17 @@ function pluginOpen() {
5691
5692
  }
5692
5693
  }
5693
5694
  };
5694
- if (beforeStartUrl) {
5695
- Promise.all(castArray6(beforeStartUrl).map((fn) => fn())).then(
5696
- openUrls
5697
- );
5698
- } else {
5699
- openUrls();
5695
+ if (before) {
5696
+ await before();
5700
5697
  }
5698
+ openUrls();
5701
5699
  };
5702
5700
  api.onAfterStartDevServer(onStartServer);
5703
5701
  api.onAfterStartProdServer(onStartServer);
5704
5702
  }
5705
5703
  };
5706
5704
  }
5707
- var execAsync, supportedChromiumBrowsers, getTargetBrowser, replacePlaceholder, openedURLs;
5705
+ var execAsync, supportedChromiumBrowsers, getTargetBrowser, replacePlaceholder, openedURLs, normalizeOpenConfig;
5708
5706
  var init_open = __esm({
5709
5707
  "src/plugins/open.ts"() {
5710
5708
  "use strict";
@@ -5731,6 +5729,26 @@ var init_open = __esm({
5731
5729
  };
5732
5730
  replacePlaceholder = (url2, port) => url2.replace(/<port>/g, String(port));
5733
5731
  openedURLs = [];
5732
+ normalizeOpenConfig = (config) => {
5733
+ const open = config.server.open || config.dev.startUrl;
5734
+ const { beforeStartUrl } = config.dev;
5735
+ if (open === false) {
5736
+ return {};
5737
+ }
5738
+ if (open === true) {
5739
+ return { targets: [], before: beforeStartUrl };
5740
+ }
5741
+ if (typeof open === "string") {
5742
+ return { targets: [open], before: beforeStartUrl };
5743
+ }
5744
+ if (Array.isArray(open)) {
5745
+ return { targets: open, before: beforeStartUrl };
5746
+ }
5747
+ return {
5748
+ targets: open.target ? castArray6(open.target) : [],
5749
+ before: open.before
5750
+ };
5751
+ };
5734
5752
  }
5735
5753
  });
5736
5754
 
@@ -7416,7 +7434,7 @@ var applyServerOptions = (command) => {
7416
7434
  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");
7417
7435
  };
7418
7436
  function runCli() {
7419
- program.name("rsbuild").usage("<command> [options]").version("0.7.4");
7437
+ program.name("rsbuild").usage("<command> [options]").version("0.7.5");
7420
7438
  const devCommand = program.command("dev");
7421
7439
  const buildCommand = program.command("build");
7422
7440
  const previewCommand = program.command("preview");
@@ -7507,7 +7525,7 @@ function prepareCli() {
7507
7525
  if (!npm_execpath || npm_execpath.includes("npx-cli.js") || npm_execpath.includes(".bun")) {
7508
7526
  console.log();
7509
7527
  }
7510
- logger19.greet(` ${`Rsbuild v${"0.7.4"}`}
7528
+ logger19.greet(` ${`Rsbuild v${"0.7.5"}`}
7511
7529
  `);
7512
7530
  }
7513
7531
 
@@ -7535,7 +7553,7 @@ init_config();
7535
7553
  init_mergeConfig();
7536
7554
  init_constants();
7537
7555
  import { logger as logger20 } from "@rsbuild/shared";
7538
- var version = "0.7.4";
7556
+ var version = "0.7.5";
7539
7557
  export {
7540
7558
  PLUGIN_CSS_NAME,
7541
7559
  PLUGIN_SWC_NAME,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsbuild/core",
3
- "version": "0.7.4",
3
+ "version": "0.7.5",
4
4
  "description": "The Rspack-based build tool.",
5
5
  "homepage": "https://rsbuild.dev",
6
6
  "bugs": {
@@ -46,12 +46,12 @@
46
46
  "types.d.ts"
47
47
  ],
48
48
  "dependencies": {
49
- "@rspack/core": "0.7.1",
49
+ "@rspack/core": "0.7.2",
50
50
  "@swc/helpers": "0.5.3",
51
51
  "core-js": "~3.36.0",
52
52
  "html-webpack-plugin": "npm:html-rspack-plugin@5.7.2",
53
53
  "postcss": "^8.4.38",
54
- "@rsbuild/shared": "0.7.4"
54
+ "@rsbuild/shared": "0.7.5"
55
55
  },
56
56
  "devDependencies": {
57
57
  "@types/connect": "3.4.38",