@rsbuild/core 2.0.0-rc.4 → 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.
Files changed (33) hide show
  1. package/compiled/css-loader/index.js +2 -2
  2. package/compiled/html-rspack-plugin/index.js +14 -14
  3. package/compiled/http-proxy-middleware/index.d.ts +7 -12
  4. package/compiled/http-proxy-middleware/package.json +1 -1
  5. package/compiled/postcss/index.js +1 -1
  6. package/compiled/postcss/package.json +1 -1
  7. package/compiled/postcss-loader/index.js +6 -6
  8. package/dist/753.js +41 -118
  9. package/dist/http-proxy-middleware.js +30 -7
  10. package/dist/launch-editor-middleware.js +1 -1
  11. package/dist/manifest-plugin.js +6 -6
  12. package/dist/memfs.js +96 -96
  13. package/dist-types/cli/init.d.ts +1 -1
  14. package/dist-types/configChain.d.ts +60 -60
  15. package/dist-types/helpers/format.d.ts +1 -1
  16. package/dist-types/helpers/index.d.ts +1 -1
  17. package/dist-types/helpers/version.d.ts +1 -1
  18. package/dist-types/initConfigs.d.ts +2 -2
  19. package/dist-types/initPlugins.d.ts +1 -1
  20. package/dist-types/inspectConfig.d.ts +1 -1
  21. package/dist-types/loadConfig.d.ts +1 -1
  22. package/dist-types/loadEnv.d.ts +1 -1
  23. package/dist-types/logger.d.ts +1 -1
  24. package/dist-types/pluginManager.d.ts +1 -1
  25. package/dist-types/restart.d.ts +1 -1
  26. package/dist-types/rspack-plugins/resource-hints/doesChunkBelongToHtml.d.ts +1 -1
  27. package/dist-types/rspack-plugins/resource-hints/getResourceType.d.ts +1 -1
  28. package/dist-types/rspackConfig.d.ts +1 -1
  29. package/dist-types/server/cliShortcuts.d.ts +1 -1
  30. package/dist-types/server/gzipMiddleware.d.ts +1 -1
  31. package/dist-types/server/helper.d.ts +2 -1
  32. package/dist-types/server/open.d.ts +1 -1
  33. package/package.json +8 -8
package/dist/753.js CHANGED
@@ -83,7 +83,7 @@ __webpack_require__.add({
83
83
  }, {});
84
84
  }, module.exports = deepmerge;
85
85
  },
