@rsbuild/core 2.2.4 → 2.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -43,24 +43,45 @@ type LoadConfigOptions<Params extends unknown[] = []> = {
43
43
  */
44
44
  fresh?: boolean;
45
45
  };
46
+ type ConfigFileMeta = {
47
+ /**
48
+ * Absolute path of the actual configuration file.
49
+ * Use `null` when no underlying configuration file was found.
50
+ */
51
+ filePath: string | null;
52
+ /**
53
+ * Absolute paths of additional configuration dependencies.
54
+ * These are merged with the adapter file and its collected dependencies.
55
+ */
56
+ dependencies?: readonly string[];
57
+ };
46
58
  type LoadConfigResult<Config = unknown> = {
47
59
  /**
48
60
  * The loaded configuration object.
49
61
  */
50
62
  content: Config;
51
63
  /**
52
- * The path to the loaded configuration file.
53
- * Return `null` if the configuration file is not found.
64
+ * The path to the loaded configuration file, or the source set by `withConfigMeta`.
65
+ * Returns `null` if no configuration file was found, including an explicit
66
+ * `null` source set by `withConfigMeta`.
54
67
  */
55
68
  filePath: string | null;
56
69
  /**
57
- * Absolute file paths of statically imported (relative) dependencies of the
58
- * config file.
70
+ * Absolute paths of collected configuration dependencies. When `withConfigMeta`
71
+ * is used, also includes explicit dependencies and the loaded adapter file,
72
+ * with duplicates removed.
59
73
  */
60
74
  dependencies: string[];
61
75
  };
62
76
 
77
+ /**
78
+ * Attach file metadata in place and return the original configuration object.
79
+ * Repeated calls replace the metadata. Requires an extensible, unfrozen object.
80
+ * Call this after merging the config: object spread does not preserve metadata.
81
+ */
82
+ declare function withConfigMeta<Config extends object>(config: Config, meta: ConfigFileMeta): Config;
83
+
63
84
  declare function loadConfig<Config = unknown, Params extends unknown[] = []>({ cwd, path, configFileNames, loader, exportName, configParams, fresh, }?: LoadConfigOptions<Params>): Promise<LoadConfigResult<Config>>;
64
85
 
