@rsbuild/core 1.0.8 → 1.0.9

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
@@ -46,12 +46,12 @@ var __publicField = (obj, key, value) => {
46
46
  return value;
47
47
  };
48
48
 
49
- // ../../node_modules/.pnpm/@modern-js+module-tools@2.60.1_typescript@5.5.2/node_modules/@modern-js/module-tools/shims/esm.js
49
+ // ../../node_modules/.pnpm/@modern-js+module-tools@2.60.2_typescript@5.5.2/node_modules/@modern-js/module-tools/shims/esm.js
50
50
  import path from "path";
51
51
  import { fileURLToPath } from "url";
52
52
  var getFilename, getDirname, __dirname, __filename;
53
53
  var init_esm = __esm({
54
- "../../node_modules/.pnpm/@modern-js+module-tools@2.60.1_typescript@5.5.2/node_modules/@modern-js/module-tools/shims/esm.js"() {
54
+ "../../node_modules/.pnpm/@modern-js+module-tools@2.60.2_typescript@5.5.2/node_modules/@modern-js/module-tools/shims/esm.js"() {
55
55
  "use strict";
56
56
  getFilename = () => fileURLToPath(import.meta.url);
57
57
  getDirname = () => path.dirname(getFilename());
@@ -4553,7 +4553,7 @@ var require_main = __commonJS({
4553
4553
  var packageJson = require_package();
4554
4554
  var version2 = packageJson.version;
4555
4555
  var LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;
4556
- function parse4(src) {
4556
+ function parse3(src) {
4557
4557
  const obj = {};
4558
4558
  let lines = src.toString();
4559
4559
  lines = lines.replace(/\r\n?/mg, "\n");
@@ -4796,7 +4796,7 @@ var require_main = __commonJS({
4796
4796
  _parseVault,
4797
4797
  config,
4798
4798
  decrypt,
4799
- parse: parse4,
4799
+ parse: parse3,
4800
4800
  populate
4801
4801
  };
4802
4802
  module.exports.configDotenv = DotenvModule.configDotenv;
@@ -4946,7 +4946,7 @@ var init_loadEnv = __esm({
4946
4946
  }
4947
4947
  });
4948
4948
 
4949
- // ../../node_modules/.pnpm/browserslist-load-config@0.0.2/node_modules/browserslist-load-config/dist/index.js
4949
+ // ../../node_modules/.pnpm/browserslist-load-config@0.1.1/node_modules/browserslist-load-config/dist/index.js
4950
4950
  import fs4 from "fs";
4951
4951
  import path4 from "path";
4952
4952
  function isFile(file) {
@@ -4979,9 +4979,12 @@ function parsePackage(file) {
4979
4979
  );
4980
4980
  }
4981
4981
  let list = config.browserslist;
4982
- if (Array.isArray(list) || typeof list === "string") {
4982
+ if (Array.isArray(list)) {
4983
4983
  list = { defaults: list };
4984
4984
  }
4985
+ if (typeof list === "string") {
4986
+ list = parseConfig(list);
4987
+ }
4985
4988
  for (const i in list) {
4986
4989
  check(list[i]);
4987
4990
  }
@@ -5126,7 +5129,7 @@ function loadConfig2(opts) {
5126
5129
  }
5127
5130
  var BrowserslistError, isFileCache, IS_SECTION, configCache;
5128
5131
  var init_dist = __esm({
5129
- "../../node_modules/.pnpm/browserslist-load-config@0.0.2/node_modules/browserslist-load-config/dist/index.js"() {
5132
+ "../../node_modules/.pnpm/browserslist-load-config@0.1.1/node_modules/browserslist-load-config/dist/index.js"() {
5130
5133
  "use strict";
5131
5134
  init_esm();
5132
5135
  BrowserslistError = class _BrowserslistError extends Error {
@@ -6028,7 +6031,7 @@ async function createContext(options, userConfig, bundlerType) {
6028
6031
  const rsbuildConfig = await withDefaultConfig(rootPath, userConfig);
6029
6032
  const cachePath = join6(rootPath, "node_modules", ".cache");
6030
6033
  return {
6031
- version: "1.0.8",
6034
+ version: "1.0.9",
6032
6035
  rootPath,
6033
6036
  distPath: "",
6034
6037
  cachePath,
@@ -6859,7 +6862,7 @@ async function createCompiler(options) {
6859
6862
  };
6860
6863
  const hasErrors = stats.hasErrors();
6861
6864
  if (!hasErrors) {
6862
- if (statsJson.children && statsJson.children.length > 0) {
6865
+ if (rspackConfigs.length > 1 && statsJson.children?.length) {
6863
6866
  statsJson.children.forEach((c, index) => {
6864
6867
  printTime(c, index);
6865
6868
  });
@@ -7339,9 +7342,8 @@ var init_environment = __esm({
7339
7342
 
7340
7343
  // src/server/middlewares.ts
7341
7344
  import path8 from "path";
7342
- import { parse as parse2 } from "url";
7343
7345
  import color9 from "../compiled/picocolors/index.js";
7344
- var faviconFallbackMiddleware, getStatusCodeColor, getRequestLoggerMiddleware, notFoundMiddleware, isFileExists2, maybeHTMLRequest, getHtmlCompletionMiddleware, getHtmlFallbackMiddleware;
7346
+ var faviconFallbackMiddleware, getStatusCodeColor, getRequestLoggerMiddleware, notFoundMiddleware, isFileExists2, maybeHTMLRequest, postfixRE, getUrlPathname, getHtmlCompletionMiddleware, getHtmlFallbackMiddleware;
7345
7347
  var init_middlewares = __esm({
7346
7348
  "src/server/middlewares.ts"() {
7347
7349
  "use strict";
@@ -7411,21 +7413,17 @@ var init_middlewares = __esm({
7411
7413
  const { accept } = req.headers;
7412
7414
  return typeof accept === "string" && (accept.includes("text/html") || accept.includes("*/*"));
7413
7415
  };
7416
+ postfixRE = /[?#].*$/;
7417
+ getUrlPathname = (url2) => {
7418
+ return url2.replace(postfixRE, "");
7419
+ };
7414
7420
  getHtmlCompletionMiddleware = ({ distPath, callback, outputFileSystem }) => {
7415
7421
  return async (req, res, next) => {
7416
7422
  if (!maybeHTMLRequest(req)) {
7417
7423
  return next();
7418
7424
  }
7419
7425
  const url2 = req.url;
7420
- let pathname;
7421
- try {
7422
- pathname = parse2(url2, false, true).pathname;
7423
- } catch (err) {
7424
- logger.error(
7425
- new Error(`Invalid URL: ${color9.yellow(url2)}`, { cause: err })
7426
- );
7427
- return next();
7428
- }
7426
+ const pathname = getUrlPathname(url2);
7429
7427
  const rewrite = (newUrl) => {
7430
7428
  req.url = newUrl;
7431
7429
  return callback(req, res, (...args) => {
@@ -7823,7 +7821,7 @@ import color10 from "../compiled/picocolors/index.js";
7823
7821
  function getURLMessages(urls, routes) {
7824
7822
  if (routes.length === 1) {
7825
7823
  return urls.map(
7826
- ({ label, url: url2 }) => ` ${`> ${label.padEnd(10)}`}${color10.cyan(
7824
+ ({ label, url: url2 }) => ` ${`➜ ${label.padEnd(10)}`}${color10.cyan(
7827
7825
  normalizeUrl(`${url2}${routes[0].pathname}`)
7828
7826
  )}
7829
7827
  `
@@ -7835,7 +7833,7 @@ function getURLMessages(urls, routes) {
7835
7833
  if (index > 0) {
7836
7834
  message += "\n";
7837
7835
  }
7838
- message += ` ${`> ${label}`}
7836
+ message += ` ${`➜ ${label}`}
7839
7837
  `;
7840
7838
  for (const r of routes) {
7841
7839
  message += ` ${color10.dim("-")} ${color10.dim(
@@ -7960,8 +7958,7 @@ var init_helper = __esm({
7960
7958
  host,
7961
7959
  port,
7962
7960
  strictPort,
7963
- tryLimits = 20,
7964
- silent = false
7961
+ tryLimits = 20
7965
7962
  }) => {
7966
7963
  if (typeof port === "string") {
7967
7964
  port = Number.parseInt(port, 10);
@@ -7997,28 +7994,27 @@ var init_helper = __esm({
7997
7994
  `Port "${original}" is occupied, please choose another one.`
7998
7995
  );
7999
7996
  }
8000
- if (!silent) {
8001
- logger.info(
8002
- `Port ${original} is in use, ${color10.yellow(`using port ${port}.`)}
8003
- `
8004
- );
8005
- }
8006
7997
  }
8007
7998
  return port;
8008
7999
  };
8009
8000
  getServerConfig = async ({
8010
- config,
8011
- getPortSilently
8001
+ config
8012
8002
  }) => {
8013
8003
  const host = config.server.host || DEFAULT_DEV_HOST;
8004
+ const originalPort = config.server.port || DEFAULT_PORT;
8014
8005
  const port = await getPort({
8015
8006
  host,
8016
- port: config.server.port || DEFAULT_PORT,
8017
- strictPort: config.server.strictPort || false,
8018
- silent: getPortSilently
8007
+ port: originalPort,
8008
+ strictPort: config.server.strictPort || false
8019
8009
  });
8020
8010
  const https = Boolean(config.server.https) || false;
8021
- return { port, host, https };
8011
+ const portTip = port !== originalPort ? `Port ${originalPort} is in use, ${color10.yellow(`using port ${port}.`)}` : void 0;
8012
+ return {
8013
+ port,
8014
+ host,
8015
+ https,
8016
+ portTip
8017
+ };
8022
8018
  };
8023
8019
  getIpv4Interfaces = () => {
8024
8020
  const interfaces = os.networkInterfaces();
@@ -8432,7 +8428,7 @@ var init_devMiddleware = __esm({
8432
8428
  });
8433
8429
 
8434
8430
  // src/server/socketServer.ts
8435
- import { parse as parse3 } from "querystring";
8431
+ import { parse as parse2 } from "querystring";
8436
8432
  function isEqualSet(a, b) {
8437
8433
  if (a.size !== b.size) {
8438
8434
  return false;
@@ -8498,7 +8494,7 @@ var init_socketServer = __esm({
8498
8494
  const queryStr = req.url ? req.url.split("?")[1] : "";
8499
8495
  this.onConnect(
8500
8496
  socket,
8501
- queryStr ? parse3(queryStr) : {}
8497
+ queryStr ? parse2(queryStr) : {}
8502
8498
  );
8503
8499
  });
8504
8500
  }
@@ -8778,9 +8774,8 @@ async function createDevServer(options, createCompiler2, config, {
8778
8774
  runCompile = true
8779
8775
  } = {}) {
8780
8776
  logger.debug("create dev server");
8781
- const { port, host, https } = await getServerConfig({
8782
- config,
8783
- getPortSilently
8777
+ const { port, host, https, portTip } = await getServerConfig({
8778
+ config
8784
8779
  });
8785
8780
  const devConfig = formatDevConfig(config.dev, port);
8786
8781
  const routes = getRoutes(options.context);
@@ -8837,6 +8832,9 @@ async function createDevServer(options, createCompiler2, config, {
8837
8832
  protocol,
8838
8833
  printUrls: config.server.printUrls
8839
8834
  });
8835
+ if (!getPortSilently && portTip) {
8836
+ logger.info(portTip);
8837
+ }
8840
8838
  };
8841
8839
  if (runCompile) {
8842
8840
  options.context.hooks.onBeforeCreateCompiler.tap(printUrls);
@@ -12463,6 +12461,9 @@ function pluginModuleFederation() {
12463
12461
  return {
12464
12462
  name: "rsbuild:module-federation",
12465
12463
  setup(api) {
12464
+ if (api.context.bundlerType === "webpack") {
12465
+ return;
12466
+ }
12466
12467
  api.modifyRsbuildConfig((config) => {
12467
12468
  const { moduleFederation } = config;
12468
12469
  if (!moduleFederation?.options) {
@@ -12920,9 +12921,8 @@ __export(prodServer_exports, {
12920
12921
  startProdServer: () => startProdServer
12921
12922
  });
12922
12923
  async function startProdServer(context, config, { getPortSilently } = {}) {
12923
- const { port, host, https } = await getServerConfig({
12924
- config,
12925
- getPortSilently
12924
+ const { port, host, https, portTip } = await getServerConfig({
12925
+ config
12926
12926
  });
12927
12927
  const { default: connect } = await import("../compiled/connect/index.js");
12928
12928
  const middlewares = connect();
@@ -12969,6 +12969,9 @@ async function startProdServer(context, config, { getPortSilently } = {}) {
12969
12969
  protocol,
12970
12970
  printUrls: serverConfig.printUrls
12971
12971
  });
12972
+ if (portTip && !getPortSilently) {
12973
+ logger.info(portTip);
12974
+ }
12972
12975
  const onClose = async () => {
12973
12976
  await Promise.all([server.close(), serverTerminator()]);
12974
12977
  };
@@ -13383,7 +13386,7 @@ var init_init = __esm({
13383
13386
  import { existsSync } from "fs";
13384
13387
  import color16 from "../compiled/picocolors/index.js";
13385
13388
  function runCli() {
13386
- program.name("rsbuild").usage("<command> [options]").version("1.0.8");
13389
+ program.name("rsbuild").usage("<command> [options]").version("1.0.9");
13387
13390
  const devCommand = program.command("dev");
13388
13391
  const buildCommand = program.command("build");
13389
13392
  const previewCommand = program.command("preview");
@@ -13505,7 +13508,7 @@ function prepareCli() {
13505
13508
  if (!npm_execpath || npm_execpath.includes("npx-cli.js") || npm_execpath.includes(".bun")) {
13506
13509
  console.log();
13507
13510
  }
13508
- logger.greet(` ${`Rsbuild v${"1.0.8"}`}
13511
+ logger.greet(` ${`Rsbuild v${"1.0.9"}`}
13509
13512
  `);
13510
13513
  }
13511
13514
  var init_prepare = __esm({
@@ -13576,7 +13579,7 @@ init_mergeConfig();
13576
13579
  init_helpers();
13577
13580
  init_constants();
13578
13581
  import { rspack as rspack10 } from "@rspack/core";
13579
- var version = "1.0.8";
13582
+ var version = "1.0.9";
13580
13583
  export {
13581
13584
  PLUGIN_CSS_NAME,
13582
13585
  PLUGIN_SWC_NAME,
@@ -33,20 +33,19 @@ export declare function printServerURLs({ urls: originalUrls, port, routes, prot
33
33
  * @param strictPort - Whether to throw an error when the port is occupied.
34
34
  * @returns Available port number.
35
35
  */
36
- export declare const getPort: ({ host, port, strictPort, tryLimits, silent, }: {
36
+ export declare const getPort: ({ host, port, strictPort, tryLimits, }: {
37
37
  host: string;
38
38
  port: string | number;
39
39
  strictPort: boolean;
40
40
  tryLimits?: number;
41
- silent?: boolean;
42
41
  }) => Promise<number>;
43
- export declare const getServerConfig: ({ config, getPortSilently, }: {
42
+ export declare const getServerConfig: ({ config, }: {
44
43
  config: NormalizedConfig;
45
- getPortSilently?: boolean;
46
44
  }) => Promise<{
47
45
  port: number;
48
46
  host: string;
49
47
  https: boolean;
48
+ portTip: string | undefined;
50
49
  }>;
51
50
  type AddressUrl = {
52
51
  label: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsbuild/core",
3
- "version": "1.0.8",
3
+ "version": "1.0.9",
4
4
  "description": "The Rspack-based build tool.",
5
5
  "homepage": "https://rsbuild.dev",
6
6
  "bugs": {
@@ -46,8 +46,8 @@
46
46
  "types.d.ts"
47
47
  ],
48
48
  "dependencies": {
49
- "@rspack/core": "~1.0.7",
50
- "@rspack/lite-tapable": "~1.0.0",
49
+ "@rspack/core": "~1.0.8",
50
+ "@rspack/lite-tapable": "~1.0.1",
51
51
  "@swc/helpers": "^0.5.13",
52
52
  "core-js": "~3.38.1"
53
53
  },
@@ -58,7 +58,7 @@
58
58
  "@types/on-finished": "2.3.4",
59
59
  "@types/webpack-bundle-analyzer": "4.7.0",
60
60
  "@types/ws": "^8.5.12",
61
- "browserslist-load-config": "0.0.2",
61
+ "browserslist-load-config": "0.1.1",
62
62
  "chokidar": "3.6.0",
63
63
  "commander": "^12.1.0",
64
64
  "connect": "3.7.0",
@@ -83,7 +83,7 @@
83
83
  "reduce-configs": "^1.0.0",
84
84
  "rsbuild-dev-middleware": "0.1.1",
85
85
  "rslog": "^1.2.3",
86
- "rspack-chain": "^1.0.1",
86
+ "rspack-chain": "^1.0.3",
87
87
  "rspack-manifest-plugin": "5.0.1",
88
88
  "sirv": "^2.0.4",
89
89
  "style-loader": "3.3.4",