@rspack/core 1.0.0-alpha.4 → 1.0.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (102) hide show
  1. package/compiled/zod/index.d.ts +138 -52
  2. package/compiled/zod/index.js +300 -103
  3. package/compiled/zod/package.json +1 -1
  4. package/compiled/zod-validation-error/index.js +6 -6
  5. package/dist/Compilation.d.ts +21 -3
  6. package/dist/Compilation.js +64 -49
  7. package/dist/Compiler.js +28 -28
  8. package/dist/ErrorHelpers.js +2 -4
  9. package/dist/FileSystem.js +6 -6
  10. package/dist/Module.js +2 -6
  11. package/dist/ModuleTypeConstants.d.ts +45 -69
  12. package/dist/ModuleTypeConstants.js +24 -77
  13. package/dist/NormalModule.js +6 -6
  14. package/dist/Stats.js +4 -6
  15. package/dist/Template.d.ts +31 -147
  16. package/dist/Template.js +40 -236
  17. package/dist/Watching.js +2 -2
  18. package/dist/builtin-loader/lightningcss/index.d.ts +89 -0
  19. package/dist/builtin-loader/lightningcss/index.js +175 -0
  20. package/dist/builtin-plugin/BannerPlugin.d.ts +24 -48
  21. package/dist/builtin-plugin/DefinePlugin.js +9 -13
  22. package/dist/builtin-plugin/EntryPlugin.d.ts +2 -2
  23. package/dist/builtin-plugin/ExternalsPlugin.d.ts +24 -0
  24. package/dist/builtin-plugin/HtmlRspackPlugin.d.ts +8 -8
  25. package/dist/builtin-plugin/JavascriptModulesPlugin.d.ts +2 -2
  26. package/dist/builtin-plugin/LightningCssMiminizerRspackPlugin.d.ts +10 -3
  27. package/dist/builtin-plugin/LightningCssMiminizerRspackPlugin.js +4 -1
  28. package/dist/builtin-plugin/SplitChunksPlugin.js +7 -17
  29. package/dist/builtin-plugin/SwcJsMinimizerPlugin.js +15 -23
  30. package/dist/builtin-plugin/base.js +1 -3
  31. package/dist/builtin-plugin/css-extract/hmr/hotModuleReplacement.d.ts +3 -3
  32. package/dist/builtin-plugin/css-extract/hmr/hotModuleReplacement.js +17 -66
  33. package/dist/builtin-plugin/css-extract/hmr/normalizeUrl.d.ts +2 -0
  34. package/dist/builtin-plugin/css-extract/hmr/{normalize-url.js → normalizeUrl.js} +15 -24
  35. package/dist/builtin-plugin/css-extract/loader.js +6 -6
  36. package/dist/builtin-plugin/css-extract/utils.js +3 -3
  37. package/dist/builtin-plugin/lazy-compilation/backend.d.ts +3 -3
  38. package/dist/builtin-plugin/lazy-compilation/backend.js +1 -1
  39. package/dist/config/adapter.d.ts +1 -1
  40. package/dist/config/adapter.js +31 -30
  41. package/dist/config/adapterRuleUse.d.ts +5 -5
  42. package/dist/config/adapterRuleUse.js +23 -1
  43. package/dist/config/browserslistTargetHandler.d.ts +17 -15
  44. package/dist/config/browserslistTargetHandler.js +27 -33
  45. package/dist/config/defaults.js +27 -28
  46. package/dist/config/normalization.d.ts +2 -0
  47. package/dist/config/normalization.js +5 -5
  48. package/dist/config/target.d.ts +48 -109
  49. package/dist/config/target.js +50 -86
  50. package/dist/config/zod.d.ts +2398 -2212
  51. package/dist/config/zod.js +29 -19
  52. package/dist/container/ContainerPlugin.d.ts +7 -7
  53. package/dist/container/options.js +1 -1
  54. package/dist/exports.d.ts +4 -4
  55. package/dist/exports.js +2 -2
  56. package/dist/lib/CacheFacade.js +1 -0
  57. package/dist/lib/EntryOptionPlugin.js +2 -2
  58. package/dist/lib/ModuleFilenameHelpers.js +1 -3
  59. package/dist/lib/WebpackError.js +1 -1
  60. package/dist/lib/cache/mergeEtags.js +5 -11
  61. package/dist/lib/formatLocation.js +3 -5
  62. package/dist/loader-runner/LoaderLoadingError.d.ts +11 -1
  63. package/dist/loader-runner/LoaderLoadingError.js +3 -5
  64. package/dist/loader-runner/index.js +23 -25
  65. package/dist/loader-runner/loadLoader.d.ts +11 -2
  66. package/dist/loader-runner/loadLoader.js +18 -20
  67. package/dist/logging/createConsoleLogger.js +2 -6
  68. package/dist/logging/truncateArgs.js +5 -9
  69. package/dist/node/NodeWatchFileSystem.js +5 -5
  70. package/dist/node/nodeConsole.js +2 -4
  71. package/dist/rspack.js +6 -6
  72. package/dist/rspackOptionsApply.js +3 -3
  73. package/dist/stats/DefaultStatsFactoryPlugin.js +65 -20
  74. package/dist/stats/DefaultStatsPresetPlugin.js +4 -4
  75. package/dist/stats/DefaultStatsPrinterPlugin.js +12 -17
  76. package/dist/stats/StatsFactory.js +13 -17
  77. package/dist/stats/StatsPrinter.js +7 -9
  78. package/dist/stats/statsFactoryUtils.d.ts +9 -10
  79. package/dist/util/AssetInfo.js +11 -7
  80. package/dist/util/SplitChunkSize.js +1 -1
  81. package/dist/util/bindingVersionCheck.js +6 -6
  82. package/dist/util/cleverMerge.d.ts +33 -57
  83. package/dist/util/cleverMerge.js +89 -145
  84. package/dist/util/comparators.js +3 -5
  85. package/dist/util/createHash.d.ts +4 -3
  86. package/dist/util/createHash.js +31 -45
  87. package/dist/util/fs.js +16 -20
  88. package/dist/util/hash/BatchedHash.d.ts +24 -9
  89. package/dist/util/hash/BatchedHash.js +16 -13
  90. package/dist/util/hash/index.d.ts +9 -9
  91. package/dist/util/hash/index.js +14 -11
  92. package/dist/util/hash/md4.d.ts +29 -2
  93. package/dist/util/hash/md4.js +7 -3
  94. package/dist/util/hash/wasm-hash.d.ts +52 -5
  95. package/dist/util/hash/wasm-hash.js +19 -22
  96. package/dist/util/hash/xxhash64.d.ts +29 -2
  97. package/dist/util/hash/xxhash64.js +7 -3
  98. package/dist/util/identifier.js +13 -19
  99. package/dist/util/index.js +1 -1
  100. package/dist/util/memoize.js +7 -9
  101. package/package.json +9 -8
  102. package/dist/builtin-plugin/css-extract/hmr/normalize-url.d.ts +0 -2
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- const util_1 = __importDefault(require("util"));
15
+ const node_util_1 = __importDefault(require("node:util"));
16
16
  const watchpack_1 = __importDefault(require("../../compiled/watchpack"));