86
- "../../node_modules/.pnpm/dotenv-expand@12.0.3/node_modules/dotenv-expand/lib/main.js" (module) {
86
+ "../../node_modules/.pnpm/dotenv-expand@13.0.0/node_modules/dotenv-expand/lib/main.js" (module) {
87
87
  function _resolveEscapeSequences(value) {
88
88
  return value.replace(/\\\$/g, '$');
89
89
  }
@@ -113,7 +113,7 @@ __webpack_require__.add({
113
113
  for(let processKey in options.parsed)processEnv[processKey] = options.parsed[processKey];
114
114
  return options;
115
115
  }
116
- module.exports.expand = expand;
116
+ module.exports.f = expand;
117
117
  },
118
118
  "../../node_modules/.pnpm/ee-first@1.1.1/node_modules/ee-first/index.js" (module) {
119
119
  function listener(event, done) {
@@ -181,9 +181,7 @@ __webpack_require__.add({
181
181
  '.json': __rspack_createRequire_require,
182
182
  '.cjs': __rspack_createRequire_require,
183
183
  noExt: jsonLoader
184
- });
185
- module.exports.defaultLoadersSync = defaultLoadersSync;
186
- let dynamicImport = async (id)=>{
184
+ }), dynamicImport = async (id)=>{
187
185
  try {
188
186
  let fileUrl = url.pathToFileURL(id).href;
189
187
  return (await import(fileUrl)).default;
@@ -234,10 +232,8 @@ __webpack_require__.add({
234
232
  if (!loader) throw Error(`No loader specified for extension "${ext}"`);
235
233
  if ('function' != typeof loader) throw Error('loader is not a function');
236
234
  }
237
- module.exports.defaultLoaders = defaultLoaders;
238
- let makeEmplace = (enableCache)=>(c, filepath, res)=>(enableCache && c.set(filepath, res), res);
239
235
  module.exports.lilconfig = function lilconfig(name, options) {
240
- let { ignoreEmptySearchPlaces, loaders, packageProp, searchPlaces, stopDir, transform, cache } = getOptions(name, options ?? {}, !1), searchCache = new Map(), loadCache = new Map(), emplace = makeEmplace(cache);
236
+ let { ignoreEmptySearchPlaces, loaders, packageProp, searchPlaces, stopDir, transform, cache } = getOptions(name, options ?? {}, !1), searchCache = new Map(), loadCache = new Map(), emplace = (c, filepath, res)=>(cache && c.set(filepath, res), res);
241
237
  return {
242
238
  async search (searchFrom = process.cwd()) {
243
239
  let result = {
@@ -320,87 +316,6 @@ __webpack_require__.add({
320
316
  cache && (loadCache.clear(), searchCache.clear());
321
317
  }
322
318
  };
323
- }, module.exports.lilconfigSync = function lilconfigSync(name, options) {
324
- let { ignoreEmptySearchPlaces, loaders, packageProp, searchPlaces, stopDir, transform, cache } = getOptions(name, options ?? {}, !0), searchCache = new Map(), loadCache = new Map(), emplace = makeEmplace(cache);
325
- return {
326
- search (searchFrom = process.cwd()) {
327
- let result = {
328
- config: null,
329
- filepath: ''
330
- }, visited = new Set(), dir = searchFrom;
331
- dirLoop: for(;;){
332
- if (cache) {
333
- let r = searchCache.get(dir);
334
- if (void 0 !== r) {
335
- for (let p of visited)searchCache.set(p, r);
336
- return r;
337
- }
338
- visited.add(dir);
339
- }
340
- for (let searchPlace of searchPlaces){
341
- let filepath = path.join(dir, searchPlace);
342
- try {
343
- fs.accessSync(filepath);
344
- } catch {
345
- continue;
346
- }
347
- let loaderKey = path.extname(searchPlace) || 'noExt', loader = loaders[loaderKey], content = String(fs.readFileSync(filepath));
348
- if ('package.json' === searchPlace) {
349
- let maybeConfig = getPackageProp(packageProp, loader(filepath, content));
350
- if (null != maybeConfig) {
351
- result.config = maybeConfig, result.filepath = filepath;
352
- break dirLoop;
353
- }
354
- continue;
355
- }
356
- let isEmpty = '' === content.trim();
357
- if (!isEmpty || !ignoreEmptySearchPlaces) {
358
- isEmpty ? (result.isEmpty = !0, result.config = void 0) : (validateLoader(loader, loaderKey), result.config = loader(filepath, content)), result.filepath = filepath;
359
- break dirLoop;
360
- }
361
- }
362
- if (dir === stopDir || dir === parentDir(dir)) break;
363
- dir = parentDir(dir);
364
- }
365
- let transformed = '' === result.filepath && null === result.config ? transform(null) : transform(result);
366
- if (cache) for (let p of visited)searchCache.set(p, transformed);
367
- return transformed;
368
- },
369
- load (filepath) {
370
- validateFilePath(filepath);
371
- let absPath = path.resolve(process.cwd(), filepath);
372
- if (cache && loadCache.has(absPath)) return loadCache.get(absPath);
373
- let { base, ext } = path.parse(absPath), loaderKey = ext || 'noExt', loader = loaders[loaderKey];
374
- validateLoader(loader, loaderKey);
375
- let content = String(fs.readFileSync(absPath));
376
- if ('package.json' === base) return transform({
377
- config: getPackageProp(packageProp, loader(absPath, content)),
378
- filepath: absPath
379
- });
380
- let result = {
381
- config: null,
382
- filepath: absPath
383
- }, isEmpty = '' === content.trim();
384
- return isEmpty && ignoreEmptySearchPlaces ? emplace(loadCache, absPath, transform({
385
- filepath: absPath,
386
- config: void 0,
387
- isEmpty: !0
388
- })) : (result.config = isEmpty ? void 0 : loader(absPath, content), emplace(loadCache, absPath, transform(isEmpty ? {
389
- ...result,
390
- isEmpty,
391
- config: void 0
392
- } : result)));
393
- },
394
- clearLoadCache () {
395
- cache && loadCache.clear();
396
- },
397
- clearSearchCache () {
398
- cache && searchCache.clear();
399
- },
400
- clearCaches () {
401
- cache && (loadCache.clear(), searchCache.clear());
402
- }
403
- };
404
319
  };
405
320
  },
406
321
  "../../node_modules/.pnpm/on-finished@2.4.1/node_modules/on-finished/index.js" (module, __unused_rspack_exports, __webpack_require__) {
@@ -469,8 +384,8 @@ __webpack_require__.add({
469
384
  return (asyncHooks.AsyncResource && (res = new asyncHooks.AsyncResource(fn.name || 'bound-anonymous-fn')), res && res.runInAsyncScope) ? res.runInAsyncScope.bind(res, fn, null) : fn;
470
385
  }
471
386
  },
472
- "../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.6.1_postcss@8.5.9_yaml@2.8.2/node_modules/postcss-load-config/src/index.js" (module, __unused_rspack_exports, __webpack_require__) {
473
- let yaml, { resolve } = __webpack_require__("node:path?435f"), config = __webpack_require__("../../node_modules/.pnpm/lilconfig@3.1.3/node_modules/lilconfig/src/index.js"), loadOptions = __webpack_require__("../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.6.1_postcss@8.5.9_yaml@2.8.2/node_modules/postcss-load-config/src/options.js"), loadPlugins = __webpack_require__("../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.6.1_postcss@8.5.9_yaml@2.8.2/node_modules/postcss-load-config/src/plugins.js"), req = __webpack_require__("../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.6.1_postcss@8.5.9_yaml@2.8.2/node_modules/postcss-load-config/src/req.js");
387
+ "../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.6.1_postcss@8.5.10_yaml@2.8.2/node_modules/postcss-load-config/src/index.js" (module, __unused_rspack_exports, __webpack_require__) {
388
+ let yaml, { resolve } = __webpack_require__("node:path?435f"), config = __webpack_require__("../../node_modules/.pnpm/lilconfig@3.1.3/node_modules/lilconfig/src/index.js"), loadOptions = __webpack_require__("../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.6.1_postcss@8.5.10_yaml@2.8.2/node_modules/postcss-load-config/src/options.js"), loadPlugins = __webpack_require__("../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.6.1_postcss@8.5.10_yaml@2.8.2/node_modules/postcss-load-config/src/plugins.js"), req = __webpack_require__("../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.6.1_postcss@8.5.10_yaml@2.8.2/node_modules/postcss-load-config/src/req.js");
474
389
  async function processResult(ctx, result) {
475
390
  let obj, file = result.filepath || '', projectConfig = ((obj = result.config) && obj.__esModule ? obj : {
476
391
  default: obj
@@ -543,8 +458,8 @@ __webpack_require__.add({
543
458
  });
544
459
  };
545
460
  },
546
- "../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.6.1_postcss@8.5.9_yaml@2.8.2/node_modules/postcss-load-config/src/options.js" (module, __unused_rspack_exports, __webpack_require__) {
547
- let req = __webpack_require__("../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.6.1_postcss@8.5.9_yaml@2.8.2/node_modules/postcss-load-config/src/req.js");
461
+ "../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.6.1_postcss@8.5.10_yaml@2.8.2/node_modules/postcss-load-config/src/options.js" (module, __unused_rspack_exports, __webpack_require__) {
462
+ let req = __webpack_require__("../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.6.1_postcss@8.5.10_yaml@2.8.2/node_modules/postcss-load-config/src/req.js");
548
463
  module.exports = async function options(config, file) {
549
464
  if (config.parser && 'string' == typeof config.parser) try {
550
465
  config.parser = await req(config.parser, file);
@@ -564,8 +479,8 @@ __webpack_require__.add({
564
479
  return config;
565
480
  };
566
481
  },
567
- "../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.6.1_postcss@8.5.9_yaml@2.8.2/node_modules/postcss-load-config/src/plugins.js" (module, __unused_rspack_exports, __webpack_require__) {
568
- let req = __webpack_require__("../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.6.1_postcss@8.5.9_yaml@2.8.2/node_modules/postcss-load-config/src/req.js");
482
+ "../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.6.1_postcss@8.5.10_yaml@2.8.2/node_modules/postcss-load-config/src/plugins.js" (module, __unused_rspack_exports, __webpack_require__) {
483
+ let req = __webpack_require__("../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.6.1_postcss@8.5.10_yaml@2.8.2/node_modules/postcss-load-config/src/req.js");
569
484
  async function load(plugin, options, file) {
570
485
  try {
571
486
  if (null == options || 0 === Object.keys(options).length) return await req(plugin, file);
@@ -581,7 +496,7 @@ __webpack_require__.add({
581
496
  }), list;
582
497
  };
583
498
  },
584
- "../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.6.1_postcss@8.5.9_yaml@2.8.2/node_modules/postcss-load-config/src/req.js" (module, __unused_rspack_exports, __webpack_require__) {
499
+ "../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.6.1_postcss@8.5.10_yaml@2.8.2/node_modules/postcss-load-config/src/req.js" (module, __unused_rspack_exports, __webpack_require__) {
585
500
  let tsx, jiti;
586
501
  var __filename = __rspack_fileURLToPath(import.meta.url);
587
502
  let { createRequire } = __webpack_require__("node:module?1bcb"), { pathToFileURL } = __webpack_require__("node:url?b4ec"), TS_EXT_RE = /\.[mc]?ts$/, importError = [];
@@ -3552,7 +3467,7 @@ function createPublicContext(context) {
3552
3467
  async function createContext(options, userConfig, logger) {
3553
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;
3554
3469
  return {
3555
- version: "2.0.0-rc.4",
3470
+ version: "2.0.1",
3556
3471
  rootPath,
3557
3472
  distPath: '',
3558
3473
  cachePath,
@@ -4090,7 +4005,7 @@ async function createCompiler_createCompiler(options) {
4090
4005
  if (item1 < item2) return -1;
4091
4006
  }
4092
4007
  return 0;
4093
- })(version, '1.5.0') >= 0)) throw Error(`${color.dim('[rsbuild]')} The current Rspack version does not meet the requirements, the minimum supported version of Rspack is ${color.green("1.5.0")}`);
4008
+ })(version, '2.0.0') >= 0)) throw Error(`${color.dim('[rsbuild]')} The current Rspack version does not meet the requirements, the minimum supported version of Rspack is ${color.green("2.0.0")}`);
4094
4009
  let isMultiCompiler = rspackConfigs.length > 1, compiler = isMultiCompiler ? core_rspack(rspackConfigs) : core_rspack(rspackConfigs[0]);
4095
4010
  'true' === process.env.RSPACK_UNSAFE_FAST_DROP && (compiler.unsafeFastDrop = !0);
4096
4011
  let isVersionLogged = !1, isCompiling = !1, logRspackVersion = ()=>{
@@ -4299,7 +4214,7 @@ let RSPACK_BUILD_ERROR = 'Rspack build failed.', build_build = async (initOption
4299
4214
  stats,
4300
4215
  close: async ()=>{}
4301
4216
  };
4302
- }, main = __webpack_require__("../../node_modules/.pnpm/dotenv-expand@12.0.3/node_modules/dotenv-expand/lib/main.js"), DOTENV_LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/gm;
4217
+ }, main = __webpack_require__("../../node_modules/.pnpm/dotenv-expand@13.0.0/node_modules/dotenv-expand/lib/main.js"), DOTENV_LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/gm;
4303
4218
  function loadEnv_parse(src) {
4304
4219
  let match, obj = {}, lines = src.toString();
4305
4220
  for(lines = lines.replace(/\r\n?/gm, '\n'); null != (match = DOTENV_LINE.exec(lines));){
@@ -4319,7 +4234,7 @@ function loadEnv({ cwd = process.cwd(), mode = process.env.NODE_ENV || '', prefi
4319
4234
  `.env.${mode}.local`
4320
4235
  ].map((filename)=>join(cwd, filename)).filter(isFileSync), parsed = {};
4321
4236
  for (let envPath of filePaths)Object.assign(parsed, loadEnv_parse(node_fs.readFileSync(envPath))), src_logger.debug('loaded env file:', envPath);
4322
- parsed.NODE_ENV && (processEnv.NODE_ENV = parsed.NODE_ENV), (0, main.expand)({
4237
+ parsed.NODE_ENV && (processEnv.NODE_ENV = parsed.NODE_ENV), (0, main.f)({
4323
4238
  parsed,
4324
4239
  processEnv
4325
4240
  });
@@ -4443,7 +4358,7 @@ function parseMinifyOptions(config) {
4443
4358
  cssOptions: minify.cssOptions
4444
4359
  };
4445
4360
  }
4446
- let postcss_load_config_src = __webpack_require__("../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.6.1_postcss@8.5.9_yaml@2.8.2/node_modules/postcss-load-config/src/index.js");
4361
+ let postcss_load_config_src = __webpack_require__("../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.6.1_postcss@8.5.10_yaml@2.8.2/node_modules/postcss-load-config/src/index.js");
4447
4362
  var postcss_load_config_src_default = __webpack_require__.n(postcss_load_config_src);
4448
4363
  function getLightningCSSLoaderOptions(config, targets, minify) {
4449
4364
  let userOptions = 'object' == typeof config.tools.lightningcssLoader ? config.tools.lightningcssLoader : {}, initialOptions = {
@@ -5041,7 +4956,12 @@ function getInlineTests(config) {
5041
4956
  styleTests
5042
4957
  };
5043
4958
  }
5044
- 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)=>{
5045
4965
  if (path === base) return '/';
5046
4966
  let trailingSlashBase = addTrailingSlash(base);
5047
4967
  return path.startsWith(trailingSlashBase) ? path.slice(trailingSlashBase.length - 1) : path;
@@ -5054,12 +4974,7 @@ let normalizeUrl = (url)=>url.replace(/([^:]\/)\/+/g, '$1'), joinUrlSegments = (
5054
4974
  return prev.concat(...routes);
5055
4975
  }, []);
5056
4976
  }, formatRoutes = (entry, base, distPathPrefix, outputStructure)=>{
5057
- let prefix = joinUrlSegments(base, ((input)=>{
5058
- let prefix = input;
5059
- if (prefix?.startsWith('./') && (prefix = prefix.replace('./', '')), !prefix) return '/';
5060
- let hasLeadingSlash = prefix.startsWith('/'), hasTailSlash = prefix.endsWith('/');
5061
- return `${hasLeadingSlash ? '' : '/'}${prefix}${hasTailSlash ? '' : '/'}`;
5062
- })(distPathPrefix));
4977
+ let prefix = joinUrlSegments(base, formatPrefix(distPathPrefix));
5063
4978
  return Object.keys(entry).map((entryName)=>({
5064
4979
  entryName,
5065
4980
  pathname: prefix + ('index' === entryName && 'nested' !== outputStructure ? '' : entryName)
@@ -5078,7 +4993,7 @@ function getURLMessages(urls, routes) {
5078
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`;
5079
4994
  }), message;
5080
4995
  }
5081
- 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 }) {
5082
4997
  if (!1 === printUrls) return null;
5083
4998
  let urls = originalUrls, useCustomUrl = isFunction(printUrls);
5084
4999
  if (useCustomUrl) {
@@ -5100,8 +5015,15 @@ function printServerURLs({ urls: originalUrls, port, routes, protocol, printUrls
5100
5015
  };
5101
5016
  });
5102
5017
  }
5103
- if (0 === urls.length || 0 === routes.length && !useCustomUrl) return null;
5104
- 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);
5105
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;
5106
5028
  }
5107
5029
  let getPort = async ({ host, port, strictPort, tryLimits = 20 })=>{
@@ -6062,7 +5984,7 @@ function createMiddleware(context, ready, outputFileSystem) {
6062
5984
  }
6063
5985
  async function setupOutputFileSystem(writeToDisk, compilers) {
6064
5986
  if (!0 !== writeToDisk) {
6065
- let { createFsFromVolume, Volume } = await import("./memfs.js").then(__webpack_require__.t.bind(__webpack_require__, "../../node_modules/.pnpm/memfs@4.57.1_tslib@2.8.1/node_modules/memfs/lib/index.js", 23)), outputFileSystem = createFsFromVolume(new Volume());
5987
+ let { createFsFromVolume, Volume } = await import("./memfs.js").then(__webpack_require__.t.bind(__webpack_require__, "../../node_modules/.pnpm/memfs@4.57.2_tslib@2.8.1/node_modules/memfs/lib/index.js", 23)), outputFileSystem = createFsFromVolume(new Volume());
6066
5988
  for (let compiler of compilers)compiler.outputFileSystem = outputFileSystem;
6067
5989
  }
6068
5990
  let compiler = compilers.find((compiler)=>!!compiler.outputFileSystem);
@@ -6722,7 +6644,7 @@ function gzipMiddleware_gzipMiddleware({ filter, level = node_zlib.constants.Z_B
6722
6644
  write(chunk) || gzip.pause();
6723
6645
  }), on('drain', ()=>gzip.resume()), gzip.on('end', ()=>{
6724
6646
  end();
6725
- }), listeners))gzip.on.apply(gzip, listener);
6647
+ }), listeners))gzip.on(...listener);
6726
6648
  else for (let listener of listeners)on.apply(res, listener);
6727
6649
  let statusCode = writeHeadStatus ?? res.statusCode;
6728
6650
  void 0 !== writeHeadMessage ? writeHead(statusCode, writeHeadMessage) : writeHead(statusCode);
@@ -7392,7 +7314,7 @@ async function startWatchFiles({ paths, options, type = 'reload-page' }, buildMa
7392
7314
  async function devServer_createDevServer(options, createCompiler, config, { getPortSilently, runCompile = !0 } = {}) {
7393
7315
  let lastStats, { context } = options, { logger } = context;
7394
7316
  logger.debug('create dev server');
7395
- 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;
7396
7318
  context.devServer = {
7397
7319
  hostname: host,
7398
7320
  port,
@@ -7434,6 +7356,7 @@ async function devServer_createDevServer(options, createCompiler, config, { getP
7434
7356
  routes,
7435
7357
  protocol,
7436
7358
  printUrls: config.server.printUrls,
7359
+ fallbackPathname,
7437
7360
  trailingLineBreak: !cliShortcutsEnabled,
7438
7361
  originalConfig: context.originalConfig,
7439
7362
  logger
@@ -8757,7 +8680,7 @@ try {
8757
8680
  api.modifyBundlerChain(async (chain, { CHAIN_ID, environment, isDev })=>{
8758
8681
  let { output: { manifest }, dev: { writeToDisk } } = environment.config;
8759
8682
  if (!1 === manifest) return;
8760
- let manifestOptions = normalizeManifestObjectConfig(manifest), { RspackManifestPlugin } = await import("./manifest-plugin.js").then(__webpack_require__.bind(__webpack_require__, "../../node_modules/.pnpm/rspack-manifest-plugin@5.2.1_@rspack+core@2.0.0-rc.3/node_modules/rspack-manifest-plugin/dist/index.js")), { htmlPaths } = environment, filter = manifestOptions.filter ?? ((file)=>!file.name.endsWith('.LICENSE.txt'));
8683
+ let manifestOptions = normalizeManifestObjectConfig(manifest), { RspackManifestPlugin } = await import("./manifest-plugin.js").then(__webpack_require__.bind(__webpack_require__, "../../node_modules/.pnpm/rspack-manifest-plugin@5.2.1_@rspack+core@2.0.0/node_modules/rspack-manifest-plugin/dist/index.js")), { htmlPaths } = environment, filter = manifestOptions.filter ?? ((file)=>!file.name.endsWith('.LICENSE.txt'));
8761
8684
  manifestFilenames.set(environment.name, manifestOptions.filename);
8762
8685
  let pluginOptions = {
8763
8686
  fileName: manifestOptions.filename,
@@ -9271,7 +9194,7 @@ let applyServerOptions = (command)=>{
9271
9194
  };
9272
9195
  function setupCommands() {
9273
9196
  let cli = ((name = "")=>new CAC(name))('rsbuild');
9274
- cli.version("2.0.0-rc.4"), 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)', {
9275
9198
  default: 'auto'
9276
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', {
9277
9200
  type: [
@@ -9348,7 +9271,7 @@ function initNodeEnv() {
9348
9271
  }
9349
9272
  function showGreeting() {
9350
9273
  let { npm_execpath, npm_lifecycle_event, NODE_RUN_SCRIPT_NAME } = process.env, isBun = npm_execpath?.includes('.bun');
9351
- src_logger.greet(`${'npx' === npm_lifecycle_event || isBun || NODE_RUN_SCRIPT_NAME ? '\n' : ''}Rsbuild v2.0.0-rc.4\n`);
9274
+ src_logger.greet(`${'npx' === npm_lifecycle_event || isBun || NODE_RUN_SCRIPT_NAME ? '\n' : ''}Rsbuild v2.0.1\n`);
9352
9275
  }
9353
9276
  function setupLogLevel() {
9354
9277
  let logLevelIndex = process.argv.findIndex((item)=>'--log-level' === item || '--logLevel' === item);
@@ -9369,5 +9292,5 @@ function runCLI() {
9369
9292
  src_logger.error('Failed to start Rsbuild CLI.'), src_logger.error(err), process.exit(1);
9370
9293
  }
9371
9294
  }
9372
- let src_version = "2.0.0-rc.4";
9295
+ let src_version = "2.0.1";
9373
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;
@@ -405,7 +405,7 @@ __webpack_require__.add({
405
405
  module.exports = createColors(), module.exports.createColors = createColors;
406
406
  },
407
407
  "../../node_modules/.pnpm/shell-quote@1.8.3/node_modules/shell-quote/index.js" (__unused_rspack_module, exports, __webpack_require__) {
408
- exports.quote = __webpack_require__("../../node_modules/.pnpm/shell-quote@1.8.3/node_modules/shell-quote/quote.js"), exports.parse = __webpack_require__("../../node_modules/.pnpm/shell-quote@1.8.3/node_modules/shell-quote/parse.js");
408
+ __webpack_require__("../../node_modules/.pnpm/shell-quote@1.8.3/node_modules/shell-quote/quote.js"), exports.parse = __webpack_require__("../../node_modules/.pnpm/shell-quote@1.8.3/node_modules/shell-quote/parse.js");
409
409
  },
410
410
  "../../node_modules/.pnpm/shell-quote@1.8.3/node_modules/shell-quote/parse.js" (module) {
411
411
  for(var CONTROL = "(?:\\|\\||\\&\\&|;;|\\|\\&|\\<\\(|\\<\\<\\<|>>|>\\&|<\\&|[&;()|<>])", controlRE = RegExp('^' + CONTROL + '$'), META = '|&;()<> \\t', hash = /^#$/, TOKEN = '', i = 0; i < 4; i++)TOKEN += (0x100000000 * Math.random()).toString(16);
@@ -1,7 +1,7 @@
1
1
  import { __webpack_require__ } from "./1~rslib-runtime.js";
2
2
  import "./753.js";
3
3
  __webpack_require__.add({
4
- "../../node_modules/.pnpm/rspack-manifest-plugin@5.2.1_@rspack+core@2.0.0-rc.3/node_modules/rspack-manifest-plugin/dist/helpers.js" (__unused_rspack_module, exports, __webpack_require__) {
4
+ "../../node_modules/.pnpm/rspack-manifest-plugin@5.2.1_@rspack+core@2.0.0/node_modules/rspack-manifest-plugin/dist/helpers.js" (__unused_rspack_module, exports, __webpack_require__) {
5
5
  exports.transformFiles = exports.reduceChunk = exports.reduceAssets = exports.generateManifest = void 0;
6
6
  let node_path_1 = __webpack_require__("node:path?435f");
7
7
  exports.generateManifest = (compilation, files, { generate, seed = {} })=>generate ? generate(seed, files, Array.from(compilation.entrypoints.entries()).reduce((e, [name, entrypoint])=>Object.assign(e, {
@@ -61,9 +61,9 @@ __webpack_require__.add({
61
61
  'sort'
62
62
  ].filter((fname)=>!!options[fname]).reduce((prev, fname)=>prev[fname](options[fname]), files).map(standardizeFilePaths);
63
63
  },
64
- "../../node_modules/.pnpm/rspack-manifest-plugin@5.2.1_@rspack+core@2.0.0-rc.3/node_modules/rspack-manifest-plugin/dist/hooks.js" (__unused_rspack_module, exports, __webpack_require__) {
64
+ "../../node_modules/.pnpm/rspack-manifest-plugin@5.2.1_@rspack+core@2.0.0/node_modules/rspack-manifest-plugin/dist/hooks.js" (__unused_rspack_module, exports, __webpack_require__) {
65
65
  exports.getCompilerHooks = exports.emitHook = exports.beforeRunHook = void 0;
66
- let node_fs_1 = __webpack_require__("node:fs?9592"), node_path_1 = __webpack_require__("node:path?435f"), lite_tapable_1 = __webpack_require__("../../node_modules/.pnpm/@rspack+lite-tapable@1.1.0/node_modules/@rspack/lite-tapable/dist/index.cjs"), helpers_1 = __webpack_require__("../../node_modules/.pnpm/rspack-manifest-plugin@5.2.1_@rspack+core@2.0.0-rc.3/node_modules/rspack-manifest-plugin/dist/helpers.js"), compilerHookMap = new WeakMap(), getCompilerHooks = (compiler)=>{
66
+ let node_fs_1 = __webpack_require__("node:fs?9592"), node_path_1 = __webpack_require__("node:path?435f"), lite_tapable_1 = __webpack_require__("../../node_modules/.pnpm/@rspack+lite-tapable@1.1.0/node_modules/@rspack/lite-tapable/dist/index.cjs"), helpers_1 = __webpack_require__("../../node_modules/.pnpm/rspack-manifest-plugin@5.2.1_@rspack+core@2.0.0/node_modules/rspack-manifest-plugin/dist/helpers.js"), compilerHookMap = new WeakMap(), getCompilerHooks = (compiler)=>{
67
67
  let hooks = compilerHookMap.get(compiler);
68
68
  return void 0 === hooks && (hooks = {
69
69
  afterEmit: new lite_tapable_1.SyncWaterfallHook([
@@ -112,9 +112,9 @@ __webpack_require__.add({
112
112
  getCompilerHooks(compiler).afterEmit.call(manifest);
113
113
  };
114
114
  },
115
- "../../node_modules/.pnpm/rspack-manifest-plugin@5.2.1_@rspack+core@2.0.0-rc.3/node_modules/rspack-manifest-plugin/dist/index.js" (__unused_rspack_module, exports, __webpack_require__) {
115
+ "../../node_modules/.pnpm/rspack-manifest-plugin@5.2.1_@rspack+core@2.0.0/node_modules/rspack-manifest-plugin/dist/index.js" (__unused_rspack_module, exports, __webpack_require__) {
116
116
  exports.RspackManifestPlugin = void 0;
117
- let node_path_1 = __webpack_require__("node:path?435f"), hooks_1 = __webpack_require__("../../node_modules/.pnpm/rspack-manifest-plugin@5.2.1_@rspack+core@2.0.0-rc.3/node_modules/rspack-manifest-plugin/dist/hooks.js"), emitCountMap = new Map(), defaults = {
117
+ let node_path_1 = __webpack_require__("node:path?435f"), hooks_1 = __webpack_require__("../../node_modules/.pnpm/rspack-manifest-plugin@5.2.1_@rspack+core@2.0.0/node_modules/rspack-manifest-plugin/dist/hooks.js"), emitCountMap = new Map(), defaults = {
118
118
  assetHookStage: 1 / 0,
119
119
  basePath: '',
120
120
  fileName: 'manifest.json',
@@ -683,5 +683,5 @@ __webpack_require__.add({
683
683
  });
684
684
  }
685
685
  });
686
- var RspackManifestPlugin = __webpack_require__("../../node_modules/.pnpm/rspack-manifest-plugin@5.2.1_@rspack+core@2.0.0-rc.3/node_modules/rspack-manifest-plugin/dist/index.js").RspackManifestPlugin;
686
+ var RspackManifestPlugin = __webpack_require__("../../node_modules/.pnpm/rspack-manifest-plugin@5.2.1_@rspack+core@2.0.0/node_modules/rspack-manifest-plugin/dist/index.js").RspackManifestPlugin;
687
687
  export { RspackManifestPlugin };