@rsbuild/core 2.0.15 → 2.1.0-rc.0

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,8 +1,8 @@
1
1
  (() => {
2
2
  var __webpack_modules__ = {
3
- 737: (module, __unused_webpack_exports, __nccwpck_require__) => {
3
+ 454: (module, __unused_webpack_exports, __nccwpck_require__) => {
4
4
  "use strict";
5
- const { HtmlWebpackChildCompiler } = __nccwpck_require__(370);
5
+ const { HtmlWebpackChildCompiler } = __nccwpck_require__(215);
6
6
  const compilerMap = new WeakMap();
7
7
  class CachedChildCompilation {
8
8
  constructor(compiler) {
@@ -311,7 +311,7 @@
311
311
  }
312
312
  module.exports = { CachedChildCompilation };
313
313
  },
314
- 370: (module) => {
314
+ 215: (module) => {
315
315
  "use strict";
316
316
  class HtmlWebpackChildCompiler {
317
317
  constructor(templates) {
@@ -480,7 +480,7 @@
480
480
  }
481
481
  module.exports = { HtmlWebpackChildCompiler };
482
482
  },
483
- 18: (module) => {
483
+ 133: (module) => {
484
484
  "use strict";
485
485
  module.exports = {};
486
486
  module.exports.none = (chunks) => chunks;
@@ -499,7 +499,7 @@
499
499
  };
500
500
  module.exports.auto = module.exports.none;
501
501
  },
502
- 21: (module) => {
502
+ 348: (module) => {
503
503
  "use strict";
504
504
  module.exports = function (err) {
505
505
  return {
@@ -523,7 +523,7 @@
523
523
  };
524
524
  };
525
525
  },
526
- 212: (module, __unused_webpack_exports, __nccwpck_require__) => {
526
+ 651: (module, __unused_webpack_exports, __nccwpck_require__) => {
527
527
  "use strict";
528
528
  const { AsyncSeriesWaterfallHook } = __nccwpck_require__(159);
529
529
  const htmlWebpackPluginHooksMap = new WeakMap();
@@ -549,7 +549,7 @@
549
549
  }
550
550
  module.exports = { getHtmlRspackPluginHooks };
551
551
  },
552
- 1: (module) => {
552
+ 362: (module) => {
553
553
  const voidTags = [
554
554
  "area",
555
555
  "base",
@@ -617,19 +617,19 @@
617
617
  htmlTagObjectToString,
618
618
  };
619
619
  },
620
- 108: (module, __unused_webpack_exports, __nccwpck_require__) => {
620
+ 667: (module, __unused_webpack_exports, __nccwpck_require__) => {
621
621
  "use strict";
622
622
  const promisify = __nccwpck_require__(23).promisify;
623
623
  const vm = __nccwpck_require__(154);
624
624
  const fs = __nccwpck_require__(896);
625
625
  const path = __nccwpck_require__(928);
626
- const { CachedChildCompilation } = __nccwpck_require__(737);
626
+ const { CachedChildCompilation } = __nccwpck_require__(454);
627
627
  const { createHtmlTagObject, htmlTagObjectToString, HtmlTagArray } =
628
- __nccwpck_require__(1);
629
- const prettyError = __nccwpck_require__(21);
630
- const chunkSorter = __nccwpck_require__(18);
628
+ __nccwpck_require__(362);
629
+ const prettyError = __nccwpck_require__(348);
630
+ const chunkSorter = __nccwpck_require__(133);
631
631
  const getHtmlRspackPluginHooks =
632
- __nccwpck_require__(212).getHtmlRspackPluginHooks;
632
+ __nccwpck_require__(651).getHtmlRspackPluginHooks;
633
633
  const WITH_PLACEHOLDER = "function __with_placeholder__";
634
634
  class HtmlRspackPlugin {
635
635
  constructor(userOptions = {}) {
@@ -2398,6 +2398,6 @@
2398
2398
  }
2399
2399
  if (typeof __nccwpck_require__ !== "undefined")
2400
2400
  __nccwpck_require__.ab = __dirname + "/";
2401
- var __webpack_exports__ = __nccwpck_require__(108);
2401
+ var __webpack_exports__ = __nccwpck_require__(667);
2402
2402
  module.exports = __webpack_exports__;
2403
2403
  })();
@@ -1 +1 @@
1
- {"name":"http-proxy-middleware","author":"Steven Chim","version":"4.1.0","license":"MIT","types":"index.d.ts","type":"module"}
1
+ {"name":"http-proxy-middleware","author":"Steven Chim","version":"4.1.1","license":"MIT","types":"index.d.ts","type":"module"}
@@ -1,15 +1,15 @@
1
1
  (() => {
2
2
  "use strict";
3
3
  var __webpack_modules__ = {
4
- 339: (module, __unused_webpack_exports, __nccwpck_require__) => {
5
- module.exports = __nccwpck_require__(821)["default"];
4
+ 549: (module, __unused_webpack_exports, __nccwpck_require__) => {
5
+ module.exports = __nccwpck_require__(735)["default"];
6
6
  },
7
- 821: (__unused_webpack_module, exports, __nccwpck_require__) => {
7
+ 735: (__unused_webpack_module, exports, __nccwpck_require__) => {
8
8
  var __webpack_unused_export__;
9
9
  __webpack_unused_export__ = { value: true };
10
10
  exports["default"] = loader;
11
11
  var _nodePath = _interopRequireDefault(__nccwpck_require__(760));
12
- var _utils = __nccwpck_require__(520);
12
+ var _utils = __nccwpck_require__(506);
13
13
  function _interopRequireDefault(e) {
14
14
  return e && e.__esModule ? e : { default: e };
15
15
  }
@@ -179,7 +179,7 @@
179
179
  callback(null, result.css, map, { ast });
180
180
  }
181
181
  },
182
- 520: (module, exports, __nccwpck_require__) => {
182
+ 506: (module, exports, __nccwpck_require__) => {
183
183
  module = __nccwpck_require__.nmd(module);
184
184
  Object.defineProperty(exports, "__esModule", { value: true });
185
185
  exports.exec = exec;
@@ -716,6 +716,6 @@
716
716
  })();
717
717
  if (typeof __nccwpck_require__ !== "undefined")
718
718
  __nccwpck_require__.ab = __dirname + "/";
719
- var __webpack_exports__ = __nccwpck_require__(339);
719
+ var __webpack_exports__ = __nccwpck_require__(549);
720
720
  module.exports = __webpack_exports__;
721
721
  })();
@@ -1 +1 @@
1
- {"name":"rspack-chain","version":"2.1.0","license":"MIT","types":"types/index.d.ts","type":"module"}
1
+ {"name":"rspack-chain","version":"2.1.1","license":"MIT","types":"types/index.d.ts","type":"module"}
@@ -91,7 +91,6 @@ export declare class RspackChain extends __Config.ChainedMap<void> {
91
91
  loader(value: RspackConfig['loader']): this;
92
92
  name(value: RspackConfig['name']): this;
93
93
  infrastructureLogging(value: RspackConfig['infrastructureLogging']): this;
94
- snapshot(value: RspackConfig['snapshot']): this;
95
94
  lazyCompilation(value: RspackConfig['lazyCompilation']): this;
96
95
  incremental(value: RspackConfig['incremental']): this;
97
96
 
package/dist/756.js CHANGED
@@ -84,23 +84,24 @@ __webpack_require__.add({
84
84
  }, {});
85
85
  }, module.exports = deepmerge;
86
86
  },
87
- "../../node_modules/.pnpm/dotenv-expand@13.0.0/node_modules/dotenv-expand/lib/main.js" (module) {
87
+ "../../node_modules/.pnpm/dotenv-expand@13.0.0_patch_hash=5ff37847fa487be2db4e4f14c2b21937f4e51cc7a43deea4506d4aaf3fa6149c/node_modules/dotenv-expand/lib/main.js" (module) {
88
88
  function _resolveEscapeSequences(value) {
89
89
  return value.replace(/\\\$/g, '$');
90
90
  }
91
+ let propertyIsEnumerable = Object.prototype.propertyIsEnumerable;
92
+ function getEnvValue(key, processEnv, runningParsed) {
93
+ return propertyIsEnumerable.call(processEnv, key) ? processEnv[key] : runningParsed[key];
94
+ }
91
95
  function expandValue(value, processEnv, runningParsed) {
92
- let match, env = {
93
- ...runningParsed,
94
- ...processEnv
95
- }, regex = /(?<!\\)\${([^{}]+)}|(?<!\\)\$([A-Za-z_][A-Za-z0-9_]*)/g, result = value, seen = new Set();
96
+ let match, regex = /(?<!\\)\${([^{}]+)}|(?<!\\)\$([A-Za-z_][A-Za-z0-9_]*)/g, result = value, seen = new Set();
96
97
  for(; null !== (match = regex.exec(result));){
97
98
  let defaultValue, value;
98
99
  seen.add(result);
99
- let [template, bracedExpression, unbracedExpression] = match, expression = bracedExpression || unbracedExpression, opRegex = /(:\+|\+|:-|-)/, opMatch = expression.match(opRegex), splitter = opMatch ? opMatch[0] : null, r = expression.split(splitter), key = r.shift();
100
+ let [template, bracedExpression, unbracedExpression] = match, expression = bracedExpression || unbracedExpression, opRegex = /(:\+|\+|:-|-)/, opMatch = expression.match(opRegex), splitter = opMatch ? opMatch[0] : null, r = expression.split(splitter), key = r.shift(), envValue = getEnvValue(key, processEnv, runningParsed);
100
101
  if ([
101
102
  ':+',
102
103
  '+'
103
- ].includes(splitter) ? (defaultValue = env[key] ? r.join(splitter) : '', value = null) : (defaultValue = r.join(splitter), value = env[key]), (result = value ? seen.has(value) ? result.replace(template, defaultValue) : result.replace(template, value) : result.replace(template, defaultValue)) === runningParsed[key]) break;
104
+ ].includes(splitter) ? (defaultValue = envValue ? r.join(splitter) : '', value = null) : (defaultValue = r.join(splitter), value = envValue), (result = value ? seen.has(value) ? result.replace(template, defaultValue) : result.replace(template, value) : result.replace(template, defaultValue)) === runningParsed[key]) break;
104
105
  regex.lastIndex = 0;
105
106
  }
106
107
  return result;
@@ -2199,7 +2200,6 @@ class RspackChain extends ChainedMap {
2199
2200
  'loader',
2200
2201
  'name',
2201
2202
  'infrastructureLogging',
2202
- 'snapshot',
2203
2203
  'lazyCompilation',
2204
2204
  'incremental'
2205
2205
  ]);
@@ -3497,7 +3497,7 @@ function createPublicContext(context) {
3497
3497
  async function createContext(options, userConfig, logger) {
3498
3498
  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;
3499
3499
  return {
3500
- version: "2.0.15",
3500
+ version: "2.1.0-rc.0",
3501
3501
  rootPath,
3502
3502
  distPath: '',
3503
3503
  cachePath,
@@ -4150,18 +4150,15 @@ async function createCompiler_createCompiler(options) {
4150
4150
  let { name } = context.environmentList[index], time = Date.now() - startTime;
4151
4151
  context.buildState.time[name] = time;
4152
4152
  let suffix = isMultiCompiler ? color.dim(` (${name})`) : '', timeStr = `${((seconds)=>{
4153
- let time, time1;
4153
+ let format = (time, unit)=>color.bold(`${time}${unit}`);
4154
4154
  if (seconds < 10) {
4155
- let time, digits = seconds >= 0.01 ? 2 : 3;
4156
- return `${time = seconds.toFixed(digits), color.bold(time)} s`;
4157
- }
4158
- if (seconds < 60) {
4159
- let time;
4160
- return `${time = seconds.toFixed(1), color.bold(time)} s`;
4155
+ let digits = seconds >= 0.01 ? 2 : 3;
4156
+ return format(seconds.toFixed(digits), 's');
4161
4157
  }
4162
- let minutes = Math.floor(seconds / 60), minutesLabel = `${(time = minutes.toFixed(0), color.bold(time))} m`, remainingSeconds = seconds % 60;
4158
+ if (seconds < 60) return format(seconds.toFixed(1), 's');
4159
+ let minutesLabel = format(Math.floor(seconds / 60).toFixed(0), 'm'), remainingSeconds = seconds % 60;
4163
4160
  if (0 === remainingSeconds) return minutesLabel;
4164
- let secondsLabel = `${(time1 = remainingSeconds.toFixed(+(remainingSeconds % 1 != 0)), color.bold(time1))} s`;
4161
+ let secondsLabel = format(remainingSeconds.toFixed(+(remainingSeconds % 1 != 0)), 's');
4165
4162
  return `${minutesLabel} ${secondsLabel}`;
4166
4163
  })(time / 1000)}${suffix}`;
4167
4164
  hasErrors ? logger.error(`build failed in ${timeStr}`) : logger.ready(`built in ${timeStr}`);
@@ -4326,7 +4323,7 @@ let RSPACK_BUILD_ERROR = 'Rspack build failed.', build_build = async (initOption
4326
4323
  stats,
4327
4324
  close: async ()=>{}
4328
4325
  };
4329
- }, 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;
4326
+ }, main = __webpack_require__("../../node_modules/.pnpm/dotenv-expand@13.0.0_patch_hash=5ff37847fa487be2db4e4f14c2b21937f4e51cc7a43deea4506d4aaf3fa6149c/node_modules/dotenv-expand/lib/main.js"), DOTENV_LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/gm;
4330
4327
  function loadEnv_parse(src) {
4331
4328
  let match, obj = {}, lines = src.toString();
4332
4329
  for(lines = lines.replace(/\r\n?/gm, '\n'); null != (match = DOTENV_LINE.exec(lines));){
@@ -5121,12 +5118,11 @@ function pluginExternals() {
5121
5118
  };
5122
5119
  }
5123
5120
  async function gzipSize(input) {
5124
- let data = await new Promise((resolve, reject)=>{
5121
+ return (await new Promise((resolve, reject)=>{
5125
5122
  node_zlib.gzip(input, (err, result)=>{
5126
5123
  err ? reject(err) : resolve(result);
5127
5124
  });
5128
- });
5129
- return Buffer.byteLength(data);
5125
+ })).length;
5130
5126
  }
5131
5127
  function getSnapshotPath(dir, snapshotHash) {
5132
5128
  return snapshotHash ? node_path.join(dir, `rsbuild/file-sizes-${snapshotHash}.json`) : node_path.join(dir, 'rsbuild/file-sizes.json');
@@ -5151,7 +5147,7 @@ async function saveSnapshots(snapshotPath, snapshots, logger) {
5151
5147
  logger.debug('Failed to save file size snapshots:', err);
5152
5148
  }
5153
5149
  }
5154
- let EXCLUDE_ASSET_REGEX = /\.(?:map|LICENSE\.txt|d\.ts)$/, excludeAsset = (asset)=>EXCLUDE_ASSET_REGEX.test(asset.name), isSignificantDiff = (diff)=>Math.abs(diff) >= 10, formatDiff = (diff)=>{
5150
+ let EXCLUDE_ASSET_REGEX = /\.(?:map|LICENSE\.txt|d\.ts)$/, isSignificantDiff = (diff)=>Math.abs(diff) >= 10, formatDiff = (diff)=>{
5155
5151
  let label = `(${diff > 0 ? '+' : '-'}${calcFileSize(Math.abs(diff))})`;
5156
5152
  return {
5157
5153
  label: (diff > 0 ? color.red : color.green)(label),
@@ -5176,22 +5172,25 @@ function getHeader(maxFileLength, maxSizeLength, fileHeader, showGzipHeader) {
5176
5172
  let calcFileSize = (len)=>{
5177
5173
  let val = len / 1000;
5178
5174
  return `${val.toFixed(val < 1 ? 2 : 1)} kB`;
5179
- }, COMPRESSIBLE_REGEX = /\.(?:js|css|html|json|svg|txt|xml|xhtml|wasm|manifest|md)$/i;
5180
- async function printFileSizes(options, stats, rootPath, distPath, environmentName, previousSizes) {
5175
+ }, COMPRESSIBLE_REGEX = /\.(?:js|css|html|json|svg|txt|xml|xhtml|wasm|manifest|md)$/i, isCompressible = (assetName)=>COMPRESSIBLE_REGEX.test(assetName), getFilePath = (assetName)=>{
5176
+ let queryIndex = assetName.indexOf('?');
5177
+ return -1 === queryIndex ? assetName : assetName.slice(0, queryIndex);
5178
+ };
5179
+ async function printFileSizes(options, stats, rootPath, distPath, environmentName, previousSizes, saveSnapshot) {
5181
5180
  let logs = [], showDetail = !1 !== options.detail, showDiff = !1 !== options.diff && null !== previousSizes, showTotal = !1 !== options.total;
5182
5181
  if (!showTotal && !showDetail) return {
5183
5182
  logs
5184
5183
  };
5185
- let relativeDistPath = node_path.relative(rootPath, distPath), snapshot = {
5184
+ let relativeDistPath = node_path.relative(rootPath, distPath), snapshot = saveSnapshot ? {
5186
5185
  files: {},
5187
5186
  totalSize: 0,
5188
5187
  totalGzipSize: 0
5189
- }, formatAsset = async (asset)=>{
5190
- let { size, filePath } = asset, gzippedSize = options.compressed && COMPRESSIBLE_REGEX.test(filePath) ? await gzipSize(asset.content) : null, normalizedPath = normalizeFilePath(filePath);
5191
- snapshot.files[normalizedPath] = {
5188
+ } : null, formatAsset = (filePath, size, gzippedSize)=>{
5189
+ let normalizedPath = '';
5190
+ (snapshot || showDiff) && (normalizedPath = normalizeFilePath(filePath), snapshot && (snapshot.files[normalizedPath] = {
5192
5191
  size,
5193
5192
  gzippedSize: gzippedSize ?? void 0
5194
- };
5193
+ }));
5195
5194
  let sizeLabel = calcFileSize(size), sizeLabelLength = sizeLabel.length, gzipSizeLabel = gzippedSize ? getAssetColor(gzippedSize)(calcFileSize(gzippedSize)) : null;
5196
5195
  if (showDiff) {
5197
5196
  let sizeData = previousSizes[environmentName]?.files[normalizedPath], sizeDiff = size - (sizeData?.size ?? 0);
@@ -5204,12 +5203,11 @@ async function printFileSizes(options, stats, rootPath, distPath, environmentNam
5204
5203
  isSignificantDiff(gzipDiff) && (gzipSizeLabel += ` ${formatDiff(gzipDiff).label}`);
5205
5204
  }
5206
5205
  }
5207
- let folder = node_path.join(relativeDistPath, node_path.dirname(filePath)), filename = node_path.basename(filePath), filenameLabel = color.dim(folder + node_path.sep) + (JS_REGEX.test(filename) ? color.cyan(filename) : filename.endsWith('.css') ? color.yellow(filename) : filename.endsWith('.html') ? color.green(filename) : color.magenta(filename)), filenameLength = (folder + node_path.sep + filename).length;
5206
+ let separatorIndex = filePath.lastIndexOf('/'), folderLabel = (-1 === separatorIndex ? node_path.join(relativeDistPath, '.') : node_path.join(relativeDistPath, filePath.slice(0, separatorIndex))) + node_path.sep, filename = -1 === separatorIndex ? filePath : filePath.slice(separatorIndex + 1);
5208
5207
  return {
5209
5208
  filePath,
5210
- filename,
5211
- filenameLabel,
5212
- filenameLength,
5209
+ filenameLabel: color.dim(folderLabel) + (JS_REGEX.test(filename) ? color.cyan(filename) : filename.endsWith('.css') ? color.yellow(filename) : filename.endsWith('.html') ? color.green(filename) : color.magenta(filename)),
5210
+ filenameLength: folderLabel.length + filename.length,
5213
5211
  size,
5214
5212
  sizeLabel,
5215
5213
  sizeLabelLength,
@@ -5217,21 +5215,21 @@ async function printFileSizes(options, stats, rootPath, distPath, environmentNam
5217
5215
  gzipSizeLabel
5218
5216
  };
5219
5217
  }, getAssets = async ()=>{
5220
- let assets = Object.entries(stats.compilation.assets).map(([assetName, value])=>{
5221
- let filePath = assetName.split('?')[0], content = value.source();
5222
- return {
5223
- filePath,
5224
- size: Buffer.byteLength(content),
5225
- content
5226
- };
5227
- }), exclude = options.exclude ?? excludeAsset, filteredAssets = assets.filter((asset)=>{
5228
- let publicAsset = {
5229
- name: asset.filePath,
5230
- size: asset.size
5231
- };
5232
- return !exclude(publicAsset) && (!options.include || options.include(publicAsset));
5233
- });
5234
- return (await Promise.all(filteredAssets.map((asset)=>formatAsset(asset)))).sort((a, b)=>a.size - b.size);
5218
+ let { exclude, include } = options, formattedAssets = [], compilationAssets = stats.compilation.assets;
5219
+ for (let assetName of Object.keys(compilationAssets)){
5220
+ let value = compilationAssets[assetName], filePath = getFilePath(assetName);
5221
+ if (!exclude && EXCLUDE_ASSET_REGEX.test(filePath)) continue;
5222
+ let content = options.compressed && isCompressible(filePath) ? value.source() : void 0, size = void 0 === content ? value.size() : Buffer.byteLength(content);
5223
+ if (exclude || include) {
5224
+ let publicAsset = {
5225
+ name: filePath,
5226
+ size
5227
+ };
5228
+ if (exclude?.(publicAsset) || include && !include(publicAsset)) continue;
5229
+ }
5230
+ void 0 === content ? formattedAssets.push(formatAsset(filePath, size, null)) : formattedAssets.push(gzipSize(content).then((gzippedSize)=>formatAsset(filePath, size, gzippedSize)));
5231
+ }
5232
+ return (await Promise.all(formattedAssets)).sort((a, b)=>a.size - b.size);
5235
5233
  }, assets = await getAssets();
5236
5234
  if (0 === assets.length) return {
5237
5235
  logs
@@ -5245,7 +5243,7 @@ async function printFileSizes(options, stats, rootPath, distPath, environmentNam
5245
5243
  totalGzipSize
5246
5244
  };
5247
5245
  })(assets, options.compressed);
5248
- snapshot.totalSize = totalSize, snapshot.totalGzipSize = totalGzipSize;
5246
+ snapshot && (snapshot.totalSize = totalSize, snapshot.totalGzipSize = totalGzipSize);
5249
5247
  let fileHeader = showDetail ? `File (${environmentName})` : '', { totalSizeTitle, totalSizeLabel, totalSizeLabelLength } = (()=>{
5250
5248
  if (!showTotal) return {
5251
5249
  totalSizeTitle: '',
@@ -5276,7 +5274,9 @@ async function printFileSizes(options, stats, rootPath, distPath, environmentNam
5276
5274
  totalGzipSize
5277
5275
  }) : null;
5278
5276
  if (showDetail) {
5279
- let maxFileLength = Math.max(...assets.map((asset)=>asset.filenameLength), showTotal ? totalSizeTitle.length : 0, fileHeader.length), maxSizeLength = Math.max(...assets.map((a)=>a.sizeLabelLength), totalSizeLabelLength), showGzipHeader = !!(options.compressed && assets.some((item)=>null !== item.gzippedSize));
5277
+ let maxFileLength = Math.max(showTotal ? totalSizeTitle.length : 0, fileHeader.length), maxSizeLength = totalSizeLabelLength, hasGzipSize = !1;
5278
+ for (let asset of assets)asset.filenameLength > maxFileLength && (maxFileLength = asset.filenameLength), asset.sizeLabelLength > maxSizeLength && (maxSizeLength = asset.sizeLabelLength), null !== asset.gzippedSize && (hasGzipSize = !0);
5279
+ let showGzipHeader = !!(options.compressed && hasGzipSize);
5280
5280
  for (let asset of (logs.push(getHeader(maxFileLength, maxSizeLength, fileHeader, showGzipHeader)), assets)){
5281
5281
  let { sizeLabel, filenameLabel } = asset, { sizeLabelLength, gzipSizeLabel, filenameLength } = asset;
5282
5282
  sizeLabelLength < maxSizeLength && (sizeLabel += ' '.repeat(maxSizeLength - sizeLabelLength)), filenameLength < maxFileLength && (filenameLabel += ' '.repeat(maxFileLength - filenameLength));
@@ -5460,9 +5460,12 @@ class RsbuildHtmlPlugin {
5460
5460
  let optPublicPath = tag.publicPath ?? tagConfig.publicPath;
5461
5461
  'function' == typeof optPublicPath ? filename = optPublicPath(filename, data.publicPath) : 'string' == typeof optPublicPath ? filename = ensureAssetPrefix(filename, optPublicPath) : !1 !== optPublicPath && (filename = ensureAssetPrefix(filename, data.publicPath));
5462
5462
  let optHash = tag.hash ?? tagConfig.hash;
5463
- 'function' == typeof optHash ? compilationHash.length && (filename = optHash(filename, compilationHash)) : 'string' == typeof optHash ? optHash.length && (filename = `${filename}?${optHash}`) : !0 === optHash && compilationHash.length && (filename = `${filename}?${compilationHash}`), attrs[filenameTag] = filename, tag.attrs = attrs;
5463
+ 'function' == typeof optHash ? compilationHash.length && (filename = optHash(filename, compilationHash)) : 'string' == typeof optHash ? optHash.length && (filename = `${filename}?${optHash}`) : !0 === optHash && compilationHash.length && (filename = `${filename}?${compilationHash}`), attrs[filenameTag] = filename;
5464
5464
  }
5465
- ret.push(fromBasicTag(tag));
5465
+ ret.push(fromBasicTag({
5466
+ ...tag,
5467
+ attrs
5468
+ }));
5466
5469
  }
5467
5470
  return ret;
5468
5471
  }, tags = [
@@ -5629,7 +5632,7 @@ let normalizeUrl = (url)=>url.replace(/([^:]\/)\/+/g, '$1'), formatPrefix = (inp
5629
5632
  if (prefix?.startsWith('./') && (prefix = prefix.replace('./', '')), !prefix) return '/';
5630
5633
  let hasLeadingSlash = prefix.startsWith('/'), hasTailSlash = prefix.endsWith('/');
5631
5634
  return `${hasLeadingSlash ? '' : '/'}${prefix}${hasTailSlash ? '' : '/'}`;
5632
- }, joinUrlPath = (basePath, pathname)=>'' === basePath ? pathname : '' === pathname ? basePath : addTrailingSlash(basePath) + pathname.replace(/^\/+/, ''), isUrlPathUnderBase = (pathname, base)=>{
5635
+ }, joinUrlPath = (basePath, pathname)=>'' === basePath ? pathname : '' === pathname ? basePath : addTrailingSlash(basePath) + pathname.replace(/^\/+/, ''), getMoreEntriesMessage = (moreEntries, cliShortcutsEnabled)=>cliShortcutsEnabled ? ` ${color.dim(`... ${moreEntries} more entries, press `)}${color.bold('u + enter')}${color.dim(' to show all')}\n` : ` ${color.dim(`... ${moreEntries} more entries, set `)}${color.bold('server.printUrls.maxRoutes')}${color.dim(' to show more')}\n`, isUrlPathUnderBase = (pathname, base)=>{
5633
5636
  let basePath = removeTailingSlash(base);
5634
5637
  return '' === basePath || pathname === basePath || pathname.startsWith(`${basePath}/`);
5635
5638
  }, removeBasePath = (url, base)=>{
@@ -5652,20 +5655,21 @@ let normalizeUrl = (url)=>url.replace(/([^:]\/)\/+/g, '$1'), formatPrefix = (inp
5652
5655
  pathname: prefix + ('index' === entryName && 'nested' !== outputStructure ? '' : entryName)
5653
5656
  })).sort((a)=>'index' === a.entryName ? -1 : 1);
5654
5657
  };
5655
- function getURLMessages(urls, routes) {
5656
- if (routes.length <= 1) {
5657
- let pathname = routes.length ? routes[0].pathname : '', padWidth = Math.max(Math.max(...urls.map((u)=>u.label.trimEnd().length)) + 2, 10);
5658
- return urls.map(({ label, url })=>{
5658
+ function getURLMessages(urls, routes, { maxRoutes = 10, showAllRoutes, cliShortcutsEnabled }) {
5659
+ let routeLimit = showAllRoutes ? 1 / 0 : void 0 === maxRoutes ? 10 : maxRoutes === 1 / 0 ? maxRoutes : Math.max(0, Math.floor(maxRoutes)), printableRoutes = 0 === routeLimit ? [] : routes.slice(0, routeLimit), moreEntries = routeLimit > 0 ? routes.length - printableRoutes.length : 0;
5660
+ if (routes.length <= 1 || 0 === printableRoutes.length) {
5661
+ let pathname = printableRoutes.length ? printableRoutes[0].pathname : '', padWidth = Math.max(Math.max(...urls.map((u)=>u.label.trimEnd().length)) + 2, 10), message = urls.map(({ label, url })=>{
5659
5662
  let normalizedPathname = normalizeUrl(`${url}${pathname}`), prefix = `➜ ${color.dim(label.trimEnd().padEnd(padWidth))}`;
5660
5663
  return ` ${prefix}${color.cyan(normalizedPathname)}\n`;
5661
5664
  }).join('');
5665
+ return moreEntries > 0 && (message += getMoreEntriesMessage(moreEntries, cliShortcutsEnabled)), message;
5662
5666
  }
5663
- let message = '', prevLabel = '', maxNameLength = Math.max(...routes.map((r)=>r.entryName.length));
5667
+ let message = '', prevLabel = '', maxNameLength = Math.max(...printableRoutes.map((r)=>r.entryName.length));
5664
5668
  return urls.forEach(({ label, url }, index)=>{
5665
- 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`;
5666
- }), message;
5669
+ for (let { entryName, pathname } of (prevLabel !== label && (index > 0 && (message += '\n'), message += ` ➜ ${label}\n`, prevLabel = label), printableRoutes))message += ` ${color.dim('-')} ${color.dim(entryName.padEnd(maxNameLength + 4))}${color.cyan(normalizeUrl(`${url}${pathname}`))}\n`;
5670
+ }), moreEntries > 0 && (message += getMoreEntriesMessage(moreEntries, cliShortcutsEnabled)), message;
5667
5671
  }
5668
- function printServerURLs({ urls: originalUrls, port, routes, protocol, printUrls, fallbackPathname, trailingLineBreak = !0, originalConfig, logger }) {
5672
+ function printServerURLs({ urls: originalUrls, port, routes, protocol, printUrls, fallbackPathname, showAllRoutes, cliShortcutsEnabled, originalConfig, logger }) {
5669
5673
  if (!1 === printUrls) return null;
5670
5674
  let urls = originalUrls, useCustomUrl = isFunction(printUrls);
5671
5675
  if (useCustomUrl) {
@@ -5695,8 +5699,12 @@ function printServerURLs({ urls: originalUrls, port, routes, protocol, printUrls
5695
5699
  }
5696
5700
  ];
5697
5701
  if (0 === printableRoutes.length && !useCustomUrl) return null;
5698
- let message = getURLMessages(urls, printableRoutes);
5699
- 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;
5702
+ let printUrlsOptions = printUrls && 'object' == typeof printUrls ? printUrls : {}, message = getURLMessages(urls, printableRoutes, {
5703
+ maxRoutes: useCustomUrl ? 1 / 0 : printUrlsOptions.maxRoutes,
5704
+ showAllRoutes,
5705
+ cliShortcutsEnabled
5706
+ });
5707
+ return originalConfig && originalConfig.server?.host === void 0 && (message += ` ➜ ${color.dim('Network:')} ${color.dim('use')} ${color.bold('--host')} ${color.dim('to expose')}\n`), !0 === cliShortcutsEnabled && message.endsWith('\n') && (message = message.slice(0, -1)), logger.log(message), message;
5700
5708
  }
5701
5709
  let getPort = async ({ host, port, strictPort, tryLimits = 20 })=>{
5702
5710
  'string' == typeof port && (port = Number.parseInt(port, 10)), strictPort && (tryLimits = 1);
@@ -6694,7 +6702,7 @@ function createAssetsMiddleware(context, ready, outputFileSystem) {
6694
6702
  }
6695
6703
  async function setupOutputFileSystem(writeToDisk, compilers) {
6696
6704
  if (!0 !== writeToDisk) {
6697
- let { createFsFromVolume, Volume } = await import("./memfs.js").then(__webpack_require__.t.bind(__webpack_require__, "../../node_modules/.pnpm/memfs@4.57.7/node_modules/memfs/lib/index.js", 23)), outputFileSystem = createFsFromVolume(new Volume());
6705
+ let { createFsFromVolume, Volume } = await import("./memfs.js").then(__webpack_require__.t.bind(__webpack_require__, "../../node_modules/.pnpm/memfs@4.57.8/node_modules/memfs/lib/index.js", 23)), outputFileSystem = createFsFromVolume(new Volume());
6698
6706
  for (let compiler of compilers)compiler.outputFileSystem = outputFileSystem;
6699
6707
  }
6700
6708
  let compiler = compilers.find((compiler)=>!!compiler.outputFileSystem);
@@ -7066,9 +7074,9 @@ function convertLinksInHtml(text, root) {
7066
7074
  }).join('\n');
7067
7075
  }
7068
7076
  function isEqualSet(a, b) {
7069
- return a.size === b.size && [
7070
- ...a
7071
- ].every((value)=>b.has(value));
7077
+ if (a.size !== b.size) return !1;
7078
+ for (let value of a)if (!b.has(value)) return !1;
7079
+ return !0;
7072
7080
  }
7073
7081
  let parseQueryString = (req)=>{
7074
7082
  let queryStr = req.url ? req.url.split('?')[1] : '';
@@ -7103,7 +7111,7 @@ class SocketServer {
7103
7111
  }
7104
7112
  async prepare() {
7105
7113
  this.clearHeartbeatTimer();
7106
- let { WebSocketServer } = await import("./ws.js");
7114
+ let { WebSocketServer } = await import("./wrapper.js");
7107
7115
  this.wsServer = new WebSocketServer({
7108
7116
  noServer: !0,
7109
7117
  path: this.options.client?.path
@@ -7208,11 +7216,15 @@ class SocketServer {
7208
7216
  return this.context.environmentList.find(({ webSocketToken })=>webSocketToken === token);
7209
7217
  }
7210
7218
  getInitialChunks(stats) {
7211
- let initialChunks = new Set();
7212
- if (!stats.entrypoints) return initialChunks;
7213
- for (let entrypoint of Object.values(stats.entrypoints)){
7214
- let { chunks } = entrypoint;
7215
- if (Array.isArray(chunks)) for (let chunkName of chunks)chunkName && initialChunks.add(String(chunkName));
7219
+ let initialChunks = new Set(), { entrypoints } = stats;
7220
+ if (!entrypoints) return initialChunks;
7221
+ let entryNames = Object.keys(entrypoints);
7222
+ for(let entryIndex = 0; entryIndex < entryNames.length; entryIndex++){
7223
+ let chunks = entrypoints[entryNames[entryIndex]]?.chunks;
7224
+ if (Array.isArray(chunks)) for(let index = 0; index < chunks.length; index++){
7225
+ let chunkName = chunks[index];
7226
+ void 0 !== chunkName && initialChunks.add('string' == typeof chunkName ? chunkName : String(chunkName));
7227
+ }
7216
7228
  }
7217
7229
  return initialChunks;
7218
7230
  }
@@ -7338,7 +7350,9 @@ async function setupCliShortcuts({ help = !0, openPage, closeServer, printUrls,
7338
7350
  {
7339
7351
  key: 'u',
7340
7352
  description: `${color.bold('u + enter')} ${color.dim('show urls')}`,
7341
- action: printUrls
7353
+ action: ()=>printUrls({
7354
+ showAllRoutes: !0
7355
+ })
7342
7356
  }
7343
7357
  ].filter(Boolean);
7344
7358
  if (customShortcuts && !Array.isArray(shortcuts = customShortcuts(shortcuts))) throw Error(`${color.dim('[rsbuild:config]')} ${color.yellow('dev.cliShortcuts')} option must return an array of shortcuts.`);
@@ -7687,7 +7701,7 @@ let applyDefaultMiddlewares = async ({ config, buildManager, context, devServer,
7687
7701
  ],
7688
7702
  outputFileSystem: buildManager.outputFileSystem
7689
7703
  })), server.publicDir.length) {
7690
- let { default: sirv } = await import("./sirv.js");
7704
+ let { default: sirv } = await import("./build.js");
7691
7705
  for (let { name } of server.publicDir){
7692
7706
  let sirvMiddleware = sirv(name, {
7693
7707
  etag: !0,
@@ -8138,14 +8152,15 @@ async function devServer_createDevServer(options, createCompiler, config, { getP
8138
8152
  protocol,
8139
8153
  port,
8140
8154
  host
8141
- }), cliShortcutsEnabled = isCliShortcutsEnabled(config), printUrls = ()=>printServerURLs({
8155
+ }), cliShortcutsEnabled = isCliShortcutsEnabled(config), printUrls = (options)=>printServerURLs({
8142
8156
  urls,
8143
8157
  port,
8144
8158
  routes,
8145
8159
  protocol,
8146
8160
  printUrls: config.server.printUrls,
8147
8161
  fallbackPathname,
8148
- trailingLineBreak: !cliShortcutsEnabled,
8162
+ showAllRoutes: options?.showAllRoutes,
8163
+ cliShortcutsEnabled,
8149
8164
  originalConfig: context.originalConfig,
8150
8165
  logger
8151
8166
  }), openPage = async ()=>open_open({
@@ -8288,13 +8303,14 @@ async function startPreviewServer(context, config, { getPortSilently } = {}) {
8288
8303
  middlewares
8289
8304
  }), cleanupGracefulShutdown = setupGracefulShutdown(), serverTerminator = getServerTerminator(httpServer), closingPromise = null, closeServer = async ()=>(closingPromise || (closingPromise = (async ()=>{
8290
8305
  removeCleanup(closeServer), cleanupGracefulShutdown(), await serverTerminator();
8291
- })()), closingPromise), printUrls = ()=>printServerURLs({
8306
+ })()), closingPromise), printUrls = (options)=>printServerURLs({
8292
8307
  urls,
8293
8308
  port,
8294
8309
  routes,
8295
8310
  protocol,
8296
8311
  printUrls: serverConfig.printUrls,
8297
- trailingLineBreak: !cliShortcutsEnabled,
8312
+ showAllRoutes: options?.showAllRoutes,
8313
+ cliShortcutsEnabled,
8298
8314
  originalConfig: context.originalConfig,
8299
8315
  logger
8300
8316
  }), openPage = async ()=>open_open({
@@ -8393,7 +8409,10 @@ function applyDefaultPlugins(pluginManager, context) {
8393
8409
  level: 'error'
8394
8410
  }), chain.watchOptions({
8395
8411
  aggregateTimeout: 0
8396
- }), chain.performance.hints(!1), chain.module.parser.merge({
8412
+ }), chain.performance.hints(!1), chain.experiments({
8413
+ ...chain.get('experiments'),
8414
+ sourceImport: !0
8415
+ }), chain.module.parser.merge({
8397
8416
  javascript: {
8398
8417
  typeReexportsPresence: 'tolerant'
8399
8418
  }
@@ -8635,7 +8654,7 @@ function applyDefaultPlugins(pluginManager, context) {
8635
8654
  ...defaultConfig,
8636
8655
  ...printFileSize
8637
8656
  };
8638
- })(config), statsItem, api.context.rootPath, distPath, name, prevSnapshots);
8657
+ })(config), statsItem, api.context.rootPath, distPath, name, prevSnapshots, showDiff);
8639
8658
  return snapshot && (nextSnapshots[name] = snapshot), sizeLogs.join('\n');
8640
8659
  })).catch((err)=>{
8641
8660
  api.logger.warn('Failed to print file size.'), api.logger.warn(err);
@@ -9470,7 +9489,7 @@ try {
9470
9489
  api.modifyBundlerChain(async (chain, { CHAIN_ID, environment, isDev })=>{
9471
9490
  let { output: { manifest }, dev: { writeToDisk } } = environment.config;
9472
9491
  if (!1 === manifest) return;
9473
- let manifestOptions = normalizeManifestObjectConfig(manifest), { RspackManifestPlugin } = await import("./manifest-plugin.js").then(__webpack_require__.bind(__webpack_require__, "../../node_modules/.pnpm/rspack-manifest-plugin@5.2.2_@rspack+core@2.0.8/node_modules/rspack-manifest-plugin/dist/index.js")), { htmlPaths } = environment, filter = manifestOptions.filter ?? ((file)=>!file.name.endsWith('.LICENSE.txt'));
9492
+ let manifestOptions = normalizeManifestObjectConfig(manifest), { RspackManifestPlugin } = await import("./rspack-manifest-plugin.js").then(__webpack_require__.bind(__webpack_require__, "../../node_modules/.pnpm/rspack-manifest-plugin@5.2.2_@rspack+core@2.1.0-rc.0/node_modules/rspack-manifest-plugin/dist/index.js")), { htmlPaths } = environment, filter = manifestOptions.filter ?? ((file)=>!file.name.endsWith('.LICENSE.txt'));
9474
9493
  manifestFilenames.set(environment.name, manifestOptions.filename);
9475
9494
  let pluginOptions = {
9476
9495
  fileName: manifestOptions.filename,
@@ -10005,7 +10024,7 @@ let applyServerOptions = (command)=>{
10005
10024
  };
10006
10025
  function setupCommands() {
10007
10026
  let cli = ((name = "")=>new CAC(name))('rsbuild');
10008
- cli.version("2.0.15"), 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)', {
10027
+ cli.version("2.1.0-rc.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)', {
10009
10028
  default: 'auto'
10010
10029
  }).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', {
10011
10030
  type: [
@@ -10076,7 +10095,7 @@ function initNodeEnv(command) {
10076
10095
  }
10077
10096
  function showGreeting() {
10078
10097
  let { npm_execpath, npm_lifecycle_event, NODE_RUN_SCRIPT_NAME } = process.env, isBun = npm_execpath?.includes('.bun');
10079
- src_logger.greet(`${'npx' === npm_lifecycle_event || isBun || NODE_RUN_SCRIPT_NAME ? '\n' : ''}Rsbuild v2.0.15\n`);
10098
+ src_logger.greet(`${'npx' === npm_lifecycle_event || isBun || NODE_RUN_SCRIPT_NAME ? '\n' : ''}Rsbuild v2.1.0-rc.0\n`);
10080
10099
  }
10081
10100
  function setupLogLevel() {
10082
10101
  if (cli_argv.length <= 3) return;
@@ -10098,5 +10117,5 @@ function runCLI() {
10098
10117
  src_logger.error('Failed to start Rsbuild CLI.'), src_logger.error(err), process.exit(1);
10099
10118
  }
10100
10119
  }
10101
- let src_version = "2.0.15";
10120
+ let src_version = "2.1.0-rc.0";
10102
10121
  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, mrmime_lookup, runCLI, src_logger as logger, src_version as version };
@@ -2673,8 +2673,9 @@ let Debug = __webpack_require__("../../node_modules/.pnpm/debug@4.4.3/node_modul
2673
2673
  };
2674
2674
  function getStatusCode(errorCode) {
2675
2675
  let statusCode;
2676
- if (/HPE_INVALID/.test(errorCode)) statusCode = 502;
2677
- else switch(errorCode){
2676
+ if (/HPE_INVALID/.test(errorCode)) return 502;
2677
+ if (/HPM_ERR_INVALID_MULTIPART_/.test(errorCode)) return 400;
2678
+ switch(errorCode){
2678
2679
  case 'ECONNRESET':
2679
2680
  case 'ENOTFOUND':
2680
2681
  case 'ECONNREFUSED':