17
17
  class NodeWatchFileSystem {
18
18
  constructor(inputFileSystem) {
@@ -91,7 +91,7 @@ class NodeWatchFileSystem {
91
91
  this.watcher.pause();
92
92
  }
93
93
  },
94
- getAggregatedRemovals: util_1.default.deprecate(() => {
94
+ getAggregatedRemovals: node_util_1.default.deprecate(() => {
95
95
  const items = this.watcher && this.watcher.aggregatedRemovals;
96
96
  if (items && this.inputFileSystem && this.inputFileSystem.purge) {
97
97
  const fs = this.inputFileSystem;
@@ -101,7 +101,7 @@ class NodeWatchFileSystem {
101
101
  }
102
102
  return items;
103
103
  }, "Watcher.getAggregatedRemovals is deprecated in favor of Watcher.getInfo since that's more performant.", "DEP_WEBPACK_WATCHER_GET_AGGREGATED_REMOVALS"),
104
- getAggregatedChanges: util_1.default.deprecate(() => {
104
+ getAggregatedChanges: node_util_1.default.deprecate(() => {
105
105
  const items = this.watcher && this.watcher.aggregatedChanges;
106
106
  if (items && this.inputFileSystem && this.inputFileSystem.purge) {
107
107
  const fs = this.inputFileSystem;
@@ -111,10 +111,10 @@ class NodeWatchFileSystem {
111
111
  }
112
112
  return items;
113
113
  }, "Watcher.getAggregatedChanges is deprecated in favor of Watcher.getInfo since that's more performant.", "DEP_WEBPACK_WATCHER_GET_AGGREGATED_CHANGES"),
114
- getFileTimeInfoEntries: util_1.default.deprecate(() => {
114
+ getFileTimeInfoEntries: node_util_1.default.deprecate(() => {
115
115
  return fetchTimeInfo().fileTimeInfoEntries;
116
116
  }, "Watcher.getFileTimeInfoEntries is deprecated in favor of Watcher.getInfo since that's more performant.", "DEP_WEBPACK_WATCHER_FILE_TIME_INFO_ENTRIES"),
117
- getContextTimeInfoEntries: util_1.default.deprecate(() => {
117
+ getContextTimeInfoEntries: node_util_1.default.deprecate(() => {
118
118
  return fetchTimeInfo().contextTimeInfoEntries;
119
119
  }, "Watcher.getContextTimeInfoEntries is deprecated in favor of Watcher.getInfo since that's more performant.", "DEP_WEBPACK_WATCHER_CONTEXT_TIME_INFO_ENTRIES"),
120
120
  getInfo: () => {
@@ -31,7 +31,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
31
31
  __setModuleDefault(result, mod);
32
32
  return result;
33
33
  };
34
- const util = __importStar(require("util"));
34
+ const util = __importStar(require("node:util"));
35
35
  const truncateArgs_1 = require("../logging/truncateArgs");
36
36
  module.exports = ({ colors, appendOnly, stream }) => {
37
37
  // @ts-expect-error
@@ -50,9 +50,7 @@ module.exports = ({ colors, appendOnly, stream }) => {
50
50
  str.replace(/\n/g, colorSuffix + "\n" + prefix + colorPrefix) +
51
51
  colorSuffix);
52
52
  }
53
- else {
54
- return prefix + str.replace(/\n/g, "\n" + prefix);
55
- }
53
+ return prefix + str.replace(/\n/g, "\n" + prefix);
56
54
  };
57
55
  const clearStatusMessage = () => {
58
56
  if (hasStatusMessage) {
package/dist/rspack.js CHANGED
@@ -13,8 +13,8 @@ exports.Stats = exports.rspack = exports.MultiStats = exports.createMultiCompile
13
13
  * Copyright (c) JS Foundation and other contributors
14
14
  * https://github.com/webpack/webpack/blob/main/LICENSE
15
15
  */
16
- const assert_1 = __importDefault(require("assert"));
17
- const util_1 = __importDefault(require("util"));
16
+ const node_assert_1 = __importDefault(require("node:assert"));
17
+ const node_util_1 = __importDefault(require("node:util"));
18
18
  const Compiler_1 = require("./Compiler");
19
19
  const MultiCompiler_1 = require("./MultiCompiler");
20
20
  const MultiStats_1 = __importDefault(require("./MultiStats"));
@@ -24,7 +24,7 @@ Object.defineProperty(exports, "Stats", { enumerable: true, get: function () { r
24
24
  const config_1 = require("./config");
25
25
  const NodeEnvironmentPlugin_1 = __importDefault(require("./node/NodeEnvironmentPlugin"));
26
26
  const rspackOptionsApply_1 = require("./rspackOptionsApply");
27
- const util_2 = require("./util");
27
+ const util_1 = require("./util");
28
28
  const validate_1 = require("./util/validate");
29
29
  function createMultiCompiler(options) {
30
30
  const compilers = options.map(createCompiler);
@@ -40,7 +40,7 @@ exports.createMultiCompiler = createMultiCompiler;
40
40
  function createCompiler(userOptions) {
41
41
  const options = (0, config_1.getNormalizedRspackOptions)(userOptions);
42
42
  (0, config_1.applyRspackOptionsBaseDefaults)(options);
43
- (0, assert_1.default)(!(0, util_2.isNil)(options.context));
43
+ (0, node_assert_1.default)(!(0, util_1.isNil)(options.context));
44
44
  const compiler = new Compiler_1.Compiler(options.context, options);
45
45
  new NodeEnvironmentPlugin_1.default({
46
46
  infrastructureLogging: options.infrastructureLogging
@@ -68,7 +68,7 @@ function isMultiRspackOptions(o) {
68
68
  }
69
69
  function rspack(options, callback) {
70
70
  try {
71
- for (const o of (0, util_2.asArray)(options)) {
71
+ for (const o of (0, util_1.asArray)(options)) {
72
72
  (0, validate_1.validate)(o, config_1.rspackOptions);
73
73
  }
74
74
  }
@@ -114,7 +114,7 @@ function rspack(options, callback) {
114
114
  else {
115
115
  const { compiler, watch } = create();
116
116
  if (watch) {
117
- util_1.default.deprecate(() => { }, "A 'callback' argument needs to be provided to the 'rspack(options, callback)' function when the 'watch' option is set. There is no way to handle the 'watch' option without a callback.")();
117
+ node_util_1.default.deprecate(() => { }, "A 'callback' argument needs to be provided to the 'rspack(options, callback)' function when the 'watch' option is set. There is no way to handle the 'watch' option without a callback.")();
118
118
  }
119
119
  return compiler;
120
120
  }
@@ -13,7 +13,7 @@ exports.RspackOptionsApply = void 0;
13
13
  * Copyright (c) JS Foundation and other contributors
14
14
  * https://github.com/webpack/webpack/blob/main/LICENSE
15
15
  */
16
- const assert_1 = __importDefault(require("assert"));
16
+ const node_assert_1 = __importDefault(require("node:assert"));
17
17
  const graceful_fs_1 = __importDefault(require("../compiled/graceful-fs"));
18
18
  const Module_1 = require("./Module");
19
19
  const builtin_plugin_1 = require("./builtin-plugin");
@@ -26,12 +26,12 @@ const assertNotNil_1 = require("./util/assertNotNil");
26
26
  class RspackOptionsApply {
27
27
  constructor() { }
28
28
  process(options, compiler) {
29
- (0, assert_1.default)(options.output.path, "options.output.path should have value after `applyRspackOptionsDefaults`");
29
+ (0, node_assert_1.default)(options.output.path, "options.output.path should have value after `applyRspackOptionsDefaults`");
30
30
  compiler.outputPath = options.output.path;
31
31
  compiler.name = options.name;
32
32
  compiler.outputFileSystem = graceful_fs_1.default;
33
33
  if (options.externals) {
34
- (0, assert_1.default)(options.externalsType, "options.externalsType should have value after `applyRspackOptionsDefaults`");
34
+ (0, node_assert_1.default)(options.externalsType, "options.externalsType should have value after `applyRspackOptionsDefaults`");
35
35
  new builtin_plugin_1.ExternalsPlugin(options.externalsType, options.externals).apply(compiler);
36
36
  }
37
37
  if (options.externalsPresets.node) {
@@ -183,9 +183,9 @@ const ASSETS_GROUPERS = {
183
183
  });
184
184
  };
185
185
  groupByNames("chunkNames");
186
- // groupByNames("auxiliaryChunkNames");
187
- // groupByNames("chunkIdHints");
188
- // groupByNames("auxiliaryChunkIdHints");
186
+ groupByNames("auxiliaryChunkNames");
187
+ groupByNames("chunkIdHints");
188
+ groupByNames("auxiliaryChunkIdHints");
189
189
  },
190
190
  excludeAssets: (groupConfigs, context, { excludeAssets }) => {
191
191
  groupConfigs.push({
@@ -261,7 +261,7 @@ const MODULES_GROUPERS = (type) => ({
261
261
  if (groupModulesByType) {
262
262
  return [module.moduleType.split("/", 1)[0]];
263
263
  }
264
- else if (module.moduleType === "runtime") {
264
+ if (module.moduleType === "runtime") {
265
265
  return ["runtime"];
266
266
  }
267
267
  },
@@ -395,16 +395,21 @@ const RESULT_SORTERS = {
395
395
  "compilation.assets": ASSET_SORTERS,
396
396
  "asset.related": ASSET_SORTERS
397
397
  };
398
+ const MODULES_SORTER = {
399
+ _: comparators => {
400
+ comparators.push((0, comparators_1.compareSelect)((m) => m.depth, comparators_1.compareNumbers), (0, comparators_1.compareSelect)((m) => m.preOrderIndex, comparators_1.compareNumbers), (0, comparators_1.compareSelect)((m) => m.identifier, compareIds));
401
+ }
402
+ };
398
403
  const SORTERS = {
399
404
  "compilation.chunks": {
400
405
  _: comparators => {
401
406
  comparators.push((0, comparators_1.compareSelect)((c) => c.id, compareIds));
402
407
  }
403
408
  },
404
- // "compilation.modules": MODULES_SORTER,
405
- // "chunk.rootModules": MODULES_SORTER,
406
- // "chunk.modules": MODULES_SORTER,
407
- // "module.modules": MODULES_SORTER,
409
+ "compilation.modules": MODULES_SORTER,
410
+ "chunk.rootModules": MODULES_SORTER,
411
+ "chunk.modules": MODULES_SORTER,
412
+ "module.modules": MODULES_SORTER,
408
413
  // not support module.reasons (missing Module.identifier())
409
414
  "chunk.origins": {
410
415
  _: comparators => {
@@ -623,22 +628,51 @@ const SIMPLE_EXTRACTORS = {
623
628
  object.outputPath = compilation.outputOptions.path;
624
629
  },
625
630
  assets: (object, compilation, context, options, factory) => {
626
- const { assets, assetsByChunkName } = context
631
+ const { assets: compilationAssets, assetsByChunkName } = context
627
632
  .getInner(compilation)
628
633
  .getAssets();
634
+ const assetMap = new Map();
635
+ const assets = new Set();
636
+ for (const asset of compilationAssets) {
637
+ const item = {
638
+ ...asset,
639
+ type: "asset",
640
+ related: []
641
+ };
642
+ assets.add(item);
643
+ assetMap.set(asset.name, item);
644
+ }
645
+ for (const item of assetMap.values()) {
646
+ const related = item.info.related;
647
+ if (!related)
648
+ continue;
649
+ for (const { name: type, value: relatedEntry } of related) {
650
+ const deps = Array.isArray(relatedEntry)
651
+ ? relatedEntry
652
+ : [relatedEntry];
653
+ for (const dep of deps) {
654
+ const depItem = assetMap.get(dep);
655
+ if (!depItem)
656
+ continue;
657
+ assets.delete(depItem);
658
+ depItem.type = type;
659
+ item.related = item.related || [];
660
+ item.related.push(depItem);
661
+ }
662
+ }
663
+ }
629
664
  object.assetsByChunkName = assetsByChunkName.reduce((acc, cur) => {
630
665
  acc[cur.name] = cur.files;
631
666
  return acc;
632
667
  }, {});
633
- const groupedAssets = factory.create(`${context.type}.assets`, assets, {
668
+ const groupedAssets = factory.create(`${context.type}.assets`, Array.from(assets), {
634
669
  ...context
635
670
  // compilationFileToChunks
636
671
  // compilationAuxiliaryFileToChunks
637
672
  });
638
- const limited = (0, statsFactoryUtils_1.spaceLimited)(groupedAssets, options.assetsSpace || Number.POSITIVE_INFINITY);
639
- // object.filteredAssets = limited.filteredChildren;
640
- // const limited = spaceLimited(groupedAssets, options.assetsSpace);
673
+ const limited = (0, statsFactoryUtils_1.spaceLimited)(groupedAssets, options.assetsSpace ?? Number.POSITIVE_INFINITY);
641
674
  object.assets = limited.children;
675
+ object.filteredAssets = limited.filteredChildren;
642
676
  },
643
677
  chunks: (object, compilation, context, options, factory) => {
644
678
  const { type } = context;
@@ -738,15 +772,21 @@ const SIMPLE_EXTRACTORS = {
738
772
  asset$visible: {
739
773
  _: (object, asset) => {
740
774
  object.chunkNames = asset.chunkNames;
741
- // - chunkIdHints
742
- // - auxiliaryChunkNames
743
- // - auxiliaryChunkIdHints
744
- // - filteredRelated
775
+ object.chunkIdHints = asset.chunkIdHints.filter(Boolean);
776
+ object.auxiliaryChunkNames = asset.auxiliaryChunkNames;
777
+ object.auxiliaryChunkIdHints =
778
+ asset.auxiliaryChunkIdHints.filter(Boolean);
779
+ },
780
+ relatedAssets: (object, asset, context, options, factory) => {
781
+ const { type } = context;
782
+ object.related = factory.create(`${type.slice(0, -8)}.related`, asset.related, context);
783
+ object.filteredRelated = asset.related
784
+ ? asset.related.length - object.related.length
785
+ : undefined;
745
786
  },
746
- // relatedAssets
747
787
  ids: (object, asset) => {
748
788
  object.chunks = asset.chunks;
749
- // - auxiliaryChunks
789
+ object.auxiliaryChunks = asset.auxiliaryChunks;
750
790
  }
751
791
  },
752
792
  chunkGroup: {
@@ -772,7 +812,12 @@ const SIMPLE_EXTRACTORS = {
772
812
  object.moduleType = module.moduleType;
773
813
  // TODO: object.layer = module.layer;
774
814
  object.size = module.size;
775
- object.sizes = Object.fromEntries(module.sizes.map(({ sourceType, size }) => [sourceType, size]));
815
+ const sizes = module.sizes.map(({ sourceType, size }) => [
816
+ sourceType,
817
+ size
818
+ ]);
819
+ sizes.sort((a, b) => -compareIds(a, b));
820
+ object.sizes = Object.fromEntries(sizes);
776
821
  object.built = module.built;
777
822
  object.codeGenerated = module.codeGenerated;
778
823
  object.buildTimeExecuted = module.buildTimeExecuted;
@@ -43,7 +43,7 @@ const NAMED_PRESETS = {
43
43
  // warningsSpace: Infinity,
44
44
  modulesSpace: Number.POSITIVE_INFINITY,
45
45
  // chunkModulesSpace: Infinity,
46
- // assetsSpace: Infinity,
46
+ assetsSpace: Number.POSITIVE_INFINITY,
47
47
  // reasonsSpace: Infinity,
48
48
  children: true
49
49
  },
@@ -69,8 +69,8 @@ const NAMED_PRESETS = {
69
69
  // exclude: false,
70
70
  // errorsSpace: 1000,
71
71
  // warningsSpace: 1000,
72
- modulesSpace: 1000
73
- // assetsSpace: 1000,
72
+ modulesSpace: 1000,
73
+ assetsSpace: 1000
74
74
  // reasonsSpace: 1000
75
75
  },
76
76
  minimal: {
@@ -82,7 +82,7 @@ const NAMED_PRESETS = {
82
82
  // warningsSpace: 0,
83
83
  modulesSpace: 0,
84
84
  assets: true,
85
- // assetsSpace: 0,
85
+ assetsSpace: 0,
86
86
  errors: true,
87
87
  errorsCount: true,
88
88
  warnings: true,
@@ -19,7 +19,7 @@ const printSizes = (sizes, { formatSize = (n) => `${n}` }) => {
19
19
  if (keys.length > 1) {
20
20
  return keys.map(key => `${formatSize(sizes[key])} (${key})`).join(" ");
21
21
  }
22
- else if (keys.length === 1) {
22
+ if (keys.length === 1) {
23
23
  return formatSize(sizes[keys[0]]);
24
24
  }
25
25
  };
@@ -81,7 +81,7 @@ const SIMPLE_PRINTERS = {
81
81
  statusMessage = `compiled ${green("successfully")}`;
82
82
  }
83
83
  else {
84
- statusMessage = `compiled`;
84
+ statusMessage = "compiled";
85
85
  }
86
86
  if (builtAtMessage ||
87
87
  versionMessage ||
@@ -242,9 +242,7 @@ const SIMPLE_PRINTERS = {
242
242
  providedExportsCount === usedExports.length) {
243
243
  return cyan(formatFlag("all exports used"));
244
244
  }
245
- else {
246
- return cyan(formatFlag(`only some exports used: ${usedExports.join(", ")}`));
247
- }
245
+ return cyan(formatFlag(`only some exports used: ${usedExports.join(", ")}`));
248
246
  }
249
247
  }
250
248
  },
@@ -909,23 +907,20 @@ const AVAILABLE_FORMATS = {
909
907
  ];
910
908
  if (time < times[3])
911
909
  return `${time}${unit}`;
912
- else if (time < times[2])
910
+ if (time < times[2])
913
911
  return bold(`${time}${unit}`);
914
- else if (time < times[1])
912
+ if (time < times[1])
915
913
  return green(`${time}${unit}`);
916
- else if (time < times[0])
914
+ if (time < times[0])
917
915
  return yellow(`${time}${unit}`);
918
- else
919
- return red(`${time}${unit}`);
916
+ return red(`${time}${unit}`);
920
917
  }
921
- else {
922
- let timeStr = time.toString();
923
- if (time > 1000) {
924
- timeStr = `${(time / 1000).toFixed(2)}`;
925
- unit = " s";
926
- }
927
- return `${boldQuantity ? bold(timeStr) : timeStr}${unit}`;
918
+ let timeStr = time.toString();
919
+ if (time > 1000) {
920
+ timeStr = `${(time / 1000).toFixed(2)}`;
921
+ unit = " s";
928
922
  }
923
+ return `${boldQuantity ? bold(timeStr) : timeStr}${unit}`;
929
924
  },
930
925
  formatError: (msg, { green, yellow, red }) => {
931
926
  let message = msg;
@@ -98,16 +98,14 @@ class StatsFactory {
98
98
  if (this._inCreate) {
99
99
  return this._create(type, data, baseContext);
100
100
  }
101
- else {
102
- try {
103
- this._inCreate = true;
104
- return this._create(type, data, baseContext);
105
- }
106
- finally {
107
- for (const key of Object.keys(this._caches))
108
- this._caches[key].clear();
109
- this._inCreate = false;
110
- }
101
+ try {
102
+ this._inCreate = true;
103
+ return this._create(type, data, baseContext);
104
+ }
105
+ finally {
106
+ for (const key of Object.keys(this._caches))
107
+ this._caches[key].clear();
108
+ this._inCreate = false;
111
109
  }
112
110
  }
113
111
  _create(type, data, baseContext) {
@@ -168,13 +166,11 @@ class StatsFactory {
168
166
  // run result on merged items
169
167
  return this._forEachLevelWaterfall(this.hooks.result, this._caches.result, type, result, (h, r) => h.call(r, context));
170
168
  }
171
- else {
172
- const object = {};
173
- // run extract on value
174
- this._forEachLevel(this.hooks.extract, this._caches.extract, type, h => h.call(object, data, context));
175
- // run result on extracted object
176
- return this._forEachLevelWaterfall(this.hooks.result, this._caches.result, type, object, (h, r) => h.call(r, context));
177
- }
169
+ const object = {};
170
+ // run extract on value
171
+ this._forEachLevel(this.hooks.extract, this._caches.extract, type, h => h.call(object, data, context));
172
+ // run result on extracted object
173
+ return this._forEachLevelWaterfall(this.hooks.result, this._caches.result, type, object, (h, r) => h.call(r, context));
178
174
  }
179
175
  }
180
176
  exports.StatsFactory = StatsFactory;
@@ -80,15 +80,13 @@ class StatsPrinter {
80
80
  if (this._inPrint) {
81
81
  return this._print(type, object, baseContext);
82
82
  }
83
- else {
84
- try {
85
- this._inPrint = true;
86
- return this._print(type, object, baseContext);
87
- }
88
- finally {
89
- this._levelHookCache.clear();
90
- this._inPrint = false;
91
- }
83
+ try {
84
+ this._inPrint = true;
85
+ return this._print(type, object, baseContext);
86
+ }
87
+ finally {
88
+ this._levelHookCache.clear();
89
+ this._inPrint = false;
92
90
  }
93
91
  }
94
92
  _print(type, object, baseContext) {
@@ -2,20 +2,19 @@ import type * as binding from "@rspack/binding";
2
2
  import type { Compilation, NormalizedStatsOptions } from "../Compilation";
3
3
  import { type Comparator } from "../util/comparators";
4
4
  import type { StatsFactory, StatsFactoryContext } from "./StatsFactory";
5
+ type Writable<T> = {
6
+ -readonly [K in keyof T]: T[K];
7
+ };
5
8
  export type KnownStatsChunkGroup = binding.JsStatsChunkGroup;
6
- export type KnownStatsChunk = Omit<binding.JsStatsChunk, "sizes"> & {
9
+ export type KnownStatsChunk = Omit<Writable<binding.JsStatsChunk>, "sizes"> & {
7
10
  sizes: Record<string, number>;
8
11
  };
9
- export type KnownStatsAssetInfo = Omit<binding.JsStatsAssetInfo, "related"> & {
10
- related: Record<string, string[]>;
11
- };
12
+ export type KnownStatsAssetInfo = Omit<binding.JsStatsAssetInfo, "related">;
12
13
  export type StatsChunkGroup = binding.JsStatsChunkGroup & Record<string, any>;
13
- export type KnownStatsAsset = Omit<binding.JsStatsAsset, "info"> & {
14
- info: KnownStatsAssetInfo;
15
- };
14
+ export type KnownStatsAsset = Omit<binding.JsStatsAsset, "info">;
16
15
  export type StatsAsset = KnownStatsAsset & Record<string, any>;
17
16
  export type StatsChunk = KnownStatsChunk & Record<string, any>;
18
- export type KnownStatsModule = Omit<binding.JsStatsModule, "usedExports" | "providedExports" | "optimizationBailout" | "sizes"> & {
17
+ export type KnownStatsModule = Omit<Writable<binding.JsStatsModule>, "usedExports" | "providedExports" | "optimizationBailout" | "sizes"> & {
19
18
  profile?: StatsProfile;
20
19
  usedExports?: null | string[] | boolean;
21
20
  providedExports?: null | string[];
@@ -42,7 +41,7 @@ export type StatsModuleTraceItem = {
42
41
  originId?: string;
43
42
  moduleId?: string;
44
43
  };
45
- export type StatsModuleReason = binding.JsStatsModuleReason & Record<string, any>;
44
+ export type StatsModuleReason = Writable<binding.JsStatsModuleReason> & Record<string, any>;
46
45
  export type KnownStatsCompilation = {
47
46
  /**
48
47
  * webpack version.
@@ -98,7 +97,7 @@ export type KnownStatsChunkOrigin = {
98
97
  type ExtractorsByOption<T, O> = {
99
98
  [x: string]: (object: O, data: T, context: StatsFactoryContext, options: any, factory: StatsFactory) => void;
100
99
  };
101
- type PreprocessedAsset = StatsAsset & {
100
+ export type PreprocessedAsset = StatsAsset & {
102
101
  type: string;
103
102
  related: PreprocessedAsset[];
104
103
  info: binding.JsStatsAssetInfo;
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.JsAssetInfo = void 0;
4
4
  class JsAssetInfo {
5
5
  static __from_binding(jsAssetInfo) {
6
- const { immutable, minimized, development, hotModuleReplacement, related, chunkHash, contentHash, javascriptModule, sourceFilename, extras } = jsAssetInfo;
6
+ const { immutable, minimized, development, hotModuleReplacement, related, chunkhash, fullhash, contenthash, javascriptModule, sourceFilename, extras } = jsAssetInfo;
7
7
  return {
8
8
  ...extras,
9
9
  immutable,
@@ -11,14 +11,15 @@ class JsAssetInfo {
11
11
  development,
12
12
  hotModuleReplacement,
13
13
  related,
14
- chunkHash,
15
- contentHash,
14
+ fullhash,
15
+ chunkhash,
16
+ contenthash,
16
17
  javascriptModule,
17
18
  sourceFilename
18
19
  };
19
20
  }
20
21
  static __to_binding(assetInfo = {}) {
21
- let { immutable = false, minimized = false, development = false, hotModuleReplacement = false, related = {}, chunkHash = [], contentHash = [], javascriptModule, sourceFilename, ...extras } = assetInfo;
22
+ let { immutable = false, minimized = false, development = false, hotModuleReplacement = false, related = {}, fullhash = [], chunkhash = [], contenthash = [], javascriptModule, sourceFilename, ...extras } = assetInfo;
22
23
  extras = extras ?? {};
23
24
  return {
24
25
  immutable,
@@ -26,9 +27,12 @@ class JsAssetInfo {
26
27
  development,
27
28
  hotModuleReplacement,
28
29
  related,
29
- chunkHash,
30
- contentHash,
31
- extras
30
+ fullhash,
31
+ chunkhash,
32
+ contenthash,
33
+ extras,
34
+ javascriptModule,
35
+ sourceFilename
32
36
  };
33
37
  }
34
38
  }
@@ -6,7 +6,7 @@ class JsSplitChunkSizes {
6
6
  if (typeof sizes === "number") {
7
7
  return sizes;
8
8
  }
9
- else if (sizes && typeof sizes === "object") {
9
+ if (sizes && typeof sizes === "object") {
10
10
  const chunkSizes = {
11
11
  sizes: sizes
12
12
  };
@@ -4,8 +4,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.checkVersion = void 0;
7
- const fs_1 = require("fs");
8
- const path_1 = __importDefault(require("path"));
7
+ const node_fs_1 = require("node:fs");
8
+ const node_path_1 = __importDefault(require("node:path"));
9
9
  const NodePlatformArchToAbi = {
10
10
  android: {
11
11
  arm64: "",
@@ -39,11 +39,11 @@ function isMusl() {
39
39
  // For Node 10
40
40
  if (!process.report || typeof process.report.getReport !== "function") {
41
41
  try {
42
- const lddPath = require("child_process")
42
+ const lddPath = require("node:child_process")
43
43
  .execSync("which ldd")
44
44
  .toString()
45
45
  .trim();
46
- return (0, fs_1.readFileSync)(lddPath, "utf8").includes("musl");
46
+ return (0, node_fs_1.readFileSync)(lddPath, "utf8").includes("musl");
47
47
  }
48
48
  catch (e) {
49
49
  return true;
@@ -96,8 +96,8 @@ const checkVersion = () => {
96
96
  }
97
97
  let ADDON_VERSION;
98
98
  try {
99
- const BINDING_PKG_DIR = path_1.default.dirname(require.resolve("@rspack/binding/package.json"));
100
- const isLocal = (0, fs_1.readdirSync)(BINDING_PKG_DIR).some(item => item === `rspack.${platformArchAbi}.node`);
99
+ const BINDING_PKG_DIR = node_path_1.default.dirname(require.resolve("@rspack/binding/package.json"));
100
+ const isLocal = (0, node_fs_1.readdirSync)(BINDING_PKG_DIR).some(item => item === `rspack.${platformArchAbi}.node`);
101
101
  if (isLocal) {
102
102
  // Treat addon version the same as binding version if running locally
103
103
  ADDON_VERSION = BINDING_VERSION;