@rsbuild/core 2.0.0 → 2.0.1

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.
@@ -10,7 +10,6 @@ import { HttpBindings } from '@hono/node-server';
10
10
  // @ts-ignore
11
11
  import { MiddlewareHandler } from 'hono';
12
12
 
13
- //#region src/types.d.ts
14
13
  interface ProxyTargetDetailed {
15
14
  host?: string;
16
15
  port?: number | string;
@@ -88,15 +87,11 @@ interface ProxyServerOptions {
88
87
  /** Buffer */
89
88
  buffer?: stream.Stream;
90
89
  }
91
- //#endregion
92
- //#region src/middleware/_utils.d.ts
93
90
  type ResOfType<T extends "web" | "ws"> = T extends "ws" ? T extends "web" ? ServerResponse | Http2ServerResponse | Socket : Socket : T extends "web" ? ServerResponse | Http2ServerResponse : never;
94
91
  type ProxyMiddleware<T extends ServerResponse | Http2ServerResponse | Socket> = (req: IncomingMessage | Http2ServerRequest, res: T, opts: ProxyServerOptions & {
95
92
  target: URL | ProxyTargetDetailed;
96
93
  forward: URL;
97
94
  }, server: ProxyServer<IncomingMessage | Http2ServerRequest, ServerResponse | Http2ServerResponse>, head?: Buffer, callback?: (err: any, req: IncomingMessage | Http2ServerRequest, socket: T, url?: any) => void) => void | true;
98
- //#endregion
99
- //#region src/server.d.ts
100
95
  interface ProxyServerEventMap<Req extends http__default.IncomingMessage | http2.Http2ServerRequest = http__default.IncomingMessage, Res extends http__default.ServerResponse | http2.Http2ServerResponse = http__default.ServerResponse> {
101
96
  error: [err: Error, req?: Req, res?: Res | net__default.Socket, target?: URL | ProxyTarget];
102
97
  start: [req: Req, res: Res, target: URL | ProxyTarget];
@@ -126,8 +121,9 @@ declare class ProxyServer<Req extends http__default.IncomingMessage | http2.Http
126
121
  * A function that wraps the object in a webserver, for your convenience
127
122
  * @param port - Port to listen on
128
123
  * @param hostname - The hostname to listen on
124
+ * @param listeningListener - A callback function that is called when the server starts listening
129
125
  */
130
- listen(port: number, hostname?: string): this;
126
+ listen(port: number, hostname?: string, listeningListener?: () => void): this;
131
127
  /**
132
128
  * A function that closes the inner webserver and stops listening on given port
133
129
  */
@@ -164,6 +160,9 @@ interface OnProxyEvent<TReq extends http.IncomingMessage = http.IncomingMessage,
164
160
  econnreset?: (err: Error, req: TReq, res: TRes, target: string | Partial<URL>) => void;
165
161
  }
166
162
  type Logger = Pick<Console, 'info' | 'warn' | 'error'>;
163
+ type PathRewriteConfig<TReq extends http.IncomingMessage = http.IncomingMessage> = {
164
+ [regexp: string]: string;
165
+ } | ((path: string, req: TReq) => string | undefined) | ((path: string, req: TReq) => Promise<string>);
167
166
  interface Options<TReq extends http.IncomingMessage = http.IncomingMessage, TRes extends http.ServerResponse = http.ServerResponse> extends ProxyServerOptions {
168
167
  /**
169
168
  * Narrow down requests to proxy or not.
@@ -185,9 +184,7 @@ interface Options<TReq extends http.IncomingMessage = http.IncomingMessage, TRes
185
184
  * ```
186
185
  * @link https://github.com/chimurai/http-proxy-middleware/blob/master/recipes/pathRewrite.md
187
186
  */
188
- pathRewrite?: {
189
- [regexp: string]: string;
190
- } | ((path: string, req: TReq) => string | undefined) | ((path: string, req: TReq) => Promise<string>);
187
+ pathRewrite?: PathRewriteConfig<TReq>;
191
188
  /**
192
189
  * Access the internal http-proxy server instance to customize behavior
193
190
  *
@@ -242,9 +239,7 @@ interface Options<TReq extends http.IncomingMessage = http.IncomingMessage, TRes
242
239
  * ```
243
240
  * @link https://github.com/chimurai/http-proxy-middleware/blob/master/recipes/router.md
244
241
  */
245
- router?: {
246
- [hostOrPath: string]: ProxyServerOptions['target'];
247
- } | ((req: TReq) => ProxyServerOptions['target']) | ((req: TReq) => Promise<ProxyServerOptions['target']>);
242
+ router?: Record<string, ProxyServerOptions['target']> | ((req: TReq) => ProxyServerOptions['target']) | ((req: TReq) => Promise<ProxyServerOptions['target']>);
248
243
  /**
249
244
  * Log information from http-proxy-middleware
250
245
  * @example
@@ -1 +1 @@
1
- {"name":"http-proxy-middleware","author":"Steven Chim","version":"4.0.0-beta.3","license":"MIT","types":"index.d.ts","type":"module"}
1
+ {"name":"http-proxy-middleware","author":"Steven Chim","version":"4.0.0-beta.4","license":"MIT","types":"index.d.ts","type":"module"}
package/dist/753.js CHANGED
@@ -3467,7 +3467,7 @@ function createPublicContext(context) {
3467
3467
  async function createContext(options, userConfig, logger) {
3468
3468
  let { cwd } = options, rootPath = userConfig.root ? ensureAbsolutePath(cwd, userConfig.root) : cwd, rsbuildConfig = await withDefaultConfig(rootPath, userConfig), cachePath = join(rootPath, 'node_modules', '.cache'), specifiedEnvironments = options.environment && options.environment.length > 0 ? options.environment : void 0;
3469
3469
  return {
3470
- version: "2.0.0",
3470
+ version: "2.0.1",
3471
3471
  rootPath,
3472
3472
  distPath: '',
3473
3473
  cachePath,
@@ -4956,7 +4956,12 @@ function getInlineTests(config) {
4956
4956
  styleTests
4957
4957
  };
4958
4958
  }
4959
- let normalizeUrl = (url)=>url.replace(/([^:]\/)\/+/g, '$1'), joinUrlSegments = (s1, s2)=>s1 && s2 ? addTrailingSlash(s1) + s2.replace(/^\/+/, '') : s1 || s2 || '', stripBase = (path, base)=>{
4959
+ let normalizeUrl = (url)=>url.replace(/([^:]\/)\/+/g, '$1'), formatPrefix = (input)=>{
4960
+ let prefix = input;
4961
+ if (prefix?.startsWith('./') && (prefix = prefix.replace('./', '')), !prefix) return '/';
4962
+ let hasLeadingSlash = prefix.startsWith('/'), hasTailSlash = prefix.endsWith('/');
4963
+ return `${hasLeadingSlash ? '' : '/'}${prefix}${hasTailSlash ? '' : '/'}`;
4964
+ }, joinUrlSegments = (s1, s2)=>s1 && s2 ? addTrailingSlash(s1) + s2.replace(/^\/+/, '') : s1 || s2 || '', stripBase = (path, base)=>{
4960
4965
  if (path === base) return '/';
4961
4966
  let trailingSlashBase = addTrailingSlash(base);
4962
4967
  return path.startsWith(trailingSlashBase) ? path.slice(trailingSlashBase.length - 1) : path;
@@ -4969,12 +4974,7 @@ let normalizeUrl = (url)=>url.replace(/([^:]\/)\/+/g, '$1'), joinUrlSegments = (
4969
4974
  return prev.concat(...routes);
4970
4975
  }, []);
4971
4976
  }, formatRoutes = (entry, base, distPathPrefix, outputStructure)=>{
4972
- let prefix = joinUrlSegments(base, ((input)=>{
4973
- let prefix = input;
4974
- if (prefix?.startsWith('./') && (prefix = prefix.replace('./', '')), !prefix) return '/';
4975
- let hasLeadingSlash = prefix.startsWith('/'), hasTailSlash = prefix.endsWith('/');
4976
- return `${hasLeadingSlash ? '' : '/'}${prefix}${hasTailSlash ? '' : '/'}`;
4977
- })(distPathPrefix));
4977
+ let prefix = joinUrlSegments(base, formatPrefix(distPathPrefix));
4978
4978
  return Object.keys(entry).map((entryName)=>({
4979
4979
  entryName,
4980
4980
  pathname: prefix + ('index' === entryName && 'nested' !== outputStructure ? '' : entryName)
@@ -4993,7 +4993,7 @@ function getURLMessages(urls, routes) {
4993
4993
  for (let { entryName, pathname } of (prevLabel !== label && (index > 0 && (message += '\n'), message += ` ➜ ${label}\n`, prevLabel = label), routes))message += ` ${color.dim('-')} ${color.dim(entryName.padEnd(maxNameLength + 4))}${color.cyan(normalizeUrl(`${url}${pathname}`))}\n`;
4994
4994
  }), message;
4995
4995
  }
4996
- function printServerURLs({ urls: originalUrls, port, routes, protocol, printUrls, trailingLineBreak = !0, originalConfig, logger }) {
4996
+ function printServerURLs({ urls: originalUrls, port, routes, protocol, printUrls, fallbackPathname, trailingLineBreak = !0, originalConfig, logger }) {
4997
4997
  if (!1 === printUrls) return null;
4998
4998
  let urls = originalUrls, useCustomUrl = isFunction(printUrls);
4999
4999
  if (useCustomUrl) {
@@ -5015,8 +5015,15 @@ function printServerURLs({ urls: originalUrls, port, routes, protocol, printUrls
5015
5015
  };
5016
5016
  });
5017
5017
  }
5018
- if (0 === urls.length || 0 === routes.length && !useCustomUrl) return null;
5019
- let message = getURLMessages(urls, routes);
5018
+ if (0 === urls.length) return null;
5019
+ let printableRoutes = 0 !== routes.length || useCustomUrl || void 0 === fallbackPathname ? routes : [
5020
+ {
5021
+ entryName: 'index',
5022
+ pathname: formatPrefix(fallbackPathname)
5023
+ }
5024
+ ];
5025
+ if (0 === printableRoutes.length && !useCustomUrl) return null;
5026
+ let message = getURLMessages(urls, printableRoutes);
5020
5027
  return originalConfig && originalConfig.server?.host === void 0 && (message += ` ➜ ${color.dim('Network:')} ${color.dim('use')} ${color.bold('--host')} ${color.dim('to expose')}\n`), !trailingLineBreak && message.endsWith('\n') && (message = message.slice(0, -1)), logger.log(message), message;
5021
5028
  }
5022
5029
  let getPort = async ({ host, port, strictPort, tryLimits = 20 })=>{
@@ -6637,7 +6644,7 @@ function gzipMiddleware_gzipMiddleware({ filter, level = node_zlib.constants.Z_B
6637
6644
  write(chunk) || gzip.pause();
6638
6645
  }), on('drain', ()=>gzip.resume()), gzip.on('end', ()=>{
6639
6646
  end();
6640
- }), listeners))gzip.on.apply(gzip, listener);
6647
+ }), listeners))gzip.on(...listener);
6641
6648
  else for (let listener of listeners)on.apply(res, listener);
6642
6649
  let statusCode = writeHeadStatus ?? res.statusCode;
6643
6650
  void 0 !== writeHeadMessage ? writeHead(statusCode, writeHeadMessage) : writeHead(statusCode);
@@ -7307,7 +7314,7 @@ async function startWatchFiles({ paths, options, type = 'reload-page' }, buildMa
7307
7314
  async function devServer_createDevServer(options, createCompiler, config, { getPortSilently, runCompile = !0 } = {}) {
7308
7315
  let lastStats, { context } = options, { logger } = context;
7309
7316
  logger.debug('create dev server');
7310
- let { port, portTip } = await resolvePort(config), { middlewareMode, host } = config.server, isHttps = !!config.server.https, routes = getRoutes(context);
7317
+ let { port, portTip } = await resolvePort(config), { middlewareMode, host } = config.server, isHttps = !!config.server.https, routes = getRoutes(context), fallbackPathname = 0 === routes.length && context.environmentList.some((item)=>'web' === item.config.output.target) ? config.server.base : void 0;
7311
7318
  context.devServer = {
7312
7319
  hostname: host,
7313
7320
  port,
@@ -7349,6 +7356,7 @@ async function devServer_createDevServer(options, createCompiler, config, { getP
7349
7356
  routes,
7350
7357
  protocol,
7351
7358
  printUrls: config.server.printUrls,
7359
+ fallbackPathname,
7352
7360
  trailingLineBreak: !cliShortcutsEnabled,
7353
7361
  originalConfig: context.originalConfig,
7354
7362
  logger
@@ -9186,7 +9194,7 @@ let applyServerOptions = (command)=>{
9186
9194
  };
9187
9195
  function setupCommands() {
9188
9196
  let cli = ((name = "")=>new CAC(name))('rsbuild');
9189
- cli.version("2.0.0"), cli.option('--base <base>', 'Set the base path of the server').option('-c, --config <config>', 'Set the configuration file (relative or absolute path)').option('--config-loader <loader>', 'Set the config file loader (auto | jiti | native)', {
9197
+ cli.version("2.0.1"), cli.option('--base <base>', 'Set the base path of the server').option('-c, --config <config>', 'Set the configuration file (relative or absolute path)').option('--config-loader <loader>', 'Set the config file loader (auto | jiti | native)', {
9190
9198
  default: 'auto'
9191
9199
  }).option('--env-dir <dir>', 'Set the directory for loading `.env` files').option('--env-mode <mode>', 'Set the env mode to load the `.env.[mode]` file').option('--environment <name>', 'Set the environment name(s) to build', {
9192
9200
  type: [
@@ -9263,7 +9271,7 @@ function initNodeEnv() {
9263
9271
  }
9264
9272
  function showGreeting() {
9265
9273
  let { npm_execpath, npm_lifecycle_event, NODE_RUN_SCRIPT_NAME } = process.env, isBun = npm_execpath?.includes('.bun');
9266
- src_logger.greet(`${'npx' === npm_lifecycle_event || isBun || NODE_RUN_SCRIPT_NAME ? '\n' : ''}Rsbuild v2.0.0\n`);
9274
+ src_logger.greet(`${'npx' === npm_lifecycle_event || isBun || NODE_RUN_SCRIPT_NAME ? '\n' : ''}Rsbuild v2.0.1\n`);
9267
9275
  }
9268
9276
  function setupLogLevel() {
9269
9277
  let logLevelIndex = process.argv.findIndex((item)=>'--log-level' === item || '--logLevel' === item);
@@ -9284,5 +9292,5 @@ function runCLI() {
9284
9292
  src_logger.error('Failed to start Rsbuild CLI.'), src_logger.error(err), process.exit(1);
9285
9293
  }
9286
9294
  }
9287
- let src_version = "2.0.0";
9295
+ let src_version = "2.0.1";
9288
9296
  export { PLUGIN_CSS_NAME, PLUGIN_SWC_NAME, core_rspack as rspack, createRsbuild, defaultAllowedOrigins, defineConfig, ensureAssetPrefix, loadConfig_loadConfig as loadConfig, loadEnv, logger_createLogger as createLogger, mergeRsbuildConfig, runCLI, src_logger as logger, src_version as version };
@@ -2226,7 +2226,7 @@ function setupOutgoing(outgoing, options, req, forward) {
2226
2226
  }, req.headers?.[":authority"] && (outgoing.headers.host = req.headers[":authority"]), options.headers) for (let key of Object.keys(options.headers))outgoing.headers[key] = options.headers[key];
2227
2227
  if (req.httpVersionMajor > 1) for (let header of HTTP2_HEADER_BLACKLIST)delete outgoing.headers[header];
2228
2228
  if (options.auth && (outgoing.auth = options.auth), options.ca && (outgoing.ca = options.ca), isSSL.test(options[forward || "target"].protocol ?? "http") && (outgoing.rejectUnauthorized = void 0 === options.secure || options.secure), void 0 !== options.agent) outgoing.agent = options.agent || !1;
2229
- else if (req.httpVersionMajor > 1) outgoing.agent = !1;
2229
+ else if (req.httpVersionMajor > 1 || upgradeHeader.test(req.headers.connection || "")) outgoing.agent = !1;
2230
2230
  else {
2231
2231
  let targetProto = options[forward || "target"].protocol ?? "http";
2232
2232
  outgoing.agent = isSSL.test(targetProto) ? defaultAgents.https : defaultAgents.http;
@@ -2363,7 +2363,7 @@ let redirectStatuses = new Set([
2363
2363
  "proto"
2364
2364
  ]){
2365
2365
  let key = "x-forwarded-" + header;
2366
- req.headers[key] || (req.headers[key] = values[header]);
2366
+ req.headers[key] || void 0 === values[header] || (req.headers[key] = values[header]);
2367
2367
  }
2368
2368
  req.headers["x-forwarded-host"] = req.headers["x-forwarded-host"] || req.headers[":authority"] || req.headers.host || "";
2369
2369
  },
@@ -2463,7 +2463,7 @@ let redirectStatuses = new Set([
2463
2463
  "proto"
2464
2464
  ]){
2465
2465
  let key = "x-forwarded-" + header;
2466
- req.headers[key] || (req.headers[key] = values[header]);
2466
+ req.headers[key] || void 0 === values[header] || (req.headers[key] = values[header]);
2467
2467
  }
2468
2468
  },
2469
2469
  (req, socket, options, server, head, callback)=>{
@@ -2510,7 +2510,7 @@ var ERRORS, errors_ERRORS, ProxyServer = class extends EventEmitter {
2510
2510
  constructor(options = {}){
2511
2511
  super(), this.options = options || {}, this.options.prependPath = !1 !== options.prependPath, this.web = _createProxyFn("web", this), this.ws = _createProxyFn("ws", this);
2512
2512
  }
2513
- listen(port, hostname) {
2513
+ listen(port, hostname, listeningListener) {
2514
2514
  let closure = (req, res)=>this.web(req, res);
2515
2515
  if (this.options.http2) {
2516
2516
  if (!this.options.ssl) throw Error("HTTP/2 requires ssl option");
@@ -2521,7 +2521,7 @@ var ERRORS, errors_ERRORS, ProxyServer = class extends EventEmitter {
2521
2521
  } else this.options.ssl ? this._server = node_https.createServer(this.options.ssl, closure) : this._server = node_http.createServer(closure);
2522
2522
  return this.options.ws && this._server.on("upgrade", (req, socket, head)=>{
2523
2523
  this.ws(req, socket, this.options, head).catch(()=>{});
2524
- }), this._server.listen(port, hostname), this;
2524
+ }), this._server.listen(port, hostname, listeningListener), this;
2525
2525
  }
2526
2526
  close(callback) {
2527
2527
  this._server && this._server.close((...args)=>{
@@ -2793,7 +2793,7 @@ async function getTarget(req, config) {
2793
2793
  return isPlainObject(router) ? newTarget = getTargetFromProxyTable(req, router) : 'function' == typeof router && (newTarget = await router(req)), newTarget;
2794
2794
  }
2795
2795
  function getTargetFromProxyTable(req, table) {
2796
- let result, host = req.headers.host, hostAndPath = host + req.url;
2796
+ let result, host = req.headers.host ?? '', hostAndPath = host + (req.url ?? '');
2797
2797
  for (let [key, value] of Object.entries(table))if (containsPath(key)) {
2798
2798
  if (hostAndPath.indexOf(key) > -1) {
2799
2799
  router_debug('match: "%s" -> "%s"', key, result = value);
@@ -2808,6 +2808,29 @@ function getTargetFromProxyTable(req, table) {
2808
2808
  function containsPath(v) {
2809
2809
  return v.indexOf('/') > -1;
2810
2810
  }
2811
+ let ipv6_debug = Debug.extend('ipv6');
2812
+ function normalizeIPv6LiteralTargets(options) {
2813
+ options.target = normalizeIPv6ProxyTarget(options.target, 'target'), options.forward = normalizeIPv6ProxyTarget(options.forward, 'forward');
2814
+ }
2815
+ function normalizeIPv6ProxyTarget(target, optionName) {
2816
+ let targetUrl = toTargetUrl(target);
2817
+ return targetUrl && isBracketedIPv6Hostname(targetUrl.hostname) ? (ipv6_debug('normalized IPv6 "%s" %s', optionName, target), {
2818
+ hostname: stripBrackets(targetUrl.hostname),
2819
+ pathname: targetUrl.pathname,
2820
+ port: targetUrl.port,
2821
+ protocol: targetUrl.protocol,
2822
+ search: targetUrl.search
2823
+ }) : target;
2824
+ }
2825
+ function toTargetUrl(target) {
2826
+ return 'string' == typeof target ? new URL(target) : target instanceof URL ? target : void 0;
2827
+ }
2828
+ function isBracketedIPv6Hostname(hostname) {
2829
+ return hostname.startsWith('[') && hostname.endsWith(']');
2830
+ }
2831
+ function stripBrackets(hostname) {
2832
+ return hostname.replace(/^\[|\]$/g, '');
2833
+ }
2811
2834
  class HttpProxyMiddleware {
2812
2835
  wsInternalSubscribed = !1;
2813
2836
  serverOnCloseSubscribed = !1;
@@ -2869,7 +2892,7 @@ class HttpProxyMiddleware {
2869
2892
  };
2870
2893
  prepareProxyRequest = async (req)=>{
2871
2894
  let newProxyOptions = Object.assign({}, this.proxyOptions);
2872
- return await this.applyRouter(req, newProxyOptions), await this.applyPathRewrite(req, this.pathRewriter), newProxyOptions;
2895
+ return await this.applyRouter(req, newProxyOptions), normalizeIPv6LiteralTargets(newProxyOptions), await this.applyPathRewrite(req, this.pathRewriter), newProxyOptions;
2873
2896
  };
2874
2897
  applyRouter = async (req, options)=>{
2875
2898
  let newTarget;
@@ -1,6 +1,6 @@
1
1
  import type { RsbuildInstance } from '../types';
2
2
  import type { CommonOptions } from './commands';
3
- export declare function init({ cliOptions, isRestart, isBuildWatch, }: {
3
+ export declare function init({ cliOptions, isRestart, isBuildWatch }: {
4
4
  cliOptions?: CommonOptions;
5
5
  isRestart?: boolean;
6
6
  isBuildWatch?: boolean;
@@ -5,129 +5,129 @@ export declare const CHAIN_ID: {
5
5
  /** Predefined rules */
6
6
  readonly RULE: {
7
7
  /** Rule for .mjs */
8
- readonly MJS: "mjs";
8
+ readonly MJS: 'mjs';
9
9
  /** Rule for fonts */
10
- readonly FONT: "font";
10
+ readonly FONT: 'font';
11
11
  /** Rule for JSON */
12
- readonly JSON: "json";
12
+ readonly JSON: 'json';
13
13
  /** Rule for images */
14
- readonly IMAGE: "image";
14
+ readonly IMAGE: 'image';
15
15
  /** Rule for media */
16
- readonly MEDIA: "media";
16
+ readonly MEDIA: 'media';
17
17
  /** Rule for additional assets */
18
- readonly ADDITIONAL_ASSETS: "additional-assets";
18
+ readonly ADDITIONAL_ASSETS: 'additional-assets';
19
19
  /** Rule for JS */
20
- readonly JS: "js";
20
+ readonly JS: 'js';
21
21
  /** Rule for data uri encoded javascript */
22
- readonly JS_DATA_URI: "js-data-uri";
22
+ readonly JS_DATA_URI: 'js-data-uri';
23
23
  /** Rule for CSS */
24
- readonly CSS: "css";
24
+ readonly CSS: 'css';
25
25
  /** Rule for Less */
26
- readonly LESS: "less";
26
+ readonly LESS: 'less';
27
27
  /** Rule for Sass */
28
- readonly SASS: "sass";
28
+ readonly SASS: 'sass';
29
29
  /** Rule for stylus */
30
- readonly STYLUS: "stylus";
30
+ readonly STYLUS: 'stylus';
31
31
  /** Rule for svg */
32
- readonly SVG: "svg";
32
+ readonly SVG: 'svg';
33
33
  /** Rule for Vue */
34
- readonly VUE: "vue";
34
+ readonly VUE: 'vue';
35
35
  /** Rule for wasm */
36
- readonly WASM: "wasm";
36
+ readonly WASM: 'wasm';
37
37
  /** Rule for svelte */
38
- readonly SVELTE: "svelte";
38
+ readonly SVELTE: 'svelte';
39
39
  };
40
40
  /** Predefined rule groups */
41
41
  readonly ONE_OF: {
42
42
  /** JS oneOf rules */
43
- readonly JS_MAIN: "js";
44
- readonly JS_RAW: "js-raw";
43
+ readonly JS_MAIN: 'js';
44
+ readonly JS_RAW: 'js-raw';
45
45
  /** CSS oneOf rules */
46
- readonly CSS_MAIN: "css";
47
- readonly CSS_RAW: "css-raw";
48
- readonly CSS_INLINE: "css-inline";
46
+ readonly CSS_MAIN: 'css';
47
+ readonly CSS_RAW: 'css-raw';
48
+ readonly CSS_INLINE: 'css-inline';
49
49
  /** SVG oneOf rules */
50
- readonly SVG: "svg";
51
- readonly SVG_RAW: "svg-asset-raw";
52
- readonly SVG_URL: "svg-asset-url";
53
- readonly SVG_ASSET: "svg-asset";
54
- readonly SVG_REACT: "svg-react";
55
- readonly SVG_INLINE: "svg-asset-inline";
50
+ readonly SVG: 'svg';
51
+ readonly SVG_RAW: 'svg-asset-raw';
52
+ readonly SVG_URL: 'svg-asset-url';
53
+ readonly SVG_ASSET: 'svg-asset';
54
+ readonly SVG_REACT: 'svg-react';
55
+ readonly SVG_INLINE: 'svg-asset-inline';
56
56
  };
57
57
  /** Predefined loaders */
58
58
  readonly USE: {
59
59
  /** ts-loader */
60
- readonly TS: "ts";
60
+ readonly TS: 'ts';
61
61
  /** css-loader */
62
- readonly CSS: "css";
62
+ readonly CSS: 'css';
63
63
  /** sass-loader */
64
- readonly SASS: "sass";
64
+ readonly SASS: 'sass';
65
65
  /** less-loader */
66
- readonly LESS: "less";
66
+ readonly LESS: 'less';
67
67
  /** stylus-loader */
68
- readonly STYLUS: "stylus";
68
+ readonly STYLUS: 'stylus';
69
69
  /** url-loader */
70
- readonly URL: "url";
70
+ readonly URL: 'url';
71
71
  /** vue-loader */
72
- readonly VUE: "vue";
72
+ readonly VUE: 'vue';
73
73
  /** swc-loader */
74
- readonly SWC: "swc";
74
+ readonly SWC: 'swc';
75
75
  /** svgr */
76
- readonly SVGR: "svgr";
76
+ readonly SVGR: 'svgr';
77
77
  /** babel-loader */
78
- readonly BABEL: "babel";
78
+ readonly BABEL: 'babel';
79
79
  /** style-loader */
80
- readonly STYLE: "style-loader";
80
+ readonly STYLE: 'style-loader';
81
81
  /** svelte-loader */
82
- readonly SVELTE: "svelte";
82
+ readonly SVELTE: 'svelte';
83
83
  /** postcss-loader */
84
- readonly POSTCSS: "postcss";
84
+ readonly POSTCSS: 'postcss';
85
85
  /** lightningcss-loader */
86
- readonly LIGHTNINGCSS: "lightningcss";
86
+ readonly LIGHTNINGCSS: 'lightningcss';
87
87
  /** ignore-css-loader */
88
- readonly IGNORE_CSS: "ignore-css";
88
+ readonly IGNORE_CSS: 'ignore-css';
89
89
  /** CssExtractRspackPlugin.loader */
90
- readonly MINI_CSS_EXTRACT: "mini-css-extract";
90
+ readonly MINI_CSS_EXTRACT: 'mini-css-extract';
91
91
  /** resolve-url-loader */
92
- readonly RESOLVE_URL: "resolve-url-loader";
92
+ readonly RESOLVE_URL: 'resolve-url-loader';
93
93
  };
94
94
  /** Predefined plugins */
95
95
  readonly PLUGIN: {
96
96
  /** HotModuleReplacementPlugin */
97
- readonly HMR: "hmr";
97
+ readonly HMR: 'hmr';
98
98
  /** CopyRspackPlugin */
99
- readonly COPY: "copy";
99
+ readonly COPY: 'copy';
100
100
  /** HtmlRspackPlugin */
101
- readonly HTML: "html";
101
+ readonly HTML: 'html';
102
102
  /** DefinePlugin */
103
- readonly DEFINE: "define";
103
+ readonly DEFINE: 'define';
104
104
  /** ProgressPlugin */
105
- readonly PROGRESS: "progress";
105
+ readonly PROGRESS: 'progress';
106
106
  /** RspackManifestPlugin */
107
- readonly MANIFEST: "rspack-manifest";
107
+ readonly MANIFEST: 'rspack-manifest';
108
108
  /** ForkTsCheckerWebpackPlugin */
109
- readonly TS_CHECKER: "ts-checker";
109
+ readonly TS_CHECKER: 'ts-checker';
110
110
  /** ModuleFederationPlugin */
111
- readonly MODULE_FEDERATION: "module-federation";
111
+ readonly MODULE_FEDERATION: 'module-federation';
112
112
  /** HtmlResourceHintsPlugin (prefetch) */
113
- readonly HTML_PREFETCH: "html-prefetch-plugin";
113
+ readonly HTML_PREFETCH: 'html-prefetch-plugin';
114
114
  /** HtmlResourceHintsPlugin (preload) */
115
- readonly HTML_PRELOAD: "html-preload-plugin";
115
+ readonly HTML_PRELOAD: 'html-preload-plugin';
116
116
  /** CssExtractRspackPlugin */
117
- readonly MINI_CSS_EXTRACT: "mini-css-extract";
117
+ readonly MINI_CSS_EXTRACT: 'mini-css-extract';
118
118
  /** VueLoaderPlugin */
119
- readonly VUE_LOADER_PLUGIN: "vue-loader-plugin";
119
+ readonly VUE_LOADER_PLUGIN: 'vue-loader-plugin';
120
120
  /** ReactFastRefreshPlugin */
121
- readonly REACT_FAST_REFRESH: "react-fast-refresh";
121
+ readonly REACT_FAST_REFRESH: 'react-fast-refresh';
122
122
  /** SubresourceIntegrityPlugin */
123
- readonly SUBRESOURCE_INTEGRITY: "subresource-integrity";
123
+ readonly SUBRESOURCE_INTEGRITY: 'subresource-integrity';
124
124
  };
125
125
  /** Predefined minimizers */
126
126
  readonly MINIMIZER: {
127
127
  /** SwcJsMinimizerRspackPlugin */
128
- readonly JS: "js";
128
+ readonly JS: 'js';
129
129
  /** LightningCssMinimizerRspackPlugin */
130
- readonly CSS: "css";
130
+ readonly CSS: 'css';
131
131
  };
132
132
  };
133
133
  export type ChainIdentifier = typeof CHAIN_ID;
@@ -1,3 +1,3 @@
1
1
  import type { StatsError } from '@rspack/core';
2
2
  import { type Logger } from '../logger';
3
- export declare function formatStatsError(stats: StatsError, root: string, level: "error" | "warning" | undefined, logger: Logger): string;
3
+ export declare function formatStatsError(stats: StatsError, root: string, level: ('error' | 'warning') | undefined, logger: Logger): string;
@@ -25,6 +25,6 @@ export declare const prettyTime: (seconds: number) => string;
25
25
  /**
26
26
  * Check if running in a TTY context
27
27
  */
28
- export declare const isTTY: (type?: "stdin" | "stdout") => boolean;
28
+ export declare const isTTY: (type?: 'stdin' | 'stdout') => boolean;
29
29
  export declare function hash(data: string): Promise<string>;
30
30
  export declare const isRspackRuntimeModule: (identifier: string) => boolean;
@@ -13,7 +13,7 @@ export type InitConfigsOptions = {
13
13
  * 5. Run all the `modifyEnvironmentConfig` hooks
14
14
  * 6. Validate the final Rsbuild config
15
15
  */
16
- export declare function initRsbuildConfig({ context, pluginManager, }: Pick<InitConfigsOptions, 'context' | 'pluginManager'>): Promise<NormalizedConfig>;
17
- export declare function initConfigs({ context, pluginManager, rsbuildOptions, }: InitConfigsOptions): Promise<{
16
+ export declare function initRsbuildConfig({ context, pluginManager }: Pick<InitConfigsOptions, 'context' | 'pluginManager'>): Promise<NormalizedConfig>;
17
+ export declare function initConfigs({ context, pluginManager, rsbuildOptions }: InitConfigsOptions): Promise<{
18
18
  rspackConfigs: Rspack.Configuration[];
19
19
  }>;
@@ -1,7 +1,7 @@
1
1
  import type { Logger } from './logger';
2
2
  import type { InternalContext, NormalizedEnvironmentConfig, PluginManager, RsbuildPluginAPI } from './types';
3
3
  export declare function getHTMLPathByEntry(entryName: string, config: NormalizedEnvironmentConfig, logger: Logger): string;
4
- export declare function initPluginAPI({ context, pluginManager, }: {
4
+ export declare function initPluginAPI({ context, pluginManager }: {
5
5
  context: InternalContext;
6
6
  pluginManager: PluginManager;
7
7
  }): (environment?: string) => RsbuildPluginAPI;
@@ -1,7 +1,7 @@
1
1
  import type { InitConfigsOptions } from './initConfigs';
2
2
  import type { InspectConfigOptions, InspectConfigResult, Rspack } from './types';
3
3
  export declare function stringifyConfig(config: unknown, verbose?: boolean): string;
4
- export declare function inspectConfig({ context, pluginManager, bundlerConfigs, inspectOptions, }: InitConfigsOptions & {
4
+ export declare function inspectConfig({ context, pluginManager, bundlerConfigs, inspectOptions }: InitConfigsOptions & {
5
5
  inspectOptions?: InspectConfigOptions;
6
6
  bundlerConfigs: Rspack.Configuration[];
7
7
  }): Promise<InspectConfigResult>;
@@ -57,4 +57,4 @@ export declare function defineConfig(config: RsbuildConfigSyncFn): RsbuildConfig
57
57
  export declare function defineConfig(config: RsbuildConfigAsyncFn): RsbuildConfigAsyncFn;
58
58
  export declare function defineConfig(config: RsbuildConfigExport): RsbuildConfigExport;
59
59
  export type ConfigLoader = 'auto' | 'jiti' | 'native';
60
- export declare function loadConfig({ cwd, path, envMode, meta, loader, }?: LoadConfigOptions): Promise<LoadConfigResult>;
60
+ export declare function loadConfig({ cwd, path, envMode, meta, loader }?: LoadConfigOptions): Promise<LoadConfigResult>;
@@ -60,4 +60,4 @@ export type LoadEnvResult = {
60
60
  */
61
61
  cleanup: () => void;
62
62
  };
63
- export declare function loadEnv({ cwd, mode, prefixes, processEnv, }?: LoadEnvOptions): LoadEnvResult;
63
+ export declare function loadEnv({ cwd, mode, prefixes, processEnv }?: LoadEnvOptions): LoadEnvResult;
@@ -19,7 +19,7 @@
19
19
  */
20
20
  import { createLogger as baseCreateLogger, type Logger, logger as defaultLogger } from '../compiled/rslog';
21
21
  export declare const isDebug: () => boolean;
22
- export declare const isVerbose: (targetLogger: Pick<Logger, "level">) => boolean;
22
+ export declare const isVerbose: (targetLogger: Pick<Logger, 'level'>) => boolean;
23
23
  export declare const createLogger: (...args: Parameters<typeof baseCreateLogger>) => ReturnType<typeof baseCreateLogger>;
24
24
  export { defaultLogger };
25
25
  export type { Logger };
@@ -16,7 +16,7 @@ export declare const sortPluginsByEnforce: (plugins: PluginMeta[]) => PluginMeta
16
16
  * execution order.
17
17
  */
18
18
  export declare const sortPluginsByDependencies: (plugins: PluginMeta[]) => PluginMeta[];
19
- export declare function initPlugins({ context, pluginManager, }: {
19
+ export declare function initPlugins({ context, pluginManager }: {
20
20
  context: InternalContext;
21
21
  pluginManager: PluginManager;
22
22
  }): Promise<void>;
@@ -11,7 +11,7 @@ export declare const restartDevServer: ({ filePath, clear, logger, }: {
11
11
  clear?: boolean;
12
12
  logger: Logger;
13
13
  }) => Promise<boolean>;
14
- export declare function watchFilesForRestart({ files, rsbuild, isBuildWatch, watchOptions, }: {
14
+ export declare function watchFilesForRestart({ files, rsbuild, isBuildWatch, watchOptions }: {
15
15
  files: string[];
16
16
  rsbuild: RsbuildInstance;
17
17
  isBuildWatch: boolean;
@@ -24,5 +24,5 @@ interface DoesChunkBelongToHtmlOptions {
24
24
  pluginOptions?: ResourceHintsOptions;
25
25
  }
26
26
  export declare function recursiveChunkEntryNames(chunk: Chunk): string[];
27
- export declare function doesChunkBelongToHtml({ chunk, htmlPluginData, }: DoesChunkBelongToHtmlOptions): boolean;
27
+ export declare function doesChunkBelongToHtml({ chunk, htmlPluginData }: DoesChunkBelongToHtmlOptions): boolean;
28
28
  export {};
@@ -16,7 +16,7 @@
16
16
  * limitations under the License.
17
17
  */
18
18
  export type ResourceType = 'audio' | 'document' | 'embed' | 'fetch' | 'font' | 'image' | 'object' | 'script' | 'style' | 'track' | 'worker' | 'video';
19
- export declare function getResourceType({ href, file, }: {
19
+ export declare function getResourceType({ href, file }: {
20
20
  href: string;
21
21
  file: string;
22
22
  }): ResourceType;
@@ -1,7 +1,7 @@
1
1
  import type { EnvironmentContext, InternalContext, ModifyChainUtils, ModifyRspackConfigUtils, RsbuildTarget, Rspack } from './types';
2
2
  export declare function getConfigUtils(getCurrentConfig: () => Rspack.Configuration, chainUtils: ModifyChainUtils): ModifyRspackConfigUtils;
3
3
  export declare function getChainUtils(target: RsbuildTarget, environment: EnvironmentContext, environments: Record<string, EnvironmentContext>): ModifyChainUtils;
4
- export declare function generateRspackConfig({ target, context, environmentName, }: {
4
+ export declare function generateRspackConfig({ target, context, environmentName }: {
5
5
  target: RsbuildTarget;
6
6
  context: InternalContext;
7
7
  environmentName: string;
@@ -2,7 +2,7 @@ import type { Logger } from '../logger';
2
2
  import type { CliShortcut, NormalizedConfig } from '../types/config';
3
3
  export declare const isCliShortcutsEnabled: (config: NormalizedConfig) => boolean;
4
4
  export declare const normalizeShortcutInput: (input: string) => string;
5
- export declare function setupCliShortcuts({ help, openPage, closeServer, printUrls, restartServer, customShortcuts, logger, }: {
5
+ export declare function setupCliShortcuts({ help, openPage, closeServer, printUrls, restartServer, customShortcuts, logger }: {
6
6
  help?: boolean | string;
7
7
  openPage: () => Promise<void>;
8
8
  closeServer: () => Promise<void>;
@@ -1,2 +1,2 @@
1
1
  import type { CompressOptions, RequestHandler } from '../types';
2
- export declare function gzipMiddleware({ filter, level, }?: CompressOptions): RequestHandler;
2
+ export declare function gzipMiddleware({ filter, level }?: CompressOptions): RequestHandler;
@@ -30,7 +30,7 @@ export declare const joinUrlSegments: (s1: string, s2: string) => string;
30
30
  export declare const stripBase: (path: string, base: string) => string;
31
31
  export declare const getRoutes: (context: InternalContext) => Routes;
32
32
  export declare const formatRoutes: (entry: RsbuildEntry, base: string, distPathPrefix: string | undefined, outputStructure: OutputStructure | undefined) => Routes;
33
- export declare function printServerURLs({ urls: originalUrls, port, routes, protocol, printUrls, trailingLineBreak, originalConfig, logger, }: {
33
+ export declare function printServerURLs({ urls: originalUrls, port, routes, protocol, printUrls, fallbackPathname, trailingLineBreak, originalConfig, logger }: {
34
34
  urls: {
35
35
  url: string;
36
36
  label: string;
@@ -39,6 +39,7 @@ export declare function printServerURLs({ urls: originalUrls, port, routes, prot
39
39
  routes: Routes;
40
40
  protocol: string;
41
41
  printUrls?: PrintUrls;
42
+ fallbackPathname?: string;
42
43
  trailingLineBreak?: boolean;
43
44
  originalConfig?: Readonly<RsbuildConfig>;
44
45
  logger: Logger;
@@ -2,7 +2,7 @@ import type { Logger } from '../logger';
2
2
  import type { NormalizedConfig, Routes } from '../types';
3
3
  export declare const replacePortPlaceholder: (url: string, port: number) => string;
4
4
  export declare function resolveUrl(str: string, base: string): string;
5
- export declare function open({ port, routes, config, protocol, clearCache, logger, }: {
5
+ export declare function open({ port, routes, config, protocol, clearCache, logger }: {
6
6
  port: number;
7
7
  routes: Routes;
8
8
  config: NormalizedConfig;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsbuild/core",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "description": "The Rspack-based build tool.",
5
5
  "homepage": "https://rsbuild.rs",
6
6
  "bugs": {
@@ -50,7 +50,7 @@
50
50
  "devDependencies": {
51
51
  "@jridgewell/remapping": "^2.3.5",
52
52
  "@jridgewell/trace-mapping": "^0.3.31",
53
- "@rslib/core": "0.21.2",
53
+ "@rslib/core": "0.21.3",
54
54
  "@types/cors": "^2.8.19",
55
55
  "@types/node": "^24.12.2",
56
56
  "@types/on-finished": "2.3.5",
@@ -65,7 +65,7 @@
65
65
  "deepmerge": "^4.3.1",
66
66
  "dotenv-expand": "13.0.0",
67
67
  "html-rspack-plugin": "6.1.8",
68
- "http-proxy-middleware": "4.0.0-beta.3",
68
+ "http-proxy-middleware": "4.0.0-beta.4",
69
69
  "jiti": "^2.6.1",
70
70
  "launch-editor-middleware": "^2.13.2",
71
71
  "memfs": "^4.57.2",