@rsbuild/core 1.6.11 → 1.6.12-canary-63b4dae2-20251204065915

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  /*! For license information please see index.cjs.LICENSE.txt */
2
2
  const __rslib_import_meta_url__ = 'undefined' == typeof document ? new (require('url'.replace('', ''))).URL('file:' + __filename).href : document.currentScript && document.currentScript.src || new URL('main.js', document.baseURI).href;
3
3
  var __webpack_modules__ = {
4
- "../../node_modules/.pnpm/deepmerge@4.3.1/node_modules/deepmerge/dist/cjs.js": function(module) {
4
+ "../../node_modules/.pnpm/deepmerge@4.3.1/node_modules/deepmerge/dist/cjs.js" (module) {
5
5
  "use strict";
6
6
  var isMergeableObject = function isMergeableObject(value) {
7
7
  return isNonNullObject(value) && !isSpecial(value);
@@ -71,7 +71,7 @@ var __webpack_modules__ = {
71
71
  }, {});
72
72
  }, module.exports = deepmerge;
73
73
  },
74
- "../../node_modules/.pnpm/dotenv-expand@12.0.3/node_modules/dotenv-expand/lib/main.js": function(module) {
74
+ "../../node_modules/.pnpm/dotenv-expand@12.0.3/node_modules/dotenv-expand/lib/main.js" (module) {
75
75
  "use strict";
76
76
  function _resolveEscapeSequences(value) {
77
77
  return value.replace(/\\\$/g, '$');
@@ -104,7 +104,7 @@ var __webpack_modules__ = {
104
104
  }
105
105
  module.exports.expand = expand;
106
106
  },
107
- "../../node_modules/.pnpm/ee-first@1.1.1/node_modules/ee-first/index.js": function(module) {
107
+ "../../node_modules/.pnpm/ee-first@1.1.1/node_modules/ee-first/index.js" (module) {
108
108
  "use strict";
109
109
  function listener(event, done) {
110
110
  return function onevent(arg1) {
@@ -138,7 +138,7 @@ var __webpack_modules__ = {
138
138
  return thunk.cancel = cleanup, thunk;
139
139
  };
140
140
  },
141
- "../../node_modules/.pnpm/javascript-stringify@2.1.0/node_modules/javascript-stringify/dist/array.js": function(__unused_webpack_module, exports1) {
141
+ "../../node_modules/.pnpm/javascript-stringify@2.1.0/node_modules/javascript-stringify/dist/array.js" (__unused_webpack_module, exports1) {
142
142
  "use strict";
143
143
  Object.defineProperty(exports1, "__esModule", {
144
144
  value: !0
@@ -150,7 +150,7 @@ var __webpack_modules__ = {
150
150
  return `[${eol}${values}${eol}]`;
151
151
  };
152
152
  },
153
- "../../node_modules/.pnpm/javascript-stringify@2.1.0/node_modules/javascript-stringify/dist/function.js": function(__unused_webpack_module, exports1, __webpack_require__) {
153
+ "../../node_modules/.pnpm/javascript-stringify@2.1.0/node_modules/javascript-stringify/dist/function.js" (__unused_webpack_module, exports1, __webpack_require__) {
154
154
  "use strict";
155
155
  Object.defineProperty(exports1, "__esModule", {
156
156
  value: !0
@@ -289,7 +289,7 @@ var __webpack_modules__ = {
289
289
  }
290
290
  exports1.FunctionParser = FunctionParser;
291
291
  },
292
- "../../node_modules/.pnpm/javascript-stringify@2.1.0/node_modules/javascript-stringify/dist/index.js": function(__unused_webpack_module, exports1, __webpack_require__) {
292
+ "../../node_modules/.pnpm/javascript-stringify@2.1.0/node_modules/javascript-stringify/dist/index.js" (__unused_webpack_module, exports1, __webpack_require__) {
293
293
  "use strict";
294
294
  exports1.stringify = void 0;
295
295
  let stringify_1 = __webpack_require__("../../node_modules/.pnpm/javascript-stringify@2.1.0/node_modules/javascript-stringify/dist/stringify.js"), quote_1 = __webpack_require__("../../node_modules/.pnpm/javascript-stringify@2.1.0/node_modules/javascript-stringify/dist/quote.js"), ROOT_SENTINEL = Symbol("root");
@@ -326,7 +326,7 @@ var __webpack_modules__ = {
326
326
  return result;
327
327
  };
328
328
  },
329
- "../../node_modules/.pnpm/javascript-stringify@2.1.0/node_modules/javascript-stringify/dist/object.js": function(__unused_webpack_module, exports1, __webpack_require__) {
329
+ "../../node_modules/.pnpm/javascript-stringify@2.1.0/node_modules/javascript-stringify/dist/object.js" (__unused_webpack_module, exports1, __webpack_require__) {
330
330
  "use strict";
331
331
  Object.defineProperty(exports1, "__esModule", {
332
332
  value: !0
@@ -361,7 +361,7 @@ var __webpack_modules__ = {
361
361
  "[object Window]": globalToString
362
362
  };
363
363
  },
364
- "../../node_modules/.pnpm/javascript-stringify@2.1.0/node_modules/javascript-stringify/dist/quote.js": function(__unused_webpack_module, exports1) {
364
+ "../../node_modules/.pnpm/javascript-stringify@2.1.0/node_modules/javascript-stringify/dist/quote.js" (__unused_webpack_module, exports1) {
365
365
  "use strict";
366
366
  Object.defineProperty(exports1, "__esModule", {
367
367
  value: !0
@@ -418,7 +418,7 @@ var __webpack_modules__ = {
418
418
  return result;
419
419
  };
420
420
  },
421
- "../../node_modules/.pnpm/javascript-stringify@2.1.0/node_modules/javascript-stringify/dist/stringify.js": function(__unused_webpack_module, exports1, __webpack_require__) {
421
+ "../../node_modules/.pnpm/javascript-stringify@2.1.0/node_modules/javascript-stringify/dist/stringify.js" (__unused_webpack_module, exports1, __webpack_require__) {
422
422
  "use strict";
423
423
  Object.defineProperty(exports1, "__esModule", {
424
424
  value: !0
@@ -438,7 +438,7 @@ var __webpack_modules__ = {
438
438
  };
439
439
  exports1.toString = (value, space, next, key)=>null === value ? "null" : PRIMITIVE_TYPES[typeof value](value, space, next, key);
440
440
  },
441
- "../../node_modules/.pnpm/lilconfig@3.1.3/node_modules/lilconfig/src/index.js": function(module, __unused_webpack_exports, __webpack_require__) {
441
+ "../../node_modules/.pnpm/lilconfig@3.1.3/node_modules/lilconfig/src/index.js" (module, __unused_webpack_exports, __webpack_require__) {
442
442
  let path = __webpack_require__("path"), fs = __webpack_require__("fs"), os = __webpack_require__("os"), url = __webpack_require__("url"), fsReadFileAsync = fs.promises.readFile;
443
443
  function getDefaultSearchPlaces(name, sync) {
444
444
  return [
@@ -693,7 +693,7 @@ var __webpack_modules__ = {
693
693
  };
694
694
  };
695
695
  },
696
- "../../node_modules/.pnpm/on-finished@2.4.1/node_modules/on-finished/index.js": function(module, __unused_webpack_exports, __webpack_require__) {
696
+ "../../node_modules/.pnpm/on-finished@2.4.1/node_modules/on-finished/index.js" (module, __unused_webpack_exports, __webpack_require__) {
697
697
  "use strict";
698
698
  module.exports = onFinished, module.exports.isFinished = isFinished;
699
699
  var asyncHooks = tryRequireAsyncHooks(), first = __webpack_require__("../../node_modules/.pnpm/ee-first@1.1.1/node_modules/ee-first/index.js"), defer = 'function' == typeof setImmediate ? setImmediate : function(fn) {
@@ -760,7 +760,7 @@ var __webpack_modules__ = {
760
760
  return (asyncHooks.AsyncResource && (res = new asyncHooks.AsyncResource(fn.name || 'bound-anonymous-fn')), res && res.runInAsyncScope) ? res.runInAsyncScope.bind(res, fn, null) : fn;
761
761
  }
762
762
  },
763
- "../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.6.1_postcss@8.5.6_yaml@2.8.1/node_modules/postcss-load-config/src/index.js": function(module, __unused_webpack_exports, __webpack_require__) {
763
+ "../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.6.1_postcss@8.5.6_yaml@2.8.1/node_modules/postcss-load-config/src/index.js" (module, __unused_webpack_exports, __webpack_require__) {
764
764
  let yaml, { resolve } = __webpack_require__("node:path"), 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.6_yaml@2.8.1/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.6_yaml@2.8.1/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.6_yaml@2.8.1/node_modules/postcss-load-config/src/req.js");
765
765
  async function processResult(ctx, result) {
766
766
  let obj, file = result.filepath || '', projectConfig = ((obj = result.config) && obj.__esModule ? obj : {
@@ -834,7 +834,7 @@ var __webpack_modules__ = {
834
834
  });
835
835
  };
836
836
  },
837
- "../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.6.1_postcss@8.5.6_yaml@2.8.1/node_modules/postcss-load-config/src/options.js": function(module, __unused_webpack_exports, __webpack_require__) {
837
+ "../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.6.1_postcss@8.5.6_yaml@2.8.1/node_modules/postcss-load-config/src/options.js" (module, __unused_webpack_exports, __webpack_require__) {
838
838
  let req = __webpack_require__("../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.6.1_postcss@8.5.6_yaml@2.8.1/node_modules/postcss-load-config/src/req.js");
839
839
  module.exports = async function options(config, file) {
840
840
  if (config.parser && 'string' == typeof config.parser) try {
@@ -855,7 +855,7 @@ var __webpack_modules__ = {
855
855
  return config;
856
856
  };
857
857
  },
858
- "../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.6.1_postcss@8.5.6_yaml@2.8.1/node_modules/postcss-load-config/src/plugins.js": function(module, __unused_webpack_exports, __webpack_require__) {
858
+ "../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.6.1_postcss@8.5.6_yaml@2.8.1/node_modules/postcss-load-config/src/plugins.js" (module, __unused_webpack_exports, __webpack_require__) {
859
859
  let req = __webpack_require__("../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.6.1_postcss@8.5.6_yaml@2.8.1/node_modules/postcss-load-config/src/req.js");
860
860
  async function load(plugin, options, file) {
861
861
  try {
@@ -872,7 +872,7 @@ var __webpack_modules__ = {
872
872
  }), list;
873
873
  };
874
874
  },
875
- "../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.6.1_postcss@8.5.6_yaml@2.8.1/node_modules/postcss-load-config/src/req.js": function(module, __unused_webpack_exports, __webpack_require__) {
875
+ "../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.6.1_postcss@8.5.6_yaml@2.8.1/node_modules/postcss-load-config/src/req.js" (module, __unused_webpack_exports, __webpack_require__) {
876
876
  let tsx, jiti, { createRequire } = __webpack_require__("node:module"), { pathToFileURL } = __webpack_require__("node:url"), TS_EXT_RE = /\.[mc]?ts$/, importError = [];
877
877
  module.exports = async function req(name, rootFile = __filename) {
878
878
  let url = createRequire(rootFile).resolve(name);
@@ -901,63 +901,63 @@ var __webpack_modules__ = {
901
901
  throw Error(`'tsx' or 'jiti' is required for the TypeScript configuration files. Make sure it is installed\nError: ${importError.map((error)=>error.message).join('\n')}`);
902
902
  };
903
903
  },
904
- async_hooks: function(module) {
904
+ async_hooks (module) {
905
905
  "use strict";
906
906
  module.exports = require("async_hooks");
907
907
  },
908
- fs: function(module) {
908
+ fs (module) {
909
909
  "use strict";
910
910
  module.exports = require("fs");
911
911
  },
912
- "node:buffer": function(module) {
912
+ "node:buffer" (module) {
913
913
  "use strict";
914
914
  module.exports = require("node:buffer");
915
915
  },
916
- "node:child_process": function(module) {
916
+ "node:child_process" (module) {
917
917
  "use strict";
918
918
  module.exports = require("node:child_process");
919
919
  },
920
- "node:fs": function(module) {
920
+ "node:fs" (module) {
921
921
  "use strict";
922
922
  module.exports = require("node:fs");
923
923
  },
924
- "node:fs/promises": function(module) {
924
+ "node:fs/promises" (module) {
925
925
  "use strict";
926
926
  module.exports = require("node:fs/promises");
927
927
  },
928
- "node:module": function(module) {
928
+ "node:module" (module) {
929
929
  "use strict";
930
930
  module.exports = require("node:module");
931
931
  },
932
- "node:os": function(module) {
932
+ "node:os" (module) {
933
933
  "use strict";
934
934
  module.exports = require("node:os");
935
935
  },
936
- "node:path": function(module) {
936
+ "node:path" (module) {
937
937
  "use strict";
938
938
  module.exports = require("node:path");
939
939
  },
940
- "node:process": function(module) {
940
+ "node:process" (module) {
941
941
  "use strict";
942
942
  module.exports = require("node:process");
943
943
  },
944
- "node:url": function(module) {
944
+ "node:url" (module) {
945
945
  "use strict";
946
946
  module.exports = require("node:url");
947
947
  },
948
- "node:util": function(module) {
948
+ "node:util" (module) {
949
949
  "use strict";
950
950
  module.exports = require("node:util");
951
951
  },
952
- os: function(module) {
952
+ os (module) {
953
953
  "use strict";
954
954
  module.exports = require("os");
955
955
  },
956
- path: function(module) {
956
+ path (module) {
957
957
  "use strict";
958
958
  module.exports = require("path");
959
959
  },
960
- url: function(module) {
960
+ url (module) {
961
961
  "use strict";
962
962
  module.exports = require("url");
963
963
  }
@@ -1021,7 +1021,7 @@ __webpack_require__.m = __webpack_modules__, __webpack_require__.n = (module)=>{
1021
1021
  };
1022
1022
  })();
1023
1023
  var __webpack_exports__ = {};
1024
- for(var __webpack_i__ in (()=>{
1024
+ for(var __rspack_i in (()=>{
1025
1025
  "use strict";
1026
1026
  let swcHelpersPath, pluginHelper_htmlPlugin, cssExtractPlugin;
1027
1027
  __webpack_require__.r(__webpack_exports__), __webpack_require__.d(__webpack_exports__, {
@@ -2502,11 +2502,14 @@ ${section.body}` : section.body).join("\n\n"));
2502
2502
  }
2503
2503
  function formatModuleTrace(stats, errorFile) {
2504
2504
  if (!stats.moduleTrace) return;
2505
- let moduleNames = stats.moduleTrace.map((trace)=>trace.originName).filter(Boolean);
2505
+ let moduleNames = stats.moduleTrace.map((trace)=>trace.originName && removeLoaderChainDelimiter(trace.originName)).filter(Boolean);
2506
2506
  if (!moduleNames.length) return;
2507
- errorFile && moduleNames.unshift(`${errorFile} ${color.bold(color.red('×'))}`);
2507
+ if (errorFile) {
2508
+ let formatted = removeLoaderChainDelimiter(errorFile);
2509
+ moduleNames[0] !== formatted && moduleNames.unshift(formatted);
2510
+ }
2508
2511
  let rawTrace = moduleNames.reverse().map((item)=>`\n ${item}`).join('');
2509
- return color.dim(`Import traces (entry → error):${rawTrace}`);
2512
+ return color.dim(`Import traces (entry → error):${rawTrace} ${color.bold(color.red('×'))}`);
2510
2513
  }
2511
2514
  function hintUnknownFiles(message) {
2512
2515
  let hint = 'You may need an appropriate loader to handle this file type.';
@@ -2548,11 +2551,19 @@ ${section.body}` : section.body).join("\n\n"));
2548
2551
  ])if (plugin.test.test(message)) return message.replace(hint, plugin.hint);
2549
2552
  return message;
2550
2553
  }
2551
- function formatStatsError(stats) {
2552
- var fileName, stats1;
2553
- let fileName1 = resolveFileName(stats), message = `${(fileName = fileName1, stats1 = stats, !fileName ? '' : /:\d+:\d+/.test(fileName) ? `File: ${color.cyan(fileName)}\n` : stats1.loc ? `File: ${color.cyan(`${fileName}:${stats1.loc}`)}\n` : `File: ${color.cyan(`${fileName}:1:1`)}\n`)}${stats.message}`, verbose = 'verbose' === logger.level;
2554
+ function formatStatsError(stats, root) {
2555
+ let fileName = resolveFileName(stats), message = `${((fileName, stats, root)=>{
2556
+ if (!fileName) return '';
2557
+ let DATA_URI_PREFIX = "data:text/javascript,";
2558
+ if (fileName.startsWith(DATA_URI_PREFIX)) {
2559
+ let snippet = fileName.replace(DATA_URI_PREFIX, '');
2560
+ return snippet.length > 30 && (snippet = `${snippet.slice(0, 30)}...`), `File: ${color.cyan('data-uri virtual module')} ${color.dim(`(${snippet})`)}\n`;
2561
+ }
2562
+ let prefix = root + external_node_path_.sep;
2563
+ return (fileName.startsWith(prefix) && (fileName = fileName.replace(prefix, `.${external_node_path_.sep}`)), /:\d+:\d+/.test(fileName)) ? `File: ${color.cyan(fileName)}\n` : stats.loc ? `File: ${color.cyan(`${fileName}:${stats.loc}`)}\n` : `File: ${color.cyan(`${fileName}:1:1`)}\n`;
2564
+ })(fileName, stats, root)}${stats.message}`, verbose = 'verbose' === logger.level;
2554
2565
  verbose && (stats.details && (message += `\nDetails: ${stats.details}\n`), stats.stack && (message += `\n${stats.stack}`));
2555
- let moduleTrace = formatModuleTrace(stats, fileName1);
2566
+ let moduleTrace = formatModuleTrace(stats, fileName);
2556
2567
  moduleTrace && (message += moduleTrace);
2557
2568
  let innerError = '-- inner error --';
2558
2569
  !verbose && message.includes(innerError) && (message = message.split(innerError)[0]);
@@ -2656,12 +2667,12 @@ ${section.body}` : section.body).join("\n\n"));
2656
2667
  let statsOptions = getStatsOptions(compiler, action);
2657
2668
  return statsInstance.toJson(statsOptions);
2658
2669
  }
2659
- function formatStats(stats, hasErrors) {
2670
+ function formatStats(stats, hasErrors, root) {
2660
2671
  if (hasErrors) return {
2661
- message: formatErrorMessage(getStatsErrors(stats).map((item)=>formatStatsError(item))),
2672
+ message: formatErrorMessage(getStatsErrors(stats).map((item)=>formatStatsError(item, root))),
2662
2673
  level: 'error'
2663
2674
  };
2664
- let warningMessages = getStatsWarnings(stats).map((item)=>formatStatsError(item));
2675
+ let warningMessages = getStatsWarnings(stats).map((item)=>formatStatsError(item, root));
2665
2676
  if (warningMessages.length) {
2666
2677
  let title = color.bold(color.yellow(warningMessages.length > 1 ? 'Build warnings: \n' : 'Build warning: \n'));
2667
2678
  return {
@@ -3541,7 +3552,7 @@ ${section.body}` : section.body).join("\n\n"));
3541
3552
  async function createContext(options, userConfig) {
3542
3553
  let { cwd } = options, rootPath = userConfig.root ? ensureAbsolutePath(cwd, userConfig.root) : cwd, rsbuildConfig = await withDefaultConfig(rootPath, userConfig), cachePath = (0, external_node_path_.join)(rootPath, 'node_modules', '.cache'), specifiedEnvironments = options.environment && options.environment.length > 0 ? options.environment : void 0, bundlerType = userConfig.provider ? 'webpack' : 'rspack';
3543
3554
  return {
3544
- version: "1.6.11",
3555
+ version: "1.6.12-canary-63b4dae2-20251204065915",
3545
3556
  rootPath,
3546
3557
  distPath: '',
3547
3558
  cachePath,
@@ -4125,7 +4136,7 @@ ${section.body}` : section.body).join("\n\n"));
4125
4136
  }), compiler.hooks.done.tap(HOOK_NAME, (statsInstance)=>{
4126
4137
  let stats = getRsbuildStats(statsInstance, compiler, context.action), hasErrors = statsInstance.hasErrors();
4127
4138
  context.buildState.stats = stats, context.buildState.status = 'done', context.buildState.hasErrors = hasErrors, context.socketServer?.onBuildDone();
4128
- let { message, level } = formatStats(stats, hasErrors);
4139
+ let { message, level } = formatStats(stats, hasErrors, options.context.rootPath);
4129
4140
  'error' === level && logger.error(message), 'warning' === level && logger.warn(message), isMultiCompiler || printTime(0, hasErrors), isCompiling = !1;
4130
4141
  }), 'dev' === context.action && registerDevHook({
4131
4142
  context,
@@ -4450,7 +4461,38 @@ ${section.body}` : section.body).join("\n\n"));
4450
4461
  let data = await fileSize_gzip(input);
4451
4462
  return Buffer.byteLength(data);
4452
4463
  }
4453
- let EXCLUDE_ASSET_REGEX = /\.(?:map|LICENSE\.txt|d\.ts)$/, excludeAsset = (asset)=>EXCLUDE_ASSET_REGEX.test(asset.name), getAssetColor = (size)=>size > 300000 ? color.red : size > 100000 ? color.yellow : color.green;
4464
+ function getSnapshotPath(dir) {
4465
+ return external_node_path_default().join(dir, 'rsbuild/file-sizes.json');
4466
+ }
4467
+ function normalizeFileName(fileName) {
4468
+ return fileName.replace(/\.[a-f0-9]{8,}\./g, '.');
4469
+ }
4470
+ async function loadPreviousSizes(dir) {
4471
+ let snapshotPath = getSnapshotPath(dir);
4472
+ try {
4473
+ let content = await external_node_fs_default().promises.readFile(snapshotPath, 'utf-8');
4474
+ return JSON.parse(content);
4475
+ } catch {
4476
+ return null;
4477
+ }
4478
+ }
4479
+ async function saveSnapshots(dir, snapshots) {
4480
+ let snapshotPath = getSnapshotPath(dir);
4481
+ try {
4482
+ await external_node_fs_default().promises.mkdir(external_node_path_default().dirname(snapshotPath), {
4483
+ recursive: !0
4484
+ }), await external_node_fs_default().promises.writeFile(snapshotPath, JSON.stringify(snapshots, null, 2));
4485
+ } catch (err) {
4486
+ logger.debug('Failed to save file size snapshots:', err);
4487
+ }
4488
+ }
4489
+ let EXCLUDE_ASSET_REGEX = /\.(?:map|LICENSE\.txt|d\.ts)$/, excludeAsset = (asset)=>EXCLUDE_ASSET_REGEX.test(asset.name), formatDiff = (diff)=>{
4490
+ let label = `(${diff > 0 ? '+' : '-'}${calcFileSize(Math.abs(diff))})`;
4491
+ return {
4492
+ label: (diff > 0 ? color.red : color.green)(label),
4493
+ length: label.length
4494
+ };
4495
+ }, getAssetColor = (size)=>size > 300000 ? color.red : size > 100000 ? color.yellow : color.green;
4454
4496
  function getHeader(maxFileLength, maxSizeLength, fileHeader, showGzipHeader) {
4455
4497
  let lengths = [
4456
4498
  maxFileLength,
@@ -4470,21 +4512,42 @@ ${section.body}` : section.body).join("\n\n"));
4470
4512
  let val = len / 1000;
4471
4513
  return `${val.toFixed(val < 1 ? 2 : 1)} kB`;
4472
4514
  }, coloringAssetName = (assetName)=>JS_REGEX.test(assetName) ? color.cyan(assetName) : assetName.endsWith('.css') ? color.yellow(assetName) : assetName.endsWith('.html') ? color.green(assetName) : color.magenta(assetName), COMPRESSIBLE_REGEX = /\.(?:js|css|html|json|svg|txt|xml|xhtml|wasm|manifest|md)$/i;
4473
- async function printFileSizes(options, stats, rootPath, distPath, environmentName) {
4474
- let logs = [], showDetail = !1 !== options.detail, showTotal = !1 !== options.total;
4475
- if (!showTotal && !showDetail) return logs;
4476
- let exclude = options.exclude ?? excludeAsset, relativeDistPath = external_node_path_default().relative(rootPath, distPath), formatAsset = async (asset)=>{
4477
- let assetName, fileName = asset.name.split('?')[0], contents = await external_node_fs_default().promises.readFile(external_node_path_default().join(distPath, fileName)), size = Buffer.byteLength(contents), gzippedSize = options.compressed && (assetName = fileName, COMPRESSIBLE_REGEX.test(assetName)) ? await gzipSize(contents) : null, gzipSizeLabel = gzippedSize ? getAssetColor(gzippedSize)(calcFileSize(gzippedSize)) : null;
4515
+ async function printFileSizes(options, stats, rootPath, distPath, environmentName, previousSizes) {
4516
+ let logs = [], showDetail = !1 !== options.detail, showDiff = !1 !== options.diff && null !== previousSizes, showTotal = !1 !== options.total;
4517
+ if (!showTotal && !showDetail) return {
4518
+ logs
4519
+ };
4520
+ let exclude = options.exclude ?? excludeAsset, relativeDistPath = external_node_path_default().relative(rootPath, distPath), sizes = {}, formatAsset = async (asset)=>{
4521
+ let assetName, fileName = asset.name.split('?')[0], contents = await external_node_fs_default().promises.readFile(external_node_path_default().join(distPath, fileName)), size = Buffer.byteLength(contents), gzippedSize = options.compressed && (assetName = fileName, COMPRESSIBLE_REGEX.test(assetName)) ? await gzipSize(contents) : null, normalizedName = normalizeFileName(fileName);
4522
+ sizes[normalizeFileName(fileName)] = {
4523
+ size,
4524
+ gzippedSize: gzippedSize ?? void 0
4525
+ };
4526
+ let sizeLabel = calcFileSize(size), sizeLabelLength = sizeLabel.length, gzipSizeLabel = gzippedSize ? getAssetColor(gzippedSize)(calcFileSize(gzippedSize)) : null;
4527
+ if (showDiff) {
4528
+ let sizeData = previousSizes[environmentName]?.[normalizedName], sizeDiff = size - (sizeData?.size ?? 0);
4529
+ if (0 !== sizeDiff) {
4530
+ let { label, length } = formatDiff(sizeDiff);
4531
+ sizeLabel += ` ${label}`, sizeLabelLength += length + 1;
4532
+ }
4533
+ if (gzippedSize) {
4534
+ let gzipDiff = gzippedSize - (sizeData?.gzippedSize ?? 0);
4535
+ 0 !== gzipDiff && (gzipSizeLabel += ` ${formatDiff(gzipDiff).label}`);
4536
+ }
4537
+ }
4478
4538
  return {
4479
4539
  size,
4540
+ sizeLabel,
4541
+ sizeLabelLength,
4480
4542
  folder: external_node_path_default().join(relativeDistPath, external_node_path_default().dirname(fileName)),
4481
4543
  name: external_node_path_default().basename(fileName),
4482
4544
  gzippedSize,
4483
- sizeLabel: calcFileSize(size),
4484
4545
  gzipSizeLabel
4485
4546
  };
4486
4547
  }, getAssets = async ()=>Promise.all(getAssetsFromStats(stats).filter((asset)=>!exclude(asset) && (!options.include || options.include(asset))).map((asset)=>formatAsset(asset))), assets = await getAssets();
4487
- if (0 === assets.length) return logs;
4548
+ if (0 === assets.length) return {
4549
+ logs
4550
+ };
4488
4551
  logs.push(''), assets.sort((a, b)=>a.size - b.size);
4489
4552
  let totalSize = 0, totalGzipSize = 0;
4490
4553
  for (let asset of (showTotal = showTotal && !(showDetail && 1 === assets.length), assets))totalSize += asset.size, options.compressed && (totalGzipSize += asset.gzippedSize ?? asset.size);
@@ -4502,12 +4565,10 @@ ${section.body}` : section.body).join("\n\n"));
4502
4565
  totalGzipSize
4503
4566
  }) : null;
4504
4567
  if (showDetail) {
4505
- let maxFileLength = Math.max(...assets.map((a)=>(a.folder + external_node_path_default().sep + a.name).length), showTotal ? totalSizeLabel.length : 0, fileHeader.length), maxSizeLength = Math.max(...assets.map((a)=>a.sizeLabel.length), totalSizeStr.length), showGzipHeader = !!(options.compressed && assets.some((item)=>null !== item.gzippedSize));
4568
+ let maxFileLength = Math.max(...assets.map((a)=>(a.folder + external_node_path_default().sep + a.name).length), showTotal ? totalSizeLabel.length : 0, fileHeader.length), maxSizeLength = Math.max(...assets.map((a)=>a.sizeLabelLength), totalSizeStr.length), showGzipHeader = !!(options.compressed && assets.some((item)=>null !== item.gzippedSize));
4506
4569
  for (let asset of (logs.push(getHeader(maxFileLength, maxSizeLength, fileHeader, showGzipHeader)), assets)){
4507
- let { sizeLabel } = asset, { name, folder, gzipSizeLabel } = asset, fileNameLength = (folder + external_node_path_default().sep + name).length, sizeLength = sizeLabel.length;
4508
- sizeLength < maxSizeLength && (sizeLabel += ' '.repeat(maxSizeLength - sizeLength));
4509
- let fileNameLabel = color.dim(asset.folder + external_node_path_default().sep) + coloringAssetName(asset.name);
4510
- fileNameLength < maxFileLength && (fileNameLabel += ' '.repeat(maxFileLength - fileNameLength));
4570
+ let { sizeLabel, sizeLabelLength, gzipSizeLabel } = asset, { name, folder } = asset, fileNameLength = (folder + external_node_path_default().sep + name).length, fileNameLabel = color.dim(asset.folder + external_node_path_default().sep) + coloringAssetName(asset.name);
4571
+ sizeLabelLength < maxSizeLength && (sizeLabel += ' '.repeat(maxSizeLength - sizeLabelLength)), fileNameLength < maxFileLength && (fileNameLabel += ' '.repeat(maxFileLength - fileNameLength));
4511
4572
  let log = `${fileNameLabel} ${sizeLabel}`;
4512
4573
  gzipSizeLabel && (log += ` ${gzipSizeLabel}`), logs.push(log);
4513
4574
  }
@@ -4532,7 +4593,10 @@ ${section.body}` : section.body).join("\n\n"));
4532
4593
  options.compressed && (log += color.green(` (${calcFileSize(totalGzipSize)} gzipped)`)), logs.push(log);
4533
4594
  }
4534
4595
  }
4535
- return logs.push(''), logs;
4596
+ return logs.push(''), {
4597
+ logs,
4598
+ sizes
4599
+ };
4536
4600
  }
4537
4601
  let entryNameSymbol = Symbol('entryName'), VOID_TAGS = [
4538
4602
  'area',
@@ -5110,13 +5174,14 @@ ${section.body}` : section.body).join("\n\n"));
5110
5174
  }
5111
5175
  let isCSSPath = (filePath)=>filePath.endsWith('.css');
5112
5176
  function normalizeManifestObjectConfig(manifest) {
5113
- if ('string' == typeof manifest) return {
5114
- filename: manifest
5115
- };
5116
5177
  let defaultOptions = {
5178
+ prefix: !0,
5117
5179
  filename: 'manifest.json'
5118
5180
  };
5119
- return 'boolean' == typeof manifest ? defaultOptions : {
5181
+ return 'string' == typeof manifest ? {
5182
+ ...defaultOptions,
5183
+ filename: manifest
5184
+ } : 'boolean' == typeof manifest ? defaultOptions : {
5120
5185
  ...defaultOptions,
5121
5186
  ...manifest
5122
5187
  };
@@ -6365,7 +6430,7 @@ init({
6365
6430
  });
6366
6431
  }
6367
6432
  sendError(errors, token) {
6368
- let formattedErrors = errors.map((item)=>formatStatsError(item));
6433
+ let formattedErrors = errors.map((item)=>formatStatsError(item, this.context.rootPath));
6369
6434
  this.sockWrite({
6370
6435
  type: 'errors',
6371
6436
  data: {
@@ -6375,7 +6440,7 @@ init({
6375
6440
  }, token);
6376
6441
  }
6377
6442
  sendWarning(warnings, token) {
6378
- let formattedWarnings = warnings.map((item)=>formatStatsError(item));
6443
+ let formattedWarnings = warnings.map((item)=>formatStatsError(item, this.context.rootPath));
6379
6444
  this.sockWrite({
6380
6445
  type: 'warnings',
6381
6446
  data: {
@@ -7819,25 +7884,29 @@ init({
7819
7884
  (context1 = context, {
7820
7885
  name: 'rsbuild:file-size',
7821
7886
  setup (api) {
7822
- api.onAfterBuild(async ({ stats, environments, isFirstCompile })=>{
7887
+ api.onAfterBuild(async ({ stats, isFirstCompile })=>{
7823
7888
  let { hasErrors } = context1.buildState;
7824
7889
  if (!stats || hasErrors || !isFirstCompile) return;
7825
- let logs = [];
7826
- await Promise.all(Object.values(environments).map(async (environment, index)=>{
7890
+ let environments = context1.environmentList.filter(({ config })=>!1 !== config.performance.printFileSize);
7891
+ if (!environments.length) return;
7892
+ let showDiff = environments.some((environment)=>{
7827
7893
  let { printFileSize } = environment.config.performance;
7828
- if (!1 === printFileSize) return;
7829
- let defaultConfig = {
7894
+ return 'object' == typeof printFileSize && !!printFileSize.diff;
7895
+ }), previousSizes = showDiff ? await loadPreviousSizes(api.context.cachePath) : null, nextSizes = {}, logs = await Promise.all(environments.map(async ({ name, index, config, distPath })=>{
7896
+ let { printFileSize } = config.performance, defaultConfig = {
7830
7897
  total: !0,
7831
7898
  detail: !0,
7832
- compressed: 'node' !== environment.config.output.target
7899
+ diff: !1,
7900
+ compressed: 'node' !== config.output.target
7833
7901
  }, mergedConfig = !0 === printFileSize ? defaultConfig : {
7834
7902
  ...defaultConfig,
7835
7903
  ...printFileSize
7836
- }, statsItem = 'stats' in stats ? stats.stats[index] : stats, statsLogs = await printFileSizes(mergedConfig, statsItem, api.context.rootPath, environment.distPath, environment.name);
7837
- logs.push(...statsLogs);
7904
+ }, statsItem = 'stats' in stats ? stats.stats[index] : stats, { logs: sizeLogs, sizes } = await printFileSizes(mergedConfig, statsItem, api.context.rootPath, distPath, name, previousSizes);
7905
+ return sizes && (nextSizes[name] = sizes), sizeLogs.join('\n');
7838
7906
  })).catch((err)=>{
7839
7907
  logger.warn('Failed to print file size.'), logger.warn(err);
7840
- }), logger.log(logs.join('\n'));
7908
+ });
7909
+ logs && logger.log(logs.join('\n')), showDiff && await saveSnapshots(api.context.cachePath, nextSizes);
7841
7910
  });
7842
7911
  }
7843
7912
  }),
@@ -8720,67 +8789,69 @@ try {
8720
8789
  let htmlPaths, manifestOptions, environment1, { output: { manifest }, dev: { writeToDisk } } = environment.config;
8721
8790
  if (!1 === manifest) return;
8722
8791
  let manifestOptions1 = normalizeManifestObjectConfig(manifest), { RspackManifestPlugin } = requireCompiledPackage('rspack-manifest-plugin'), { htmlPaths: htmlPaths1 } = environment, filter = manifestOptions1.filter ?? ((file)=>!file.name.endsWith('.LICENSE.txt'));
8723
- manifestFilenames.set(environment.name, manifestOptions1.filename), chain.plugin(CHAIN_ID.PLUGIN.MANIFEST).use(RspackManifestPlugin, [
8724
- {
8725
- fileName: manifestOptions1.filename,
8726
- filter,
8727
- writeToFileEmit: isDev && !0 !== writeToDisk,
8728
- generate: (htmlPaths = htmlPaths1, manifestOptions = manifestOptions1, environment1 = environment, (_seed, files, entries, { compilation })=>{
8729
- let chunkEntries = new Map(), licenseMap = new Map(), publicPath = getPublicPathFromCompiler(compilation), integrity = {}, allFiles = files.map((file)=>{
8730
- if (file.integrity && (integrity[file.path] = file.integrity), file.chunk) for (let entryName of recursiveChunkEntryNames(file.chunk))chunkEntries.set(entryName, [
8731
- file,
8732
- ...chunkEntries.get(entryName) || []
8733
- ]);
8734
- if (file.path.endsWith('.LICENSE.txt')) {
8735
- let sourceFilePath = file.path.split('.LICENSE.txt')[0];
8736
- licenseMap.set(sourceFilePath, file.path);
8737
- }
8738
- return file.path;
8739
- }), manifestEntries = {};
8740
- for (let [entryName, chunkFiles] of chunkEntries){
8741
- let assets = new Set(), initialJS = [], initialCSS = [], asyncJS = [], asyncCSS = [];
8742
- if (entries[entryName]) for (let filePath of entries[entryName]){
8743
- let fileURL = ensureAssetPrefix(filePath, publicPath);
8744
- isCSSPath(filePath) ? initialCSS.push(fileURL) : initialJS.push(fileURL);
8745
- }
8746
- for (let file of chunkFiles){
8747
- file.isInitial || (isCSSPath(file.path) ? asyncCSS.push(file.path) : asyncJS.push(file.path));
8748
- let relatedLICENSE = licenseMap.get(file.path);
8749
- if (relatedLICENSE && assets.add(relatedLICENSE), file.chunk) for (let auxiliaryFile of file.chunk.auxiliaryFiles)assets.add(auxiliaryFile);
8750
- }
8751
- let entryManifest = {};
8752
- assets.size && (entryManifest.assets = Array.from(assets));
8753
- let htmlPath = files.find((f)=>f.name === htmlPaths[entryName])?.path;
8754
- htmlPath && (entryManifest.html = [
8755
- htmlPath
8756
- ]), initialJS.length && (entryManifest.initial = {
8757
- js: initialJS
8758
- }), initialCSS.length && (entryManifest.initial = {
8759
- ...entryManifest.initial || {},
8760
- css: initialCSS
8761
- }), asyncJS.length && (entryManifest.async = {
8762
- js: asyncJS
8763
- }), asyncCSS.length && (entryManifest.async = {
8764
- ...entryManifest.async || {},
8765
- css: asyncCSS
8766
- }), manifestEntries[entryName] = entryManifest;
8792
+ manifestFilenames.set(environment.name, manifestOptions1.filename);
8793
+ let pluginOptions = {
8794
+ fileName: manifestOptions1.filename,
8795
+ filter,
8796
+ writeToFileEmit: isDev && !0 !== writeToDisk,
8797
+ generate: (htmlPaths = htmlPaths1, manifestOptions = manifestOptions1, environment1 = environment, (_seed, files, entries, { compilation })=>{
8798
+ let chunkEntries = new Map(), licenseMap = new Map(), publicPath = getPublicPathFromCompiler(compilation), integrity = {}, allFiles = files.map((file)=>{
8799
+ if (file.integrity && (integrity[file.path] = file.integrity), file.chunk) for (let entryName of recursiveChunkEntryNames(file.chunk))chunkEntries.set(entryName, [
8800
+ file,
8801
+ ...chunkEntries.get(entryName) || []
8802
+ ]);
8803
+ if (file.path.endsWith('.LICENSE.txt')) {
8804
+ let sourceFilePath = file.path.split('.LICENSE.txt')[0];
8805
+ licenseMap.set(sourceFilePath, file.path);
8767
8806
  }
8768
- let manifestData = {
8769
- allFiles,
8770
- entries: manifestEntries,
8771
- integrity
8772
- };
8773
- if (manifestOptions.generate) {
8774
- let generatedManifest = manifestOptions.generate({
8775
- files,
8776
- manifestData
8777
- });
8778
- if (isObject(generatedManifest)) return environment1.manifest = generatedManifest, generatedManifest;
8779
- throw Error(`${color.dim('[rsbuild:manifest]')} \`manifest.generate\` function must return a valid manifest object.`);
8807
+ return file.path;
8808
+ }), manifestEntries = {};
8809
+ for (let [entryName, chunkFiles] of chunkEntries){
8810
+ let assets = new Set(), initialJS = [], initialCSS = [], asyncJS = [], asyncCSS = [];
8811
+ if (entries[entryName]) for (let filePath of entries[entryName]){
8812
+ let fileURL = manifestOptions.prefix ? ensureAssetPrefix(filePath, publicPath) : filePath;
8813
+ isCSSPath(filePath) ? initialCSS.push(fileURL) : initialJS.push(fileURL);
8780
8814
  }
8781
- return environment1.manifest = manifestData, manifestData;
8782
- })
8783
- }
8815
+ for (let file of chunkFiles){
8816
+ file.isInitial || (isCSSPath(file.path) ? asyncCSS.push(file.path) : asyncJS.push(file.path));
8817
+ let relatedLICENSE = licenseMap.get(file.path);
8818
+ if (relatedLICENSE && assets.add(relatedLICENSE), file.chunk) for (let auxiliaryFile of file.chunk.auxiliaryFiles)assets.add(auxiliaryFile);
8819
+ }
8820
+ let entryManifest = {};
8821
+ assets.size && (entryManifest.assets = Array.from(assets));
8822
+ let htmlPath = files.find((f)=>f.name === htmlPaths[entryName])?.path;
8823
+ htmlPath && (entryManifest.html = [
8824
+ htmlPath
8825
+ ]), initialJS.length && (entryManifest.initial = {
8826
+ js: initialJS
8827
+ }), initialCSS.length && (entryManifest.initial = {
8828
+ ...entryManifest.initial || {},
8829
+ css: initialCSS
8830
+ }), asyncJS.length && (entryManifest.async = {
8831
+ js: asyncJS
8832
+ }), asyncCSS.length && (entryManifest.async = {
8833
+ ...entryManifest.async || {},
8834
+ css: asyncCSS
8835
+ }), manifestEntries[entryName] = entryManifest;
8836
+ }
8837
+ let manifestData = {
8838
+ allFiles,
8839
+ entries: manifestEntries,
8840
+ integrity
8841
+ };
8842
+ if (manifestOptions.generate) {
8843
+ let generatedManifest = manifestOptions.generate({
8844
+ files,
8845
+ manifestData
8846
+ });
8847
+ if (isObject(generatedManifest)) return environment1.manifest = generatedManifest, generatedManifest;
8848
+ throw Error(`${color.dim('[rsbuild:manifest]')} \`manifest.generate\` function must return a valid manifest object.`);
8849
+ }
8850
+ return environment1.manifest = manifestData, manifestData;
8851
+ })
8852
+ };
8853
+ manifestOptions1.prefix || (pluginOptions.publicPath = ''), chain.plugin(CHAIN_ID.PLUGIN.MANIFEST).use(RspackManifestPlugin, [
8854
+ pluginOptions
8784
8855
  ]);
8785
8856
  }), api.onAfterCreateCompiler(()=>{
8786
8857
  if (manifestFilenames.size <= 1) return void manifestFilenames.clear();
@@ -9182,7 +9253,7 @@ try {
9182
9253
  };
9183
9254
  function setupCommands() {
9184
9255
  let cli = ((name = "")=>new CAC(name))('rsbuild');
9185
- cli.version("1.6.11"), 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)', {
9256
+ cli.version("1.6.12-canary-63b4dae2-20251204065915"), 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)', {
9186
9257
  default: 'auto'
9187
9258
  }).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', {
9188
9259
  type: [
@@ -9251,7 +9322,7 @@ try {
9251
9322
  }
9252
9323
  function showGreeting() {
9253
9324
  let { npm_execpath, npm_lifecycle_event, NODE_RUN_SCRIPT_NAME } = process.env, isBun = npm_execpath?.includes('.bun');
9254
- logger.greet(`${'npx' === npm_lifecycle_event || isBun || NODE_RUN_SCRIPT_NAME ? '\n' : ''}Rsbuild v1.6.11\n`);
9325
+ logger.greet(`${'npx' === npm_lifecycle_event || isBun || NODE_RUN_SCRIPT_NAME ? '\n' : ''}Rsbuild v1.6.12-canary-63b4dae2-20251204065915\n`);
9255
9326
  }
9256
9327
  function setupLogLevel() {
9257
9328
  let logLevelIndex = process.argv.findIndex((item)=>'--log-level' === item || '--logLevel' === item);
@@ -9272,7 +9343,7 @@ try {
9272
9343
  logger.error('Failed to start Rsbuild CLI.'), logger.error(err);
9273
9344
  }
9274
9345
  }
9275
- let src_version = "1.6.11";
9346
+ let src_version = "1.6.12-canary-63b4dae2-20251204065915";
9276
9347
  })(), exports.PLUGIN_CSS_NAME = __webpack_exports__.PLUGIN_CSS_NAME, exports.PLUGIN_SWC_NAME = __webpack_exports__.PLUGIN_SWC_NAME, exports.createRsbuild = __webpack_exports__.createRsbuild, exports.defaultAllowedOrigins = __webpack_exports__.defaultAllowedOrigins, exports.defineConfig = __webpack_exports__.defineConfig, exports.ensureAssetPrefix = __webpack_exports__.ensureAssetPrefix, exports.loadConfig = __webpack_exports__.loadConfig, exports.loadEnv = __webpack_exports__.loadEnv, exports.logger = __webpack_exports__.logger, exports.mergeRsbuildConfig = __webpack_exports__.mergeRsbuildConfig, exports.rspack = __webpack_exports__.rspack, exports.runCLI = __webpack_exports__.runCLI, exports.version = __webpack_exports__.version, __webpack_exports__)-1 === [
9277
9348
  "PLUGIN_CSS_NAME",
9278
9349
  "PLUGIN_SWC_NAME",
@@ -9287,7 +9358,7 @@ try {
9287
9358
  "rspack",
9288
9359
  "runCLI",
9289
9360
  "version"
9290
- ].indexOf(__webpack_i__) && (exports[__webpack_i__] = __webpack_exports__[__webpack_i__]);
9361
+ ].indexOf(__rspack_i) && (exports[__rspack_i] = __webpack_exports__[__rspack_i]);
9291
9362
  Object.defineProperty(exports, '__esModule', {
9292
9363
  value: !0
9293
9364
  });