@rsbuild/core 1.6.11 → 1.6.12-canary-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/131.js CHANGED
@@ -10,14 +10,14 @@ import * as __rspack_external_path from "path";
10
10
  import * as __rspack_external_url from "url";
11
11
  import { __webpack_require__ } from "./rslib-runtime.js";
12
12
  import { EventEmitter } from "events";
13
+ import { promisify as external_node_util_promisify, stripVTControlCharacters } from "node:util";
13
14
  import node_fs, { existsSync } from "node:fs";
14
15
  import node_os, { constants as external_node_os_constants } from "node:os";
15
16
  import node_process from "node:process";
16
17
  import { isPromise, isRegExp } from "node:util/types";
17
- import { promisify as external_node_util_promisify } from "node:util";
18
18
  import node_zlib from "node:zlib";
19
19
  __webpack_require__.add({
20
- "../../node_modules/.pnpm/deepmerge@4.3.1/node_modules/deepmerge/dist/cjs.js": function(module) {
20
+ "../../node_modules/.pnpm/deepmerge@4.3.1/node_modules/deepmerge/dist/cjs.js" (module) {
21
21
  var isMergeableObject = function isMergeableObject(value) {
22
22
  return isNonNullObject(value) && !isSpecial(value);
23
23
  };
@@ -86,7 +86,7 @@ __webpack_require__.add({
86
86
  }, {});
87
87
  }, module.exports = deepmerge;
88
88
  },
89
- "../../node_modules/.pnpm/dotenv-expand@12.0.3/node_modules/dotenv-expand/lib/main.js": function(module) {
89
+ "../../node_modules/.pnpm/dotenv-expand@12.0.3/node_modules/dotenv-expand/lib/main.js" (module) {
90
90
  function _resolveEscapeSequences(value) {
91
91
  return value.replace(/\\\$/g, '$');
92
92
  }
@@ -118,7 +118,7 @@ __webpack_require__.add({
118
118
  }
119
119
  module.exports.expand = expand;
120
120
  },
121
- "../../node_modules/.pnpm/ee-first@1.1.1/node_modules/ee-first/index.js": function(module) {
121
+ "../../node_modules/.pnpm/ee-first@1.1.1/node_modules/ee-first/index.js" (module) {
122
122
  function listener(event, done) {
123
123
  return function onevent(arg1) {
124
124
  for(var args = Array(arguments.length), i = 0; i < args.length; i++)args[i] = arguments[i];
@@ -151,7 +151,7 @@ __webpack_require__.add({
151
151
  return thunk.cancel = cleanup, thunk;
152
152
  };
153
153
  },
154
- "../../node_modules/.pnpm/javascript-stringify@2.1.0/node_modules/javascript-stringify/dist/array.js": function(__unused_webpack_module, exports) {
154
+ "../../node_modules/.pnpm/javascript-stringify@2.1.0/node_modules/javascript-stringify/dist/array.js" (__unused_webpack_module, exports) {
155
155
  Object.defineProperty(exports, "__esModule", {
156
156
  value: !0
157
157
  }), exports.arrayToString = void 0, exports.arrayToString = (array, space, next)=>{
@@ -162,7 +162,7 @@ __webpack_require__.add({
162
162
  return `[${eol}${values}${eol}]`;
163
163
  };
164
164
  },
165
- "../../node_modules/.pnpm/javascript-stringify@2.1.0/node_modules/javascript-stringify/dist/function.js": function(__unused_webpack_module, exports, __webpack_require__) {
165
+ "../../node_modules/.pnpm/javascript-stringify@2.1.0/node_modules/javascript-stringify/dist/function.js" (__unused_webpack_module, exports, __webpack_require__) {
166
166
  Object.defineProperty(exports, "__esModule", {
167
167
  value: !0
168
168
  }), exports.FunctionParser = exports.dedentFunction = exports.functionToString = exports.USED_METHOD_KEY = void 0;
@@ -300,7 +300,7 @@ __webpack_require__.add({
300
300
  }
301
301
  exports.FunctionParser = FunctionParser;
302
302
  },
303
- "../../node_modules/.pnpm/javascript-stringify@2.1.0/node_modules/javascript-stringify/dist/index.js": function(__unused_webpack_module, exports, __webpack_require__) {
303
+ "../../node_modules/.pnpm/javascript-stringify@2.1.0/node_modules/javascript-stringify/dist/index.js" (__unused_webpack_module, exports, __webpack_require__) {
304
304
  exports.stringify = void 0;
305
305
  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");
306
306
  function replacerToString(replacer) {
@@ -336,7 +336,7 @@ __webpack_require__.add({
336
336
  return result;
337
337
  };
338
338
  },
339
- "../../node_modules/.pnpm/javascript-stringify@2.1.0/node_modules/javascript-stringify/dist/object.js": function(__unused_webpack_module, exports, __webpack_require__) {
339
+ "../../node_modules/.pnpm/javascript-stringify@2.1.0/node_modules/javascript-stringify/dist/object.js" (__unused_webpack_module, exports, __webpack_require__) {
340
340
  Object.defineProperty(exports, "__esModule", {
341
341
  value: !0
342
342
  }), exports.objectToString = void 0;
@@ -370,7 +370,7 @@ __webpack_require__.add({
370
370
  "[object Window]": globalToString
371
371
  };
372
372
  },
373
- "../../node_modules/.pnpm/javascript-stringify@2.1.0/node_modules/javascript-stringify/dist/quote.js": function(__unused_webpack_module, exports) {
373
+ "../../node_modules/.pnpm/javascript-stringify@2.1.0/node_modules/javascript-stringify/dist/quote.js" (__unused_webpack_module, exports) {
374
374
  Object.defineProperty(exports, "__esModule", {
375
375
  value: !0
376
376
  }), exports.stringifyPath = exports.quoteKey = exports.isValidVariableName = exports.IS_VALID_IDENTIFIER = exports.quoteString = void 0;
@@ -426,7 +426,7 @@ __webpack_require__.add({
426
426
  return result;
427
427
  };
428
428
  },
429
- "../../node_modules/.pnpm/javascript-stringify@2.1.0/node_modules/javascript-stringify/dist/stringify.js": function(__unused_webpack_module, exports, __webpack_require__) {
429
+ "../../node_modules/.pnpm/javascript-stringify@2.1.0/node_modules/javascript-stringify/dist/stringify.js" (__unused_webpack_module, exports, __webpack_require__) {
430
430
  Object.defineProperty(exports, "__esModule", {
431
431
  value: !0
432
432
  }), exports.toString = void 0;
@@ -445,7 +445,7 @@ __webpack_require__.add({
445
445
  };
446
446
  exports.toString = (value, space, next, key)=>null === value ? "null" : PRIMITIVE_TYPES[typeof value](value, space, next, key);
447
447
  },
448
- "../../node_modules/.pnpm/lilconfig@3.1.3/node_modules/lilconfig/src/index.js": function(module, __unused_webpack_exports, __webpack_require__) {
448
+ "../../node_modules/.pnpm/lilconfig@3.1.3/node_modules/lilconfig/src/index.js" (module, __unused_webpack_exports, __webpack_require__) {
449
449
  let path = __webpack_require__("path"), fs = __webpack_require__("fs"), os = __webpack_require__("os"), url = __webpack_require__("url"), fsReadFileAsync = fs.promises.readFile;
450
450
  function getDefaultSearchPlaces(name, sync) {
451
451
  return [
@@ -700,7 +700,7 @@ __webpack_require__.add({
700
700
  };
701
701
  };
702
702
  },
703
- "../../node_modules/.pnpm/on-finished@2.4.1/node_modules/on-finished/index.js": function(module, __unused_webpack_exports, __webpack_require__) {
703
+ "../../node_modules/.pnpm/on-finished@2.4.1/node_modules/on-finished/index.js" (module, __unused_webpack_exports, __webpack_require__) {
704
704
  module.exports = onFinished, module.exports.isFinished = isFinished;
705
705
  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) {
706
706
  process.nextTick(fn.bind.apply(fn, arguments));
@@ -766,7 +766,7 @@ __webpack_require__.add({
766
766
  return (asyncHooks.AsyncResource && (res = new asyncHooks.AsyncResource(fn.name || 'bound-anonymous-fn')), res && res.runInAsyncScope) ? res.runInAsyncScope.bind(res, fn, null) : fn;
767
767
  }
768
768
  },
769
- "../../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__) {
769
+ "../../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__) {
770
770
  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");
771
771
  async function processResult(ctx, result) {
772
772
  let obj, file = result.filepath || '', projectConfig = ((obj = result.config) && obj.__esModule ? obj : {
@@ -840,7 +840,7 @@ __webpack_require__.add({
840
840
  });
841
841
  };
842
842
  },
843
- "../../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__) {
843
+ "../../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__) {
844
844
  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");
845
845
  module.exports = async function options(config, file) {
846
846
  if (config.parser && 'string' == typeof config.parser) try {
@@ -861,7 +861,7 @@ __webpack_require__.add({
861
861
  return config;
862
862
  };
863
863
  },
864
- "../../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__) {
864
+ "../../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__) {
865
865
  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");
866
866
  async function load(plugin, options, file) {
867
867
  try {
@@ -878,9 +878,9 @@ __webpack_require__.add({
878
878
  }), list;
879
879
  };
880
880
  },
881
- "../../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__) {
881
+ "../../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__) {
882
882
  let tsx, jiti;
883
- var __filename = __webpack_fileURLToPath__(import.meta.url);
883
+ var __filename = __rspack_fileURLToPath(import.meta.url);
884
884
  let { createRequire } = __webpack_require__("node:module"), { pathToFileURL } = __webpack_require__("node:url"), TS_EXT_RE = /\.[mc]?ts$/, importError = [];
885
885
  module.exports = async function req(name, rootFile = __filename) {
886
886
  let url = createRequire(rootFile).resolve(name);
@@ -909,28 +909,28 @@ __webpack_require__.add({
909
909
  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')}`);
910
910
  };
911
911
  },
912
- async_hooks: function(module) {
912
+ async_hooks (module) {
913
913
  module.exports = __rspack_external_async_hooks;
914
914
  },
915
- fs: function(module) {
915
+ fs (module) {
916
916
  module.exports = __rspack_external_fs;
917
917
  },
918
- "node:module": function(module) {
918
+ "node:module" (module) {
919
919
  module.exports = __rspack_external_node_module_ab9f2194;
920
920
  },
921
- "node:path": function(module) {
921
+ "node:path" (module) {
922
922
  module.exports = __rspack_external_node_path_c5b9b54f;
923
923
  },
924
- "node:url": function(module) {
924
+ "node:url" (module) {
925
925
  module.exports = __rspack_external_node_url_e96de089;
926
926
  },
927
- os: function(module) {
927
+ os (module) {
928
928
  module.exports = __rspack_external_os;
929
929
  },
930
- path: function(module) {
930
+ path (module) {
931
931
  module.exports = __rspack_external_path;
932
932
  },
933
- url: function(module) {
933
+ url (module) {
934
934
  module.exports = __rspack_external_url;
935
935
  }
936
936
  });
@@ -2395,11 +2395,14 @@ function resolveFileName(stats) {
2395
2395
  }
2396
2396
  function formatModuleTrace(stats, errorFile) {
2397
2397
  if (!stats.moduleTrace) return;
2398
- let moduleNames = stats.moduleTrace.map((trace)=>trace.originName).filter(Boolean);
2398
+ let moduleNames = stats.moduleTrace.map((trace)=>trace.originName && removeLoaderChainDelimiter(trace.originName)).filter(Boolean);
2399
2399
  if (!moduleNames.length) return;
2400
- errorFile && moduleNames.unshift(`${errorFile} ${color.bold(color.red('×'))}`);
2400
+ if (errorFile) {
2401
+ let formatted = removeLoaderChainDelimiter(errorFile);
2402
+ moduleNames[0] !== formatted && moduleNames.unshift(formatted);
2403
+ }
2401
2404
  let rawTrace = moduleNames.reverse().map((item)=>`\n ${item}`).join('');
2402
- return color.dim(`Import traces (entry → error):${rawTrace}`);
2405
+ return color.dim(`Import traces (entry → error):${rawTrace} ${color.bold(color.red('×'))}`);
2403
2406
  }
2404
2407
  function hintUnknownFiles(message) {
2405
2408
  let hint = 'You may need an appropriate loader to handle this file type.';
@@ -2441,8 +2444,17 @@ function hintUnknownFiles(message) {
2441
2444
  ])if (plugin.test.test(message)) return message.replace(hint, plugin.hint);
2442
2445
  return message;
2443
2446
  }
2444
- function formatStatsError(stats) {
2445
- let fileName = resolveFileName(stats), message = `${!fileName ? '' : /:\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`}${stats.message}`, verbose = 'verbose' === logger.level;
2447
+ function formatStatsError(stats, root) {
2448
+ let fileName = resolveFileName(stats), message = `${((fileName, stats, root)=>{
2449
+ if (!fileName) return '';
2450
+ let DATA_URI_PREFIX = "data:text/javascript,";
2451
+ if (fileName.startsWith(DATA_URI_PREFIX)) {
2452
+ let snippet = fileName.replace(DATA_URI_PREFIX, '');
2453
+ return snippet.length > 30 && (snippet = `${snippet.slice(0, 30)}...`), `File: ${color.cyan('data-uri virtual module')} ${color.dim(`(${snippet})`)}\n`;
2454
+ }
2455
+ let prefix = root + external_node_path_.sep;
2456
+ 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`;
2457
+ })(fileName, stats, root)}${stats.message}`, verbose = 'verbose' === logger.level;
2446
2458
  verbose && (stats.details && (message += `\nDetails: ${stats.details}\n`), stats.stack && (message += `\n${stats.stack}`));
2447
2459
  let moduleTrace = formatModuleTrace(stats, fileName);
2448
2460
  moduleTrace && (message += moduleTrace);
@@ -2464,7 +2476,7 @@ function formatStatsError(stats) {
2464
2476
  };
2465
2477
  if (message.includes('need an additional plugin to handle "node:" URIs')) return getTips('node:*');
2466
2478
  if (!message.includes("Can't resolve")) return message;
2467
- let matchArray = message.match(/Can't resolve '(\w+)'/);
2479
+ let matchArray = stripVTControlCharacters(message).match(/Can't resolve '(\w+)'/);
2468
2480
  if (!matchArray) return message;
2469
2481
  let moduleName = matchArray[1];
2470
2482
  return moduleName && [
@@ -2548,12 +2560,12 @@ function getRsbuildStats(statsInstance, compiler, action) {
2548
2560
  let statsOptions = getStatsOptions(compiler, action);
2549
2561
  return statsInstance.toJson(statsOptions);
2550
2562
  }
2551
- function formatStats(stats, hasErrors) {
2563
+ function formatStats(stats, hasErrors, root) {
2552
2564
  if (hasErrors) return {
2553
- message: formatErrorMessage(getStatsErrors(stats).map((item)=>formatStatsError(item))),
2565
+ message: formatErrorMessage(getStatsErrors(stats).map((item)=>formatStatsError(item, root))),
2554
2566
  level: 'error'
2555
2567
  };
2556
- let warningMessages = getStatsWarnings(stats).map((item)=>formatStatsError(item));
2568
+ let warningMessages = getStatsWarnings(stats).map((item)=>formatStatsError(item, root));
2557
2569
  if (warningMessages.length) {
2558
2570
  let title = color.bold(color.yellow(warningMessages.length > 1 ? 'Build warnings: \n' : 'Build warning: \n'));
2559
2571
  return {
@@ -3406,7 +3418,7 @@ function createPublicContext(context) {
3406
3418
  async function createContext(options, userConfig) {
3407
3419
  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';
3408
3420
  return {
3409
- version: "1.6.11",
3421
+ version: "1.6.12-canary-20251204065915",
3410
3422
  rootPath,
3411
3423
  distPath: '',
3412
3424
  cachePath,
@@ -4008,7 +4020,7 @@ async function createCompiler_createCompiler(options) {
4008
4020
  }), compiler.hooks.done.tap(HOOK_NAME, (statsInstance)=>{
4009
4021
  let stats = getRsbuildStats(statsInstance, compiler, context.action), hasErrors = statsInstance.hasErrors();
4010
4022
  context.buildState.stats = stats, context.buildState.status = 'done', context.buildState.hasErrors = hasErrors, context.socketServer?.onBuildDone();
4011
- let { message, level } = formatStats(stats, hasErrors);
4023
+ let { message, level } = formatStats(stats, hasErrors, options.context.rootPath);
4012
4024
  'error' === level && logger.error(message), 'warning' === level && logger.warn(message), isMultiCompiler || printTime(0, hasErrors), isCompiling = !1;
4013
4025
  }), 'dev' === context.action && registerDevHook({
4014
4026
  context,
@@ -4325,7 +4337,38 @@ async function gzipSize(input) {
4325
4337
  let data = await fileSize_gzip(input);
4326
4338
  return Buffer.byteLength(data);
4327
4339
  }
4328
- 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;
4340
+ function getSnapshotPath(dir) {
4341
+ return external_node_path_.default.join(dir, 'rsbuild/file-sizes.json');
4342
+ }
4343
+ function normalizeFileName(fileName) {
4344
+ return fileName.replace(/\.[a-f0-9]{8,}\./g, '.');
4345
+ }
4346
+ async function loadPreviousSizes(dir) {
4347
+ let snapshotPath = getSnapshotPath(dir);
4348
+ try {
4349
+ let content = await node_fs.promises.readFile(snapshotPath, 'utf-8');
4350
+ return JSON.parse(content);
4351
+ } catch {
4352
+ return null;
4353
+ }
4354
+ }
4355
+ async function saveSnapshots(dir, snapshots) {
4356
+ let snapshotPath = getSnapshotPath(dir);
4357
+ try {
4358
+ await node_fs.promises.mkdir(external_node_path_.default.dirname(snapshotPath), {
4359
+ recursive: !0
4360
+ }), await node_fs.promises.writeFile(snapshotPath, JSON.stringify(snapshots, null, 2));
4361
+ } catch (err) {
4362
+ logger.debug('Failed to save file size snapshots:', err);
4363
+ }
4364
+ }
4365
+ let EXCLUDE_ASSET_REGEX = /\.(?:map|LICENSE\.txt|d\.ts)$/, excludeAsset = (asset)=>EXCLUDE_ASSET_REGEX.test(asset.name), formatDiff = (diff)=>{
4366
+ let label = `(${diff > 0 ? '+' : '-'}${calcFileSize(Math.abs(diff))})`;
4367
+ return {
4368
+ label: (diff > 0 ? color.red : color.green)(label),
4369
+ length: label.length
4370
+ };
4371
+ }, getAssetColor = (size)=>size > 300000 ? color.red : size > 100000 ? color.yellow : color.green;
4329
4372
  function getHeader(maxFileLength, maxSizeLength, fileHeader, showGzipHeader) {
4330
4373
  let lengths = [
4331
4374
  maxFileLength,
@@ -4345,21 +4388,42 @@ let calcFileSize = (len)=>{
4345
4388
  let val = len / 1000;
4346
4389
  return `${val.toFixed(val < 1 ? 2 : 1)} kB`;
4347
4390
  }, 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;
4348
- async function printFileSizes(options, stats, rootPath, distPath, environmentName) {
4349
- let logs = [], showDetail = !1 !== options.detail, showTotal = !1 !== options.total;
4350
- if (!showTotal && !showDetail) return logs;
4351
- let exclude = options.exclude ?? excludeAsset, relativeDistPath = external_node_path_.default.relative(rootPath, distPath), formatAsset = async (asset)=>{
4352
- let fileName = asset.name.split('?')[0], contents = await node_fs.promises.readFile(external_node_path_.default.join(distPath, fileName)), size = Buffer.byteLength(contents), gzippedSize = options.compressed && COMPRESSIBLE_REGEX.test(fileName) ? await gzipSize(contents) : null, gzipSizeLabel = gzippedSize ? getAssetColor(gzippedSize)(calcFileSize(gzippedSize)) : null;
4391
+ async function printFileSizes(options, stats, rootPath, distPath, environmentName, previousSizes) {
4392
+ let logs = [], showDetail = !1 !== options.detail, showDiff = !1 !== options.diff && null !== previousSizes, showTotal = !1 !== options.total;
4393
+ if (!showTotal && !showDetail) return {
4394
+ logs
4395
+ };
4396
+ let exclude = options.exclude ?? excludeAsset, relativeDistPath = external_node_path_.default.relative(rootPath, distPath), sizes = {}, formatAsset = async (asset)=>{
4397
+ let fileName = asset.name.split('?')[0], contents = await node_fs.promises.readFile(external_node_path_.default.join(distPath, fileName)), size = Buffer.byteLength(contents), gzippedSize = options.compressed && COMPRESSIBLE_REGEX.test(fileName) ? await gzipSize(contents) : null, normalizedName = normalizeFileName(fileName);
4398
+ sizes[normalizeFileName(fileName)] = {
4399
+ size,
4400
+ gzippedSize: gzippedSize ?? void 0
4401
+ };
4402
+ let sizeLabel = calcFileSize(size), sizeLabelLength = sizeLabel.length, gzipSizeLabel = gzippedSize ? getAssetColor(gzippedSize)(calcFileSize(gzippedSize)) : null;
4403
+ if (showDiff) {
4404
+ let sizeData = previousSizes[environmentName]?.[normalizedName], sizeDiff = size - (sizeData?.size ?? 0);
4405
+ if (0 !== sizeDiff) {
4406
+ let { label, length } = formatDiff(sizeDiff);
4407
+ sizeLabel += ` ${label}`, sizeLabelLength += length + 1;
4408
+ }
4409
+ if (gzippedSize) {
4410
+ let gzipDiff = gzippedSize - (sizeData?.gzippedSize ?? 0);
4411
+ 0 !== gzipDiff && (gzipSizeLabel += ` ${formatDiff(gzipDiff).label}`);
4412
+ }
4413
+ }
4353
4414
  return {
4354
4415
  size,
4416
+ sizeLabel,
4417
+ sizeLabelLength,
4355
4418
  folder: external_node_path_.default.join(relativeDistPath, external_node_path_.default.dirname(fileName)),
4356
4419
  name: external_node_path_.default.basename(fileName),
4357
4420
  gzippedSize,
4358
- sizeLabel: calcFileSize(size),
4359
4421
  gzipSizeLabel
4360
4422
  };
4361
4423
  }, getAssets = async ()=>Promise.all(getAssetsFromStats(stats).filter((asset)=>!exclude(asset) && (!options.include || options.include(asset))).map((asset)=>formatAsset(asset))), assets = await getAssets();
4362
- if (0 === assets.length) return logs;
4424
+ if (0 === assets.length) return {
4425
+ logs
4426
+ };
4363
4427
  logs.push(''), assets.sort((a, b)=>a.size - b.size);
4364
4428
  let totalSize = 0, totalGzipSize = 0;
4365
4429
  for (let asset of (showTotal = showTotal && !(showDetail && 1 === assets.length), assets))totalSize += asset.size, options.compressed && (totalGzipSize += asset.gzippedSize ?? asset.size);
@@ -4374,12 +4438,10 @@ async function printFileSizes(options, stats, rootPath, distPath, environmentNam
4374
4438
  totalGzipSize
4375
4439
  }) : null;
4376
4440
  if (showDetail) {
4377
- 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));
4441
+ 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));
4378
4442
  for (let asset of (logs.push(getHeader(maxFileLength, maxSizeLength, fileHeader, showGzipHeader)), assets)){
4379
- let { sizeLabel } = asset, { name, folder, gzipSizeLabel } = asset, fileNameLength = (folder + external_node_path_.default.sep + name).length, sizeLength = sizeLabel.length;
4380
- sizeLength < maxSizeLength && (sizeLabel += ' '.repeat(maxSizeLength - sizeLength));
4381
- let fileNameLabel = color.dim(asset.folder + external_node_path_.default.sep) + coloringAssetName(asset.name);
4382
- fileNameLength < maxFileLength && (fileNameLabel += ' '.repeat(maxFileLength - fileNameLength));
4443
+ 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);
4444
+ sizeLabelLength < maxSizeLength && (sizeLabel += ' '.repeat(maxSizeLength - sizeLabelLength)), fileNameLength < maxFileLength && (fileNameLabel += ' '.repeat(maxFileLength - fileNameLength));
4383
4445
  let log = `${fileNameLabel} ${sizeLabel}`;
4384
4446
  gzipSizeLabel && (log += ` ${gzipSizeLabel}`), logs.push(log);
4385
4447
  }
@@ -4404,7 +4466,10 @@ async function printFileSizes(options, stats, rootPath, distPath, environmentNam
4404
4466
  options.compressed && (log += color.green(` (${calcFileSize(totalGzipSize)} gzipped)`)), logs.push(log);
4405
4467
  }
4406
4468
  }
4407
- return logs.push(''), logs;
4469
+ return logs.push(''), {
4470
+ logs,
4471
+ sizes
4472
+ };
4408
4473
  }
4409
4474
  let entryNameSymbol = Symbol('entryName'), VOID_TAGS = [
4410
4475
  'area',
@@ -4984,13 +5049,14 @@ function doesChunkBelongToHtml({ chunk, htmlPluginData }) {
4984
5049
  }
4985
5050
  let isCSSPath = (filePath)=>filePath.endsWith('.css');
4986
5051
  function normalizeManifestObjectConfig(manifest) {
4987
- if ('string' == typeof manifest) return {
4988
- filename: manifest
4989
- };
4990
5052
  let defaultOptions = {
5053
+ prefix: !0,
4991
5054
  filename: 'manifest.json'
4992
5055
  };
4993
- return 'boolean' == typeof manifest ? defaultOptions : {
5056
+ return 'string' == typeof manifest ? {
5057
+ ...defaultOptions,
5058
+ filename: manifest
5059
+ } : 'boolean' == typeof manifest ? defaultOptions : {
4994
5060
  ...defaultOptions,
4995
5061
  ...manifest
4996
5062
  };
@@ -6237,7 +6303,7 @@ class SocketServer {
6237
6303
  });
6238
6304
  }
6239
6305
  sendError(errors, token) {
6240
- let formattedErrors = errors.map((item)=>formatStatsError(item));
6306
+ let formattedErrors = errors.map((item)=>formatStatsError(item, this.context.rootPath));
6241
6307
  this.sockWrite({
6242
6308
  type: 'errors',
6243
6309
  data: {
@@ -6247,7 +6313,7 @@ class SocketServer {
6247
6313
  }, token);
6248
6314
  }
6249
6315
  sendWarning(warnings, token) {
6250
- let formattedWarnings = warnings.map((item)=>formatStatsError(item));
6316
+ let formattedWarnings = warnings.map((item)=>formatStatsError(item, this.context.rootPath));
6251
6317
  this.sockWrite({
6252
6318
  type: 'warnings',
6253
6319
  data: {
@@ -7685,25 +7751,29 @@ function applyDefaultPlugins(pluginManager, context) {
7685
7751
  {
7686
7752
  name: 'rsbuild:file-size',
7687
7753
  setup (api) {
7688
- api.onAfterBuild(async ({ stats, environments, isFirstCompile })=>{
7754
+ api.onAfterBuild(async ({ stats, isFirstCompile })=>{
7689
7755
  let { hasErrors } = context.buildState;
7690
7756
  if (!stats || hasErrors || !isFirstCompile) return;
7691
- let logs = [];
7692
- await Promise.all(Object.values(environments).map(async (environment, index)=>{
7757
+ let environments = context.environmentList.filter(({ config })=>!1 !== config.performance.printFileSize);
7758
+ if (!environments.length) return;
7759
+ let showDiff = environments.some((environment)=>{
7693
7760
  let { printFileSize } = environment.config.performance;
7694
- if (!1 === printFileSize) return;
7695
- let defaultConfig = {
7761
+ return 'object' == typeof printFileSize && !!printFileSize.diff;
7762
+ }), previousSizes = showDiff ? await loadPreviousSizes(api.context.cachePath) : null, nextSizes = {}, logs = await Promise.all(environments.map(async ({ name, index, config, distPath })=>{
7763
+ let { printFileSize } = config.performance, defaultConfig = {
7696
7764
  total: !0,
7697
7765
  detail: !0,
7698
- compressed: 'node' !== environment.config.output.target
7766
+ diff: !1,
7767
+ compressed: 'node' !== config.output.target
7699
7768
  }, mergedConfig = !0 === printFileSize ? defaultConfig : {
7700
7769
  ...defaultConfig,
7701
7770
  ...printFileSize
7702
- }, statsItem = 'stats' in stats ? stats.stats[index] : stats, statsLogs = await printFileSizes(mergedConfig, statsItem, api.context.rootPath, environment.distPath, environment.name);
7703
- logs.push(...statsLogs);
7771
+ }, statsItem = 'stats' in stats ? stats.stats[index] : stats, { logs: sizeLogs, sizes } = await printFileSizes(mergedConfig, statsItem, api.context.rootPath, distPath, name, previousSizes);
7772
+ return sizes && (nextSizes[name] = sizes), sizeLogs.join('\n');
7704
7773
  })).catch((err)=>{
7705
7774
  logger.warn('Failed to print file size.'), logger.warn(err);
7706
- }), logger.log(logs.join('\n'));
7775
+ });
7776
+ logs && logger.log(logs.join('\n')), showDiff && await saveSnapshots(api.context.cachePath, nextSizes);
7707
7777
  });
7708
7778
  }
7709
7779
  },
@@ -8585,67 +8655,69 @@ try {
8585
8655
  let { output: { manifest }, dev: { writeToDisk } } = environment.config;
8586
8656
  if (!1 === manifest) return;
8587
8657
  let manifestOptions = normalizeManifestObjectConfig(manifest), { RspackManifestPlugin } = requireCompiledPackage('rspack-manifest-plugin'), { htmlPaths } = environment, filter = manifestOptions.filter ?? ((file)=>!file.name.endsWith('.LICENSE.txt'));
8588
- manifestFilenames.set(environment.name, manifestOptions.filename), chain.plugin(CHAIN_ID.PLUGIN.MANIFEST).use(RspackManifestPlugin, [
8589
- {
8590
- fileName: manifestOptions.filename,
8591
- filter,
8592
- writeToFileEmit: isDev && !0 !== writeToDisk,
8593
- generate: (_seed, files, entries, { compilation })=>{
8594
- let chunkEntries = new Map(), licenseMap = new Map(), publicPath = getPublicPathFromCompiler(compilation), integrity = {}, allFiles = files.map((file)=>{
8595
- if (file.integrity && (integrity[file.path] = file.integrity), file.chunk) for (let entryName of recursiveChunkEntryNames(file.chunk))chunkEntries.set(entryName, [
8596
- file,
8597
- ...chunkEntries.get(entryName) || []
8598
- ]);
8599
- if (file.path.endsWith('.LICENSE.txt')) {
8600
- let sourceFilePath = file.path.split('.LICENSE.txt')[0];
8601
- licenseMap.set(sourceFilePath, file.path);
8602
- }
8603
- return file.path;
8604
- }), manifestEntries = {};
8605
- for (let [entryName, chunkFiles] of chunkEntries){
8606
- let assets = new Set(), initialJS = [], initialCSS = [], asyncJS = [], asyncCSS = [];
8607
- if (entries[entryName]) for (let filePath of entries[entryName]){
8608
- let fileURL = ensureAssetPrefix(filePath, publicPath);
8609
- isCSSPath(filePath) ? initialCSS.push(fileURL) : initialJS.push(fileURL);
8610
- }
8611
- for (let file of chunkFiles){
8612
- file.isInitial || (isCSSPath(file.path) ? asyncCSS.push(file.path) : asyncJS.push(file.path));
8613
- let relatedLICENSE = licenseMap.get(file.path);
8614
- if (relatedLICENSE && assets.add(relatedLICENSE), file.chunk) for (let auxiliaryFile of file.chunk.auxiliaryFiles)assets.add(auxiliaryFile);
8615
- }
8616
- let entryManifest = {};
8617
- assets.size && (entryManifest.assets = Array.from(assets));
8618
- let htmlPath = files.find((f)=>f.name === htmlPaths[entryName])?.path;
8619
- htmlPath && (entryManifest.html = [
8620
- htmlPath
8621
- ]), initialJS.length && (entryManifest.initial = {
8622
- js: initialJS
8623
- }), initialCSS.length && (entryManifest.initial = {
8624
- ...entryManifest.initial || {},
8625
- css: initialCSS
8626
- }), asyncJS.length && (entryManifest.async = {
8627
- js: asyncJS
8628
- }), asyncCSS.length && (entryManifest.async = {
8629
- ...entryManifest.async || {},
8630
- css: asyncCSS
8631
- }), manifestEntries[entryName] = entryManifest;
8658
+ manifestFilenames.set(environment.name, manifestOptions.filename);
8659
+ let pluginOptions = {
8660
+ fileName: manifestOptions.filename,
8661
+ filter,
8662
+ writeToFileEmit: isDev && !0 !== writeToDisk,
8663
+ generate: (_seed, files, entries, { compilation })=>{
8664
+ let chunkEntries = new Map(), licenseMap = new Map(), publicPath = getPublicPathFromCompiler(compilation), integrity = {}, allFiles = files.map((file)=>{
8665
+ if (file.integrity && (integrity[file.path] = file.integrity), file.chunk) for (let entryName of recursiveChunkEntryNames(file.chunk))chunkEntries.set(entryName, [
8666
+ file,
8667
+ ...chunkEntries.get(entryName) || []
8668
+ ]);
8669
+ if (file.path.endsWith('.LICENSE.txt')) {
8670
+ let sourceFilePath = file.path.split('.LICENSE.txt')[0];
8671
+ licenseMap.set(sourceFilePath, file.path);
8632
8672
  }
8633
- let manifestData = {
8634
- allFiles,
8635
- entries: manifestEntries,
8636
- integrity
8637
- };
8638
- if (manifestOptions.generate) {
8639
- let generatedManifest = manifestOptions.generate({
8640
- files,
8641
- manifestData
8642
- });
8643
- if (isObject(generatedManifest)) return environment.manifest = generatedManifest, generatedManifest;
8644
- throw Error(`${color.dim('[rsbuild:manifest]')} \`manifest.generate\` function must return a valid manifest object.`);
8673
+ return file.path;
8674
+ }), manifestEntries = {};
8675
+ for (let [entryName, chunkFiles] of chunkEntries){
8676
+ let assets = new Set(), initialJS = [], initialCSS = [], asyncJS = [], asyncCSS = [];
8677
+ if (entries[entryName]) for (let filePath of entries[entryName]){
8678
+ let fileURL = manifestOptions.prefix ? ensureAssetPrefix(filePath, publicPath) : filePath;
8679
+ isCSSPath(filePath) ? initialCSS.push(fileURL) : initialJS.push(fileURL);
8680
+ }
8681
+ for (let file of chunkFiles){
8682
+ file.isInitial || (isCSSPath(file.path) ? asyncCSS.push(file.path) : asyncJS.push(file.path));
8683
+ let relatedLICENSE = licenseMap.get(file.path);
8684
+ if (relatedLICENSE && assets.add(relatedLICENSE), file.chunk) for (let auxiliaryFile of file.chunk.auxiliaryFiles)assets.add(auxiliaryFile);
8645
8685
  }
8646
- return environment.manifest = manifestData, manifestData;
8686
+ let entryManifest = {};
8687
+ assets.size && (entryManifest.assets = Array.from(assets));
8688
+ let htmlPath = files.find((f)=>f.name === htmlPaths[entryName])?.path;
8689
+ htmlPath && (entryManifest.html = [
8690
+ htmlPath
8691
+ ]), initialJS.length && (entryManifest.initial = {
8692
+ js: initialJS
8693
+ }), initialCSS.length && (entryManifest.initial = {
8694
+ ...entryManifest.initial || {},
8695
+ css: initialCSS
8696
+ }), asyncJS.length && (entryManifest.async = {
8697
+ js: asyncJS
8698
+ }), asyncCSS.length && (entryManifest.async = {
8699
+ ...entryManifest.async || {},
8700
+ css: asyncCSS
8701
+ }), manifestEntries[entryName] = entryManifest;
8647
8702
  }
8703
+ let manifestData = {
8704
+ allFiles,
8705
+ entries: manifestEntries,
8706
+ integrity
8707
+ };
8708
+ if (manifestOptions.generate) {
8709
+ let generatedManifest = manifestOptions.generate({
8710
+ files,
8711
+ manifestData
8712
+ });
8713
+ if (isObject(generatedManifest)) return environment.manifest = generatedManifest, generatedManifest;
8714
+ throw Error(`${color.dim('[rsbuild:manifest]')} \`manifest.generate\` function must return a valid manifest object.`);
8715
+ }
8716
+ return environment.manifest = manifestData, manifestData;
8648
8717
  }
8718
+ };
8719
+ manifestOptions.prefix || (pluginOptions.publicPath = ''), chain.plugin(CHAIN_ID.PLUGIN.MANIFEST).use(RspackManifestPlugin, [
8720
+ pluginOptions
8649
8721
  ]);
8650
8722
  }), api.onAfterCreateCompiler(()=>{
8651
8723
  if (manifestFilenames.size <= 1) return void manifestFilenames.clear();
@@ -9047,7 +9119,7 @@ let applyServerOptions = (command)=>{
9047
9119
  };
9048
9120
  function setupCommands() {
9049
9121
  let cli = ((name = "")=>new CAC(name))('rsbuild');
9050
- 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)', {
9122
+ cli.version("1.6.12-canary-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)', {
9051
9123
  default: 'auto'
9052
9124
  }).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', {
9053
9125
  type: [
@@ -9116,7 +9188,7 @@ function initNodeEnv() {
9116
9188
  }
9117
9189
  function showGreeting() {
9118
9190
  let { npm_execpath, npm_lifecycle_event, NODE_RUN_SCRIPT_NAME } = process.env, isBun = npm_execpath?.includes('.bun');
9119
- logger.greet(`${'npx' === npm_lifecycle_event || isBun || NODE_RUN_SCRIPT_NAME ? '\n' : ''}Rsbuild v1.6.11\n`);
9191
+ logger.greet(`${'npx' === npm_lifecycle_event || isBun || NODE_RUN_SCRIPT_NAME ? '\n' : ''}Rsbuild v1.6.12-canary-20251204065915\n`);
9120
9192
  }
9121
9193
  function setupLogLevel() {
9122
9194
  let logLevelIndex = process.argv.findIndex((item)=>'--log-level' === item || '--logLevel' === item);
@@ -9137,9 +9209,9 @@ function runCLI() {
9137
9209
  logger.error('Failed to start Rsbuild CLI.'), logger.error(err);
9138
9210
  }
9139
9211
  }
9140
- let src_version = "1.6.11";
9212
+ let src_version = "1.6.12-canary-20251204065915";
9141
9213
  import * as __rspack_external_node_module_ab9f2194 from "node:module";
9142
9214
  import { createRequire as __rspack_createRequire } from "node:module";
9143
9215
  import * as __rspack_external_node_url_e96de089 from "node:url";
9144
- import { fileURLToPath as __webpack_fileURLToPath__ } from "node:url";
9216
+ import { fileURLToPath as __rspack_fileURLToPath } from "node:url";
9145
9217
  export { PLUGIN_CSS_NAME, PLUGIN_SWC_NAME, createRsbuild, defaultAllowedOrigins, defineConfig, ensureAssetPrefix, external_node_util_promisify, loadConfig_loadConfig as loadConfig, loadEnv, logger, mergeRsbuildConfig, node_fs, node_os, node_process, rspack_rspack as rspack, runCLI, src_version as version };
package/dist/2~open.cjs CHANGED
@@ -3,7 +3,7 @@ const __rslib_import_meta_url__ = 'undefined' == typeof document ? new (require(
3
3
  exports.ids = [
4
4
  "664"
5
5
  ], exports.modules = {
6
- "../../node_modules/.pnpm/open@11.0.0/node_modules/open/index.js": function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
6
+ "../../node_modules/.pnpm/open@11.0.0/node_modules/open/index.js" (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
7
7
  let isDockerCached, cachedResult, canAccessPowerShellPromise, mountPoint, defaultMountPoint;
8
8
  __webpack_require__.d(__webpack_exports__, {
9
9
  default: ()=>node_modules_open,
@@ -4,7 +4,7 @@ const __rslib_import_meta_url__ = 'undefined' == typeof document ? new (require(
4
4
  exports.ids = [
5
5
  "603"
6
6
  ], exports.modules = {
7
- "../../node_modules/.pnpm/range-parser@1.2.1/node_modules/range-parser/index.js": function(module) {
7
+ "../../node_modules/.pnpm/range-parser@1.2.1/node_modules/range-parser/index.js" (module) {
8
8
  function combineRanges(ranges) {
9
9
  for(var ordered = ranges.map(mapWithIndex).sort(sortByRangeStart), j = 0, i = 1; i < ordered.length; i++){
10
10
  var range = ordered[i], current = ordered[j];