65
- export { loadConfig };
66
- export type { ConfigDefinition, ConfigLoader, LoadConfigOptions, LoadConfigResult };
86
+ export { loadConfig, withConfigMeta };
87
+ export type { ConfigDefinition, ConfigFileMeta, ConfigLoader, LoadConfigOptions, LoadConfigResult };
@@ -1 +1 @@
1
- {"name":"@rstackjs/load-config","version":"0.1.2","license":"MIT","types":"index.d.ts","type":"module"}
1
+ {"name":"@rstackjs/load-config","version":"1.0.0","license":"MIT","types":"index.d.ts","type":"module"}
package/dist/626.js CHANGED
@@ -3425,7 +3425,7 @@ function createPublicContext(context) {
3425
3425
  async function createContext(options, userConfig, logger, loadConfigResult) {
3426
3426
  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, hooks = initHooks();
3427
3427
  return {
3428
- version: "2.2.4",
3428
+ version: "2.2.5",
3429
3429
  rootPath,
3430
3430
  configFile: loadConfigResult?.filePath ?? userConfig._privateMeta?.configFilePath,
3431
3431
  configFileDependencies: loadConfigResult?.dependencies ?? userConfig._privateMeta?.configFileDependencies ?? [],
@@ -5261,11 +5261,36 @@ function pluginExternals() {
5261
5261
  }
5262
5262
  };
5263
5263
  }
5264
- async function gzipSize(input) {
5264
+ function getCompression(compressed) {
5265
+ let { type = 'gzip', level = 6 } = 'object' == typeof compressed ? compressed : {};
5266
+ return 'brotli' === type ? {
5267
+ type,
5268
+ level,
5269
+ header: 'Br',
5270
+ label: 'brotli',
5271
+ sizeKey: 'brotliSize',
5272
+ totalKey: 'totalBrotliSize'
5273
+ } : {
5274
+ type,
5275
+ level,
5276
+ header: 'Gzip',
5277
+ label: 'gzipped',
5278
+ sizeKey: 'gzippedSize',
5279
+ totalKey: 'totalGzipSize'
5280
+ };
5281
+ }
5282
+ async function calcCompressedSize(input, type, level) {
5265
5283
  return (await new Promise((resolve, reject)=>{
5266
- node_zlib.gzip(input, (err, result)=>{
5284
+ let callback = (err, result)=>{
5267
5285
  err ? reject(err) : resolve(result);
5268
- });
5286
+ };
5287
+ 'brotli' === type ? node_zlib.brotliCompress(input, {
5288
+ params: {
5289
+ [node_zlib.constants.BROTLI_PARAM_QUALITY]: level
5290
+ }
5291
+ }, callback) : node_zlib.gzip(input, {
5292
+ level
5293
+ }, callback);
5269
5294
  })).length;
5270
5295
  }
5271
5296
  function getSnapshotPath(dir, snapshotHash) {
@@ -5298,7 +5323,7 @@ let EXCLUDE_ASSET_REGEX = /\.(?:map|LICENSE\.txt|d\.(?:ts|mts|cts))$/, isSignifi
5298
5323
  length: label.length
5299
5324
  };
5300
5325
  }, getAssetColor = (size)=>size > 300000 ? color.red : size > 100000 ? color.yellow : (input)=>input;
5301
- function getHeader(maxFileLength, maxSizeLength, fileHeader, showGzipHeader) {
5326
+ function getHeader(maxFileLength, maxSizeLength, fileHeader, compressionHeader) {
5302
5327
  let lengths = [
5303
5328
  maxFileLength,
5304
5329
  maxSizeLength
@@ -5306,7 +5331,7 @@ function getHeader(maxFileLength, maxSizeLength, fileHeader, showGzipHeader) {
5306
5331
  fileHeader,
5307
5332
  'Size'
5308
5333
  ];
5309
- showGzipHeader && rowTypes.push('Gzip');
5334
+ compressionHeader && rowTypes.push(compressionHeader);
5310
5335
  let headerRow = rowTypes.reduce((prev, cur, index)=>{
5311
5336
  let length = lengths[index], curLabel = cur;
5312
5337
  return length && (curLabel = cur.length < length ? cur + ' '.repeat(length - cur.length) : cur), `${prev + curLabel} `;
@@ -5321,30 +5346,31 @@ let calcFileSize = (len)=>{
5321
5346
  return -1 === queryIndex ? assetName : assetName.slice(0, queryIndex);
5322
5347
  };
5323
5348
  async function printFileSizes(options, stats, rootPath, distPath, environmentName, previousSizes, saveSnapshot) {
5324
- let logs = [], showDetail = !1 !== options.detail, showDiff = !1 !== options.diff && null !== previousSizes, showTotal = !1 !== options.total;
5349
+ let logs = [], compression = getCompression(options.compressed), prev = previousSizes?.[environmentName], showDetail = !1 !== options.detail, showDiff = !1 !== options.diff && null !== previousSizes, prevType = prev?.compressionType ?? (!!prev?.totalGzipSize && 'gzip'), showCompressedDiff = showDiff && prevType === compression.type, showTotal = !1 !== options.total;
5325
5350
  if (!showTotal && !showDetail) return {
5326
5351
  logs
5327
5352
  };
5328
5353
  let relativeDistPath = node_path.relative(rootPath, distPath), rootFolderLabel = `${relativeDistPath || '.'}${node_path.sep}`, snapshot = saveSnapshot ? {
5329
5354
  files: {},
5330
5355
  totalSize: 0,
5331
- totalGzipSize: 0
5332
- } : null, formatAsset = (filePath, size, gzippedSize)=>{
5356
+ totalGzipSize: 0,
5357
+ compressionType: !!options.compressed && compression.type
5358
+ } : null, formatAsset = (filePath, size, compressedSize)=>{
5333
5359
  let normalizedPath = '';
5334
5360
  (snapshot || showDiff) && (normalizedPath = normalizeFilePath(filePath), snapshot && (snapshot.files[normalizedPath] = {
5335
5361
  size,
5336
- gzippedSize: gzippedSize ?? void 0
5362
+ [compression.sizeKey]: compressedSize ?? void 0
5337
5363
  }));
5338
- let sizeLabel = calcFileSize(size), sizeLabelLength = sizeLabel.length, gzipSizeLabel = gzippedSize ? getAssetColor(gzippedSize)(calcFileSize(gzippedSize)) : null;
5364
+ let sizeLabel = calcFileSize(size), sizeLabelLength = sizeLabel.length, compressedSizeLabel = compressedSize ? getAssetColor(compressedSize)(calcFileSize(compressedSize)) : null;
5339
5365
  if (showDiff) {
5340
- let sizeData = previousSizes[environmentName]?.files[normalizedPath], sizeDiff = size - (sizeData?.size ?? 0);
5366
+ let sizeData = prev?.files[normalizedPath], sizeDiff = size - (sizeData?.size ?? 0);
5341
5367
  if (isSignificantDiff(sizeDiff)) {
5342
5368
  let { label, length } = formatDiff(sizeDiff);
5343
5369
  sizeLabel += ` ${label}`, sizeLabelLength += length + 1;
5344
5370
  }
5345
- if (null !== gzippedSize) {
5346
- let gzipDiff = gzippedSize - (sizeData?.gzippedSize ?? 0);
5347
- isSignificantDiff(gzipDiff) && (gzipSizeLabel += ` ${formatDiff(gzipDiff).label}`);
5371
+ if (null !== compressedSize && showCompressedDiff) {
5372
+ let compressedDiff = compressedSize - (sizeData?.[compression.sizeKey] ?? 0);
5373
+ isSignificantDiff(compressedDiff) && (compressedSizeLabel += ` ${formatDiff(compressedDiff).label}`);
5348
5374
  }
5349
5375
  }
5350
5376
  let separatorIndex = filePath.lastIndexOf('/'), folderLabel = -1 === separatorIndex ? rootFolderLabel : `${node_path.join(relativeDistPath, filePath.slice(0, separatorIndex))}${node_path.sep}`, filename = -1 === separatorIndex ? filePath : filePath.slice(separatorIndex + 1);
@@ -5355,8 +5381,8 @@ async function printFileSizes(options, stats, rootPath, distPath, environmentNam
5355
5381
  size,
5356
5382
  sizeLabel,
5357
5383
  sizeLabelLength,
5358
- gzippedSize,
5359
- gzipSizeLabel
5384
+ compressedSize,
5385
+ compressedSizeLabel
5360
5386
  };
5361
5387
  }, getAssets = async ()=>{
5362
5388
  let { exclude, include } = options, formattedAssets = [], compilationAssets = stats.compilation.assets;
@@ -5371,7 +5397,7 @@ async function printFileSizes(options, stats, rootPath, distPath, environmentNam
5371
5397
  };
5372
5398
  if (exclude?.(publicAsset) || include && !include(publicAsset)) continue;
5373
5399
  }
5374
- void 0 === content ? formattedAssets.push(formatAsset(filePath, size, null)) : formattedAssets.push(gzipSize(content).then((gzippedSize)=>formatAsset(filePath, size, gzippedSize)));
5400
+ void 0 === content ? formattedAssets.push(formatAsset(filePath, size, null)) : formattedAssets.push(calcCompressedSize(content, compression.type, compression.level).then((compressedSize)=>formatAsset(filePath, size, compressedSize)));
5375
5401
  }
5376
5402
  return (await Promise.all(formattedAssets)).sort((a, b)=>a.size - b.size);
5377
5403
  }, assets = await getAssets();
@@ -5379,15 +5405,15 @@ async function printFileSizes(options, stats, rootPath, distPath, environmentNam
5379
5405
  logs
5380
5406
  };
5381
5407
  logs.push(''), showDetail && 1 === assets.length && (showTotal = !1);
5382
- let { totalSize, totalGzipSize } = ((assets, compressed)=>{
5383
- let totalSize = 0, totalGzipSize = 0;
5384
- for (let { size, gzippedSize } of assets)totalSize += size, compressed && (totalGzipSize += gzippedSize ?? size);
5408
+ let { totalSize, totalCompressedSize } = ((assets, compressed)=>{
5409
+ let totalSize = 0, totalCompressedSize = 0;
5410
+ for (let { size, compressedSize } of assets)totalSize += size, compressed && (totalCompressedSize += compressedSize ?? size);
5385
5411
  return {
5386
5412
  totalSize,
5387
- totalGzipSize
5413
+ totalCompressedSize
5388
5414
  };
5389
- })(assets, options.compressed);
5390
- snapshot && (snapshot.totalSize = totalSize, snapshot.totalGzipSize = totalGzipSize);
5415
+ })(assets, !!options.compressed);
5416
+ snapshot && (snapshot.totalSize = totalSize, options.compressed && (snapshot[compression.totalKey] = totalCompressedSize));
5391
5417
  let fileHeader = showDetail ? `File (${environmentName})` : '', { totalSizeTitle, totalSizeLabel, totalSizeLabelLength } = (()=>{
5392
5418
  if (!showTotal) return {
5393
5419
  totalSizeTitle: '',
@@ -5396,7 +5422,7 @@ async function printFileSizes(options, stats, rootPath, distPath, environmentNam
5396
5422
  };
5397
5423
  let totalSizeTitle = showDetail ? 'Total:' : `Total size (${environmentName}):`, totalSizeLabel = calcFileSize(totalSize), totalSizeLabelLength = totalSizeLabel.length;
5398
5424
  if (showDiff) {
5399
- let totalSizeDiff = totalSize - (previousSizes[environmentName]?.totalSize ?? 0);
5425
+ let totalSizeDiff = totalSize - (prev?.totalSize ?? 0);
5400
5426
  if (isSignificantDiff(totalSizeDiff)) {
5401
5427
  let { label, length } = formatDiff(totalSizeDiff);
5402
5428
  totalSizeLabel += ` ${label}`, totalSizeLabelLength += length + 1;
@@ -5407,7 +5433,11 @@ async function printFileSizes(options, stats, rootPath, distPath, environmentNam
5407
5433
  totalSizeLabel,
5408
5434
  totalSizeLabelLength
5409
5435
  };
5410
- })(), getCustomTotal = ()=>'function' == typeof options.total ? options.total({
5436
+ })(), getCompressedTotalDiff = ()=>{
5437
+ if (!showCompressedDiff) return '';
5438
+ let diff = totalCompressedSize - (prev?.[compression.totalKey] ?? 0);
5439
+ return isSignificantDiff(diff) ? ` ${formatDiff(diff).label}` : '';
5440
+ }, getCustomTotal = ()=>'function' == typeof options.total ? options.total({
5411
5441
  environmentName,
5412
5442
  distPath: relativeDistPath,
5413
5443
  assets: assets.map((asset)=>({
@@ -5415,17 +5445,18 @@ async function printFileSizes(options, stats, rootPath, distPath, environmentNam
5415
5445
  size: asset.size
5416
5446
  })),
5417
5447
  totalSize,
5418
- totalGzipSize
5448
+ totalGzipSize: 'gzip' === compression.type ? totalCompressedSize : 0,
5449
+ totalBrotliSize: options.compressed && 'brotli' === compression.type ? totalCompressedSize : void 0
5419
5450
  }) : null;
5420
5451
  if (showDetail) {
5421
- let maxFileLength = Math.max(showTotal ? totalSizeTitle.length : 0, fileHeader.length), maxSizeLength = totalSizeLabelLength, hasGzipSize = !1;
5422
- for (let asset of assets)asset.filenameLength > maxFileLength && (maxFileLength = asset.filenameLength), asset.sizeLabelLength > maxSizeLength && (maxSizeLength = asset.sizeLabelLength), null !== asset.gzippedSize && (hasGzipSize = !0);
5423
- let showGzipHeader = !!(options.compressed && hasGzipSize);
5424
- for (let asset of (logs.push(getHeader(maxFileLength, maxSizeLength, fileHeader, showGzipHeader)), assets)){
5425
- let { sizeLabel, filenameLabel } = asset, { sizeLabelLength, gzipSizeLabel, filenameLength } = asset;
5452
+ let maxFileLength = Math.max(showTotal ? totalSizeTitle.length : 0, fileHeader.length), maxSizeLength = totalSizeLabelLength, hasCompressedSize = !1;
5453
+ for (let asset of assets)asset.filenameLength > maxFileLength && (maxFileLength = asset.filenameLength), asset.sizeLabelLength > maxSizeLength && (maxSizeLength = asset.sizeLabelLength), null !== asset.compressedSize && (hasCompressedSize = !0);
5454
+ let showCompressedHeader = !!(options.compressed && hasCompressedSize);
5455
+ for (let asset of (logs.push(getHeader(maxFileLength, maxSizeLength, fileHeader, showCompressedHeader && compression.header)), assets)){
5456
+ let { sizeLabel, filenameLabel } = asset, { sizeLabelLength, compressedSizeLabel, filenameLength } = asset;
5426
5457
  sizeLabelLength < maxSizeLength && (sizeLabel += ' '.repeat(maxSizeLength - sizeLabelLength)), filenameLength < maxFileLength && (filenameLabel += ' '.repeat(maxFileLength - filenameLength));
5427
5458
  let log = `${filenameLabel} ${sizeLabel}`;
5428
- gzipSizeLabel && (log += ` ${gzipSizeLabel}`), logs.push(log);
5459
+ compressedSizeLabel && (log += ` ${compressedSizeLabel}`), logs.push(log);
5429
5460
  }
5430
5461
  if (showTotal) {
5431
5462
  logs.push('');
@@ -5434,11 +5465,8 @@ async function printFileSizes(options, stats, rootPath, distPath, environmentNam
5434
5465
  else {
5435
5466
  let log = '';
5436
5467
  if (log += ' '.repeat(maxFileLength - totalSizeTitle.length), log += color.magenta(totalSizeTitle), log += ` ${totalSizeLabel}`, options.compressed) {
5437
- let colorFn = getAssetColor(totalGzipSize / assets.length);
5438
- if (log += ' '.repeat(maxSizeLength - totalSizeLabelLength), log += ` ${colorFn(calcFileSize(totalGzipSize))}`, showDiff) {
5439
- let totalGzipSizeDiff = totalGzipSize - (previousSizes[environmentName]?.totalGzipSize ?? 0);
5440
- isSignificantDiff(totalGzipSizeDiff) && (log += ` ${formatDiff(totalGzipSizeDiff).label}`);
5441
- }
5468
+ let colorFn = getAssetColor(totalCompressedSize / assets.length);
5469
+ log += ' '.repeat(maxSizeLength - totalSizeLabelLength), log += ` ${colorFn(calcFileSize(totalCompressedSize))}${getCompressedTotalDiff()}`;
5442
5470
  }
5443
5471
  logs.push(log);
5444
5472
  }
@@ -5448,7 +5476,7 @@ async function printFileSizes(options, stats, rootPath, distPath, environmentNam
5448
5476
  if (customTotal) logs.push(customTotal);
5449
5477
  else {
5450
5478
  let log = `${color.magenta(totalSizeTitle)} ${totalSizeLabel}`;
5451
- options.compressed && (log += color.green(` (${calcFileSize(totalGzipSize)} gzipped)`)), logs.push(log);
5479
+ options.compressed && (log += color.green(` (${calcFileSize(totalCompressedSize)}${getCompressedTotalDiff()} ${compression.label})`)), logs.push(log);
5452
5480
  }
5453
5481
  }
5454
5482
  return logs.push(''), {
@@ -10068,7 +10096,11 @@ let canReadExport = (module)=>null !== module && ('object' == typeof module || '
10068
10096
  configExport: getConfigExport(await jiti.import(configPath), exportName, configPath),
10069
10097
  dependencies: []
10070
10098
  };
10071
- }, JS_CONFIG_REGEXP = /\.(?:js|mjs|cjs)$/, loadWithNative = async (configPath, fresh)=>{
10099
+ }, CONFIG_META = Symbol.for('@rstackjs/load-config/meta');
10100
+ function getConfigMeta(config) {
10101
+ if (null !== config && 'object' == typeof config && Object.hasOwn(config, CONFIG_META)) return config[CONFIG_META];
10102
+ }
10103
+ let JS_CONFIG_REGEXP = /\.(?:js|mjs|cjs)$/, loadWithNative = async (configPath, fresh)=>{
10072
10104
  let configFileURL = pathToFileURL(configPath).href;
10073
10105
  if (!fresh) return {
10074
10106
  configModule: await import(configFileURL),
@@ -10084,7 +10116,7 @@ let canReadExport = (module)=>null !== module && ('object' == typeof module || '
10084
10116
  };
10085
10117
  };
10086
10118
  async function dist_loadConfig({ cwd = process.cwd(), path, configFileNames = [], loader = 'auto', exportName = 'default', configParams = [], fresh = !1 } = {}) {
10087
- let loadedConfig;
10119
+ let loadedConfig, content;
10088
10120
  if (!path && 0 === configFileNames.length) throw Error('Either `path` or at least one `configFileNames` entry must be provided.');
10089
10121
  let configPath = ((root, customConfig, configFileNames = [])=>{
10090
10122
  if (customConfig) {
@@ -10120,17 +10152,20 @@ async function dist_loadConfig({ cwd = process.cwd(), path, configFileNames = []
10120
10152
  if ('function' == typeof configExport) {
10121
10153
  let result = await configExport(...configParams);
10122
10154
  if (void 0 === result) throw Error('The config function must return a config object.');
10123
- return {
10124
- content: result,
10125
- filePath: configPath,
10126
- dependencies
10127
- };
10128
- }
10129
- return {
10130
- content: configExport,
10155
+ content = result;
10156
+ } else content = configExport;
10157
+ let meta = getConfigMeta(content), result = {
10158
+ content,
10131
10159
  filePath: configPath,
10132
10160
  dependencies
10133
10161
  };
10162
+ return meta && (result.filePath = meta.filePath, result.dependencies = [
10163
+ ...new Set([
10164
+ ...meta.dependencies ?? [],
10165
+ configPath,
10166
+ ...dependencies
10167
+ ])
10168
+ ]), result;
10134
10169
  }
10135
10170
  function defineConfig(config) {
10136
10171
  return config;
@@ -10226,7 +10261,7 @@ let applyServerOptions = (command)=>{
10226
10261
  };
10227
10262
  function setupCommands(argv) {
10228
10263
  let cli = ((name = "")=>new CAC(name))('rsbuild');
10229
- cli.version("2.2.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)', {
10264
+ cli.version("2.2.5"), 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)', {
10230
10265
  default: 'auto'
10231
10266
  }).option('--dist-path <dir>', 'Set the root directory of output files').option('--source-map', 'Enable source map').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', {
10232
10267
  type: [
@@ -10291,7 +10326,7 @@ function setupCommands(argv) {
10291
10326
  }
10292
10327
  function showGreeting() {
10293
10328
  let { npm_execpath, npm_lifecycle_event, NODE_RUN_SCRIPT_NAME } = process.env, isBun = npm_execpath?.includes('.bun');
10294
- src_logger.greet(`${'npx' === npm_lifecycle_event || isBun || NODE_RUN_SCRIPT_NAME ? '\n' : ''}Rsbuild v2.2.4\n`);
10329
+ src_logger.greet(`${'npx' === npm_lifecycle_event || isBun || NODE_RUN_SCRIPT_NAME ? '\n' : ''}Rsbuild v2.2.5\n`);
10295
10330
  }
10296
10331
  function setupLogLevel(argv) {
10297
10332
  if (argv.length <= 3) return;
@@ -10313,5 +10348,5 @@ function runCLI({ argv = process.argv } = {}) {
10313
10348
  src_logger.error('Failed to start Rsbuild CLI.'), src_logger.error(err), process.exit(1);
10314
10349
  }
10315
10350
  }
10316
- let src_version = "2.2.4";
10351
+ let src_version = "2.2.5";
10317
10352
  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 };
@@ -497,16 +497,28 @@ export type PrintFileSizeOptions = {
497
497
  assets: PrintFileSizeAsset[];
498
498
  totalSize: number;
499
499
  totalGzipSize: number;
500
+ totalBrotliSize?: number;
500
501
  }) => string);
501
502
  /**
502
503
  * Whether to print the size of each static asset.
503
504
  * @default true
504
505
  */ detail?: boolean;
505
506
  /**
506
- * Whether to print the gzip-compressed size of each static asset.
507
- * Disable this option can save some gzip computation time for large projects.
507
+ * Whether to print the compressed size of each static asset.
508
+ * Set to `true` to use gzip, or specify `type` to select gzip or Brotli.
509
+ * Disabling this option saves compression computation time for large projects.
508
510
  * @default true
509
- */ compressed?: boolean;
511
+ */ compressed?: boolean | {
512
+ /**
513
+ * The compression algorithm used to calculate file sizes.
514
+ * @default 'gzip'
515
+ */ type?: 'gzip' | 'brotli';
516
+ /**
517
+ * The compression level: an integer from 0 to 9 for gzip, or 0 to 11 for Brotli.
518
+ * Higher levels generally produce smaller sizes but take longer to calculate.
519
+ * @default 6
520
+ */ level?: number;
521
+ };
510
522
  /**
511
523
  * A filter function to determine which static assets to print.
512
524
  * If returned `false`, the static asset will be excluded and not included in the
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsbuild/core",
3
- "version": "2.2.4",
3
+ "version": "2.2.5",
4
4
  "description": "The Rspack-based build tool.",
5
5
  "homepage": "https://rsbuild.rs",
6
6
  "bugs": {
@@ -41,7 +41,7 @@
41
41
  "devDependencies": {
42
42
  "@jridgewell/remapping": "^2.3.5",
43
43
  "@jridgewell/trace-mapping": "^0.3.31",
44
- "@rstackjs/load-config": "^0.1.2",
44
+ "@rstackjs/load-config": "^1.0.0",
45
45
  "@types/cors": "^2.8.19",
46
46
  "@types/node": "^24.13.3",
47
47
  "@types/on-finished": "2.3.5",