@rspack/core 1.0.0-alpha.3 → 1.0.0-alpha.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/compiled/browserslist/index.js +17 -17
  2. package/compiled/enhanced-resolve/index.js +107 -107
  3. package/compiled/graceful-fs/index.js +8 -8
  4. package/compiled/json-parse-even-better-errors/index.js +2 -2
  5. package/compiled/neo-async/index.js +2 -2
  6. package/compiled/watchpack/index.js +15 -15
  7. package/compiled/webpack-sources/index.js +76 -76
  8. package/compiled/zod/index.js +30 -30
  9. package/compiled/zod-validation-error/index.js +6 -6
  10. package/dist/Compilation.js +2 -3
  11. package/dist/ErrorHelpers.d.ts +16 -7
  12. package/dist/ErrorHelpers.js +34 -33
  13. package/dist/ExecuteModulePlugin.js +1 -1
  14. package/dist/FileSystem.js +6 -6
  15. package/dist/Module.d.ts +1 -2
  16. package/dist/Module.js +2 -6
  17. package/dist/MultiCompiler.js +1 -1
  18. package/dist/NormalModule.js +6 -6
  19. package/dist/ResolverFactory.d.ts +5 -1
  20. package/dist/ResolverFactory.js +7 -1
  21. package/dist/RuntimeGlobals.js +3 -3
  22. package/dist/Stats.js +4 -4
  23. package/dist/Template.js +2 -2
  24. package/dist/Watching.js +2 -2
  25. package/dist/builtin-plugin/DefinePlugin.js +2 -2
  26. package/dist/builtin-plugin/EntryPlugin.js +1 -1
  27. package/dist/builtin-plugin/SplitChunksPlugin.js +2 -2
  28. package/dist/builtin-plugin/SwcCssMinimizerPlugin.d.ts +10 -2
  29. package/dist/builtin-plugin/SwcCssMinimizerPlugin.js +7 -1
  30. package/dist/builtin-plugin/SwcJsMinimizerPlugin.js +2 -2
  31. package/dist/builtin-plugin/WorkerPlugin.js +5 -1
  32. package/dist/builtin-plugin/base.js +1 -1
  33. package/dist/builtin-plugin/css-extract/loader.js +5 -5
  34. package/dist/builtin-plugin/css-extract/utils.js +3 -3
  35. package/dist/builtin-plugin/lazy-compilation/backend.d.ts +3 -3
  36. package/dist/builtin-plugin/lazy-compilation/backend.js +1 -1
  37. package/dist/config/adapter.d.ts +1 -1
  38. package/dist/config/adapter.js +27 -16
  39. package/dist/config/adapterRuleUse.js +1 -1
  40. package/dist/config/browserslistTargetHandler.js +2 -2
  41. package/dist/config/defaults.js +11 -10
  42. package/dist/config/zod.d.ts +119 -12
  43. package/dist/config/zod.js +43 -40
  44. package/dist/container/ModuleFederationPlugin.js +2 -2
  45. package/dist/lib/EntryOptionPlugin.js +2 -2
  46. package/dist/lib/WebpackError.js +1 -1
  47. package/dist/loader-runner/index.js +22 -22
  48. package/dist/loader-runner/loadLoader.js +1 -1
  49. package/dist/logging/runtime.js +1 -1
  50. package/dist/node/NodeWatchFileSystem.js +5 -5
  51. package/dist/node/nodeConsole.js +1 -1
  52. package/dist/rspack.js +6 -6
  53. package/dist/rspackOptionsApply.js +3 -3
  54. package/dist/sharing/ConsumeSharedPlugin.js +1 -1
  55. package/dist/stats/DefaultStatsFactoryPlugin.js +285 -50
  56. package/dist/stats/DefaultStatsPresetPlugin.js +17 -17
  57. package/dist/stats/DefaultStatsPrinterPlugin.js +2 -2
  58. package/dist/stats/statsFactoryUtils.d.ts +24 -10
  59. package/dist/util/bindingVersionCheck.js +6 -6
  60. package/dist/util/createHash.js +2 -2
  61. package/dist/util/fs.js +11 -11
  62. package/dist/util/identifier.d.ts +65 -62
  63. package/dist/util/identifier.js +30 -55
  64. package/package.json +6 -3
@@ -57,22 +57,14 @@ const ITEM_NAMES = {
57
57
  "module.issuerPath[]": "moduleIssuer",
58
58
  "module.reasons[]": "moduleReason",
59
59
  "module.modules[]": "module",
60
- "module.children[]": "module"
61
- // "moduleTrace[]": "moduleTraceItem",
60
+ "module.children[]": "module",
61
+ "moduleTrace[]": "moduleTraceItem"
62
62
  // "moduleTraceItem.dependencies[]": "moduleTraceDependency"
63
63
  };
64
- // const MERGER: Record<
65
- // string,
66
- // (
67
- // items: {
68
- // [key: string]: any;
69
- // name: string;
70
- // }[]
71
- // ) => any
72
- // > = {
73
- // "compilation.entrypoints": mergeToObject,
74
- // "compilation.namedChunkGroups": mergeToObject
75
- // };
64
+ const MERGER = {
65
+ "compilation.entrypoints": statsFactoryUtils_1.mergeToObject,
66
+ "compilation.namedChunkGroups": statsFactoryUtils_1.mergeToObject
67
+ };
76
68
  const ASSETS_GROUPERS = {
77
69
  _: (groupConfigs, context, options) => {
78
70
  const groupByFlag = (name, exclude) => {
@@ -149,10 +141,74 @@ const ASSETS_GROUPERS = {
149
141
  }
150
142
  });
151
143
  }
144
+ },
145
+ groupAssetsByInfo: groupConfigs => {
146
+ const groupByAssetInfoFlag = (name) => {
147
+ groupConfigs.push({
148
+ getKeys: asset => {
149
+ return asset.info && asset.info[name] ? ["1"] : undefined;
150
+ },
151
+ // @ts-expect-error
152
+ createGroup: (key, children) => {
153
+ return {
154
+ type: "assets by info",
155
+ info: {
156
+ [name]: !!key
157
+ },
158
+ children,
159
+ ...(0, statsFactoryUtils_1.assetGroup)(children)
160
+ };
161
+ }
162
+ });
163
+ };
164
+ groupByAssetInfoFlag("immutable");
165
+ groupByAssetInfoFlag("development");
166
+ groupByAssetInfoFlag("hotModuleReplacement");
167
+ },
168
+ groupAssetsByChunk: groupConfigs => {
169
+ const groupByNames = (name) => {
170
+ groupConfigs.push({
171
+ getKeys: asset => {
172
+ return asset[name];
173
+ },
174
+ // @ts-expect-error
175
+ createGroup: (key, children) => {
176
+ return {
177
+ type: "assets by chunk",
178
+ [name]: [key],
179
+ children,
180
+ ...(0, statsFactoryUtils_1.assetGroup)(children)
181
+ };
182
+ }
183
+ });
184
+ };
185
+ groupByNames("chunkNames");
186
+ groupByNames("auxiliaryChunkNames");
187
+ groupByNames("chunkIdHints");
188
+ groupByNames("auxiliaryChunkIdHints");
189
+ },
190
+ excludeAssets: (groupConfigs, context, { excludeAssets }) => {
191
+ groupConfigs.push({
192
+ getKeys: asset => {
193
+ const ident = asset.name;
194
+ const excluded = excludeAssets.some(fn => fn(ident, asset));
195
+ if (excluded)
196
+ return ["excluded"];
197
+ },
198
+ getOptions: () => ({
199
+ groupChildren: false,
200
+ force: true
201
+ }),
202
+ // @ts-expect-error
203
+ createGroup: (key, children, assets) => ({
204
+ type: "hidden assets",
205
+ filteredChildren: assets.length,
206
+ ...(0, statsFactoryUtils_1.assetGroup)(children)
207
+ })
208
+ });
152
209
  }
153
- // not support groupAssetsByInfo / groupAssetsByChunk / excludeAssets
154
210
  };
155
- const MODULES_GROUPERS = (_type) => ({
211
+ const MODULES_GROUPERS = (type) => ({
156
212
  _: (groupConfigs, context, options) => {
157
213
  const groupByFlag = (name, type, exclude) => {
158
214
  groupConfigs.push({
@@ -176,7 +232,7 @@ const MODULES_GROUPERS = (_type) => ({
176
232
  }
177
233
  });
178
234
  };
179
- const { groupModulesByCacheStatus, groupModulesByAttributes, groupModulesByType } = options;
235
+ const { groupModulesByCacheStatus, groupModulesByAttributes, groupModulesByType, groupModulesByPath, groupModulesByExtension } = options;
180
236
  if (groupModulesByAttributes) {
181
237
  groupByFlag("errors", "modules with errors");
182
238
  groupByFlag("warnings", "modules with warnings");
@@ -228,9 +284,76 @@ const MODULES_GROUPERS = (_type) => ({
228
284
  }
229
285
  });
230
286
  }
231
- // not support groupModulesByLayer / groupModulesByPath / groupModulesByExtension
287
+ // not support groupModulesByLayer
288
+ if (groupModulesByPath || groupModulesByExtension) {
289
+ groupConfigs.push({
290
+ getKeys: module => {
291
+ if (!module.name)
292
+ return;
293
+ const resource = (0, identifier_1.parseResource)(module.name.split("!").pop()).path;
294
+ const dataUrl = /^data:[^,;]+/.exec(resource);
295
+ if (dataUrl)
296
+ return [dataUrl[0]];
297
+ const extensionMatch = groupModulesByExtension && GROUP_EXTENSION_REGEXP.exec(resource);
298
+ const extension = extensionMatch ? extensionMatch[1] : "";
299
+ const pathMatch = groupModulesByPath && GROUP_PATH_REGEXP.exec(resource);
300
+ const path = pathMatch ? pathMatch[1].split(/[/\\]/) : [];
301
+ const keys = [];
302
+ if (groupModulesByPath) {
303
+ if (extension)
304
+ keys.push(path.length
305
+ ? `${path.join("/")}/*${extension}`
306
+ : `*${extension}`);
307
+ while (path.length > 0) {
308
+ keys.push(path.join("/") + "/");
309
+ path.pop();
310
+ }
311
+ }
312
+ else {
313
+ if (extension)
314
+ keys.push(`*${extension}`);
315
+ }
316
+ return keys;
317
+ },
318
+ // @ts-expect-error
319
+ createGroup: (key, children, modules) => {
320
+ const isDataUrl = key.startsWith("data:");
321
+ return {
322
+ type: isDataUrl
323
+ ? "modules by mime type"
324
+ : groupModulesByPath
325
+ ? "modules by path"
326
+ : "modules by extension",
327
+ name: isDataUrl ? key.slice(/* 'data:'.length */ 5) : key,
328
+ children,
329
+ ...(0, statsFactoryUtils_1.moduleGroup)(children)
330
+ };
331
+ }
332
+ });
333
+ }
334
+ },
335
+ excludeModules: (groupConfigs, context, { excludeModules }) => {
336
+ groupConfigs.push({
337
+ getKeys: module => {
338
+ const name = module.name;
339
+ if (name) {
340
+ const excluded = excludeModules.some(fn => fn(name, module, type));
341
+ if (excluded)
342
+ return ["1"];
343
+ }
344
+ },
345
+ getOptions: () => ({
346
+ groupChildren: false,
347
+ force: true
348
+ }),
349
+ // @ts-expect-error
350
+ createGroup: (key, children, modules) => ({
351
+ type: "hidden modules",
352
+ filteredChildren: children.length,
353
+ ...(0, statsFactoryUtils_1.moduleGroup)(children)
354
+ })
355
+ });
232
356
  }
233
- // not support excludeModules
234
357
  });
235
358
  const RESULT_GROUPERS = {
236
359
  "compilation.assets": ASSETS_GROUPERS,
@@ -295,6 +418,31 @@ const SORTERS = {
295
418
  }
296
419
  }
297
420
  };
421
+ const EXTRACT_ERROR = {
422
+ _: (object, error) => {
423
+ object.message = error.message;
424
+ object.chunkName = error.chunkName;
425
+ object.chunkEntry = error.chunkEntry;
426
+ object.chunkInitial = error.chunkInitial;
427
+ object.file = error.file;
428
+ object.moduleIdentifier = error.moduleIdentifier;
429
+ object.moduleName = error.moduleName;
430
+ },
431
+ ids: (object, error) => {
432
+ object.chunkId = error.chunkId;
433
+ object.moduleId = error.moduleId;
434
+ },
435
+ moduleTrace: (object, error, context, _, factory) => {
436
+ const { type } = context;
437
+ object.moduleTrace = factory.create(`${type}.moduleTrace`, error.moduleTrace, context);
438
+ },
439
+ errorDetails: (object, error) => {
440
+ object.details = error.details;
441
+ },
442
+ errorStack: (object, error) => {
443
+ object.stack = error.stack;
444
+ }
445
+ };
298
446
  const SIMPLE_EXTRACTORS = {
299
447
  compilation: {
300
448
  _: (object, compilation, context, options) => {
@@ -475,22 +623,51 @@ const SIMPLE_EXTRACTORS = {
475
623
  object.outputPath = compilation.outputOptions.path;
476
624
  },
477
625
  assets: (object, compilation, context, options, factory) => {
478
- const { assets, assetsByChunkName } = context
626
+ const { assets: compilationAssets, assetsByChunkName } = context
479
627
  .getInner(compilation)
480
628
  .getAssets();
629
+ const assetMap = new Map();
630
+ const assets = new Set();
631
+ for (const asset of compilationAssets) {
632
+ const item = {
633
+ ...asset,
634
+ type: "asset",
635
+ related: []
636
+ };
637
+ assets.add(item);
638
+ assetMap.set(asset.name, item);
639
+ }
640
+ for (const item of assetMap.values()) {
641
+ const related = item.info.related;
642
+ if (!related)
643
+ continue;
644
+ for (const { name: type, value: relatedEntry } of related) {
645
+ const deps = Array.isArray(relatedEntry)
646
+ ? relatedEntry
647
+ : [relatedEntry];
648
+ for (const dep of deps) {
649
+ const depItem = assetMap.get(dep);
650
+ if (!depItem)
651
+ continue;
652
+ assets.delete(depItem);
653
+ depItem.type = type;
654
+ item.related = item.related || [];
655
+ item.related.push(depItem);
656
+ }
657
+ }
658
+ }
481
659
  object.assetsByChunkName = assetsByChunkName.reduce((acc, cur) => {
482
660
  acc[cur.name] = cur.files;
483
661
  return acc;
484
662
  }, {});
485
- const groupedAssets = factory.create(`${context.type}.assets`, assets, {
663
+ const groupedAssets = factory.create(`${context.type}.assets`, Array.from(assets), {
486
664
  ...context
487
665
  // compilationFileToChunks
488
666
  // compilationAuxiliaryFileToChunks
489
667
  });
490
- const limited = (0, statsFactoryUtils_1.spaceLimited)(groupedAssets, options.assetsSpace || Infinity);
491
- // object.filteredAssets = limited.filteredChildren;
492
- // const limited = spaceLimited(groupedAssets, options.assetsSpace);
668
+ const limited = (0, statsFactoryUtils_1.spaceLimited)(groupedAssets, options.assetsSpace || Number.POSITIVE_INFINITY);
493
669
  object.assets = limited.children;
670
+ object.filteredAssets = limited.filteredChildren;
494
671
  },
495
672
  chunks: (object, compilation, context, options, factory) => {
496
673
  const { type } = context;
@@ -509,35 +686,46 @@ const SIMPLE_EXTRACTORS = {
509
686
  object.modules = limited.children;
510
687
  object.filteredModules = limited.filteredChildren;
511
688
  },
512
- entrypoints: (object, compilation, context, { chunkGroupAuxiliary, chunkGroupChildren }, _factory) => {
513
- // const { type } = context;
689
+ entrypoints: (object, compilation, context, { entrypoints, chunkGroups, chunkGroupAuxiliary, chunkGroupChildren }, factory) => {
690
+ const { type } = context;
514
691
  const array = context
515
692
  .getInner(compilation)
516
- .getEntrypoints(chunkGroupAuxiliary, chunkGroupChildren);
517
- // object.entrypoints = factory.create(
518
- // `${type}.entrypoints`,
519
- // array,
520
- // context
521
- // );
522
- object.entrypoints = array.reduce((acc, cur) => {
523
- acc[cur.name] = cur;
524
- return acc;
693
+ .getEntrypoints(chunkGroupAuxiliary, chunkGroupChildren)
694
+ .map(entrypoint => ({
695
+ name: entrypoint.name,
696
+ chunkGroup: entrypoint
697
+ }));
698
+ const chunks = Array.from(compilation.chunks).reduce((res, chunk) => {
699
+ res[chunk.id] = chunk;
700
+ return res;
525
701
  }, {});
702
+ if (entrypoints === "auto" && !chunkGroups) {
703
+ if (array.length > 5)
704
+ return;
705
+ if (!chunkGroupChildren &&
706
+ array.every(({ chunkGroup }) => {
707
+ if (chunkGroup.chunks.length !== 1)
708
+ return false;
709
+ const chunk = chunks[chunkGroup.chunks[0]];
710
+ return (chunk &&
711
+ chunk.files.size === 1 &&
712
+ (!chunkGroupAuxiliary || chunk.auxiliaryFiles.size === 0));
713
+ })) {
714
+ return;
715
+ }
716
+ }
717
+ object.entrypoints = factory.create(`${type}.entrypoints`, array, context);
526
718
  },
527
719
  chunkGroups: (object, compilation, context, { chunkGroupAuxiliary, chunkGroupChildren }, factory) => {
528
- // const { type } = context;
720
+ const { type } = context;
529
721
  const namedChunkGroups = context
530
722
  .getInner(compilation)
531
- .getNamedChunkGroups(chunkGroupAuxiliary, chunkGroupChildren);
532
- // object.namedChunkGroups = factory.create(
533
- // `${type}.namedChunkGroups`,
534
- // namedChunkGroups,
535
- // context
536
- // );
537
- object.namedChunkGroups = namedChunkGroups.reduce((acc, cur) => {
538
- acc[cur.name] = cur;
539
- return acc;
540
- }, {});
723
+ .getNamedChunkGroups(chunkGroupAuxiliary, chunkGroupChildren)
724
+ .map(cg => ({
725
+ name: cg.name,
726
+ chunkGroup: cg
727
+ }));
728
+ object.namedChunkGroups = factory.create(`${type}.namedChunkGroups`, namedChunkGroups, context);
541
729
  },
542
730
  errors: (object, compilation, context, _options, _factory) => {
543
731
  const { cachedGetErrors } = context;
@@ -571,15 +759,45 @@ const SIMPLE_EXTRACTORS = {
571
759
  ...asset.info,
572
760
  related: Object.fromEntries(asset.info.related.map(i => [i.name, i.value]))
573
761
  };
762
+ // - comparedForEmit
763
+ // - cached
574
764
  Object.assign(object, factory.create(`${context.type}$visible`, asset, context));
575
765
  }
576
766
  },
577
767
  asset$visible: {
578
768
  _: (object, asset) => {
579
769
  object.chunkNames = asset.chunkNames;
770
+ object.chunkIdHints = asset.chunkIdHints.filter(Boolean);
771
+ object.auxiliaryChunkNames = asset.auxiliaryChunkNames;
772
+ object.auxiliaryChunkIdHints =
773
+ asset.auxiliaryChunkIdHints.filter(Boolean);
774
+ },
775
+ relatedAssets: (object, asset, context, options, factory) => {
776
+ const { type } = context;
777
+ object.related = factory.create(`${type.slice(0, -8)}.related`, asset.related, context);
778
+ object.filteredRelated = asset.related
779
+ ? asset.related.length - object.related.length
780
+ : undefined;
580
781
  },
581
782
  ids: (object, asset) => {
582
783
  object.chunks = asset.chunks;
784
+ object.auxiliaryChunks = asset.auxiliaryChunks;
785
+ }
786
+ },
787
+ chunkGroup: {
788
+ _: (object, { name, chunkGroup }, _context, { chunkGroupMaxAssets }) => {
789
+ object.name = name;
790
+ object.chunks = chunkGroup.chunks;
791
+ object.assets = chunkGroup.assets;
792
+ object.filteredAssets =
793
+ chunkGroup.assets.length <= chunkGroupMaxAssets
794
+ ? 0
795
+ : chunkGroup.assets.length;
796
+ object.assetsSize = chunkGroup.assetsSize;
797
+ object.auxiliaryAssets = chunkGroup.auxiliaryAssets;
798
+ object.auxiliaryAssetsSize = chunkGroup.auxiliaryAssetsSize;
799
+ object.children = chunkGroup.children;
800
+ // - childAssets
583
801
  }
584
802
  },
585
803
  module: {
@@ -635,6 +853,7 @@ const SIMPLE_EXTRACTORS = {
635
853
  reasons: (object, module, context, options, factory) => {
636
854
  const { type } = context;
637
855
  object.reasons = factory.create(`${type.slice(0, -8)}.reasons`, module.reasons, context);
856
+ // object.filteredReasons
638
857
  },
639
858
  source: (object, module) => {
640
859
  object.source = module.source;
@@ -745,7 +964,23 @@ const SIMPLE_EXTRACTORS = {
745
964
  chunkOrigins: (object, chunk, context, options, factory) => {
746
965
  object.origins = chunk.origins;
747
966
  }
967
+ },
968
+ // chunkOrigin
969
+ error: EXTRACT_ERROR,
970
+ warning: EXTRACT_ERROR,
971
+ moduleTraceItem: {
972
+ _: (object, { origin, module }, context, { requestShortener }, factory) => {
973
+ object.originIdentifier = origin.identifier;
974
+ object.originName = origin.name;
975
+ object.moduleIdentifier = module.identifier;
976
+ object.moduleName = module.name;
977
+ },
978
+ ids: (object, { origin, module }) => {
979
+ object.originId = origin.id;
980
+ object.moduleId = module.id;
981
+ }
748
982
  }
983
+ // moduleTraceDependency
749
984
  };
750
985
  /**
751
986
  * only support below factories:
@@ -797,10 +1032,10 @@ class DefaultStatsFactoryPlugin {
797
1032
  .for(key)
798
1033
  .tap("DefaultStatsFactoryPlugin", () => itemName);
799
1034
  }
800
- // for (const key of Object.keys(MERGER)) {
801
- // const merger = MERGER[key];
802
- // stats.hooks.merge.for(key).tap("DefaultStatsFactoryPlugin", merger);
803
- // }
1035
+ for (const key of Object.keys(MERGER)) {
1036
+ const merger = MERGER[key];
1037
+ stats.hooks.merge.for(key).tap("DefaultStatsFactoryPlugin", merger);
1038
+ }
804
1039
  });
805
1040
  });
806
1041
  }
@@ -16,7 +16,7 @@ const NAMED_PRESETS = {
16
16
  verbose: {
17
17
  hash: true,
18
18
  builtAt: true,
19
- // relatedAssets: true,
19
+ relatedAssets: true,
20
20
  entrypoints: true,
21
21
  chunkGroups: true,
22
22
  ids: true,
@@ -24,16 +24,16 @@ const NAMED_PRESETS = {
24
24
  chunks: true,
25
25
  chunkRelations: true,
26
26
  chunkModules: true,
27
- // dependentModules: true,
28
- // chunkOrigins: true,
27
+ dependentModules: true,
28
+ chunkOrigins: true,
29
29
  depth: true,
30
- // env: true,
30
+ env: true,
31
31
  reasons: true,
32
32
  usedExports: true,
33
33
  providedExports: true,
34
34
  optimizationBailout: true,
35
- // errorDetails: true,
36
- // errorStack: true,
35
+ errorDetails: true,
36
+ errorStack: true,
37
37
  publicPath: true,
38
38
  logging: "verbose",
39
39
  orphanModules: true,
@@ -41,7 +41,7 @@ const NAMED_PRESETS = {
41
41
  // exclude: false,
42
42
  // errorsSpace: Infinity,
43
43
  // warningsSpace: Infinity,
44
- modulesSpace: Infinity,
44
+ modulesSpace: Number.POSITIVE_INFINITY,
45
45
  // chunkModulesSpace: Infinity,
46
46
  // assetsSpace: Infinity,
47
47
  // reasonsSpace: Infinity,
@@ -50,19 +50,19 @@ const NAMED_PRESETS = {
50
50
  detailed: {
51
51
  hash: true,
52
52
  builtAt: true,
53
- // relatedAssets: true,
53
+ relatedAssets: true,
54
54
  entrypoints: true,
55
55
  chunkGroups: true,
56
56
  ids: true,
57
57
  chunks: true,
58
58
  chunkRelations: true,
59
59
  chunkModules: false,
60
- // chunkOrigins: true,
60
+ chunkOrigins: true,
61
61
  depth: true,
62
62
  usedExports: true,
63
63
  providedExports: true,
64
64
  optimizationBailout: true,
65
- // errorDetails: true,
65
+ errorDetails: true,
66
66
  publicPath: true,
67
67
  logging: true,
68
68
  runtimeModules: true,
@@ -94,7 +94,7 @@ const NAMED_PRESETS = {
94
94
  errors: true,
95
95
  errorsCount: true,
96
96
  // errorsSpace: Infinity,
97
- // moduleTrace: true,
97
+ moduleTrace: true,
98
98
  logging: "error"
99
99
  },
100
100
  "errors-warnings": {
@@ -147,7 +147,7 @@ const DEFAULTS = {
147
147
  chunkGroups: OFF_FOR_TO_STRING,
148
148
  chunkGroupAuxiliary: OFF_FOR_TO_STRING,
149
149
  chunkGroupChildren: OFF_FOR_TO_STRING,
150
- chunkGroupMaxAssets: (o, { forToString }) => (forToString ? 5 : Infinity),
150
+ chunkGroupMaxAssets: (o, { forToString }) => forToString ? 5 : Number.POSITIVE_INFINITY,
151
151
  chunks: OFF_FOR_TO_STRING,
152
152
  chunkRelations: OFF_FOR_TO_STRING,
153
153
  chunkModules: ({ all, modules }) => {
@@ -178,16 +178,16 @@ const DEFAULTS = {
178
178
  groupModulesByAttributes: ON_FOR_TO_STRING,
179
179
  groupModulesByPath: ON_FOR_TO_STRING,
180
180
  groupModulesByExtension: ON_FOR_TO_STRING,
181
- modulesSpace: (o, { forToString }) => (forToString ? 15 : Infinity),
182
- chunkModulesSpace: (o, { forToString }) => (forToString ? 10 : Infinity),
183
- nestedModulesSpace: (o, { forToString }) => (forToString ? 10 : Infinity),
181
+ modulesSpace: (o, { forToString }) => forToString ? 15 : Number.POSITIVE_INFINITY,
182
+ chunkModulesSpace: (o, { forToString }) => forToString ? 10 : Number.POSITIVE_INFINITY,
183
+ nestedModulesSpace: (o, { forToString }) => forToString ? 10 : Number.POSITIVE_INFINITY,
184
184
  relatedAssets: OFF_FOR_TO_STRING,
185
185
  groupAssetsByEmitStatus: ON_FOR_TO_STRING,
186
186
  groupAssetsByInfo: ON_FOR_TO_STRING,
187
187
  groupAssetsByPath: ON_FOR_TO_STRING,
188
188
  groupAssetsByExtension: ON_FOR_TO_STRING,
189
189
  groupAssetsByChunk: ON_FOR_TO_STRING,
190
- assetsSpace: (o, { forToString }) => (forToString ? 15 : Infinity),
190
+ assetsSpace: (o, { forToString }) => forToString ? 15 : Number.POSITIVE_INFINITY,
191
191
  orphanModules: OFF_FOR_TO_STRING,
192
192
  runtimeModules: ({ all, runtime }, { forToString }) => runtime !== undefined
193
193
  ? runtime
@@ -200,7 +200,7 @@ const DEFAULTS = {
200
200
  depth: OFF_FOR_TO_STRING,
201
201
  // cachedAssets: OFF_FOR_TO_STRING,
202
202
  reasons: OFF_FOR_TO_STRING,
203
- reasonsSpace: (o, { forToString }) => (forToString ? 15 : Infinity),
203
+ reasonsSpace: (o, { forToString }) => forToString ? 15 : Number.POSITIVE_INFINITY,
204
204
  groupReasonsByOrigin: ON_FOR_TO_STRING,
205
205
  usedExports: OFF_FOR_TO_STRING,
206
206
  providedExports: OFF_FOR_TO_STRING,
@@ -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 ||
@@ -367,7 +367,7 @@ const SIMPLE_PRINTERS = {
367
367
  "error.message": (message, { bold, formatError }) => message.includes("\u001b[") ? message : bold(formatError(message)),
368
368
  // "error.details": (details, { formatError }) => formatError(details),
369
369
  // "error.stack": stack => stack,
370
- // "error.moduleTrace": moduleTrace => undefined,
370
+ "error.moduleTrace": moduleTrace => undefined,
371
371
  "error.separator!": () => "\n",
372
372
  "loggingEntry(error).loggingEntry.message": (message, { red }) => mapLines(message, x => `<e> ${red(x)}`),
373
373
  "loggingEntry(warn).loggingEntry.message": (message, { yellow }) => mapLines(message, x => `<w> ${yellow(x)}`),
@@ -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[];
@@ -34,7 +33,15 @@ export type StatsModule = KnownStatsModule & Record<string, any>;
34
33
  export type StatsModuleIssuer = binding.JsStatsModuleIssuer & Record<string, any>;
35
34
  export type StatsError = binding.JsStatsError & Record<string, any>;
36
35
  export type StatsWarnings = binding.JsStatsWarning & Record<string, any>;
37
- export type StatsModuleReason = binding.JsStatsModuleReason & Record<string, any>;
36
+ export type StatsModuleTraceItem = {
37
+ originIdentifier?: string;
38
+ originName?: string;
39
+ moduleIdentifier?: string;
40
+ moduleName?: string;
41
+ originId?: string;
42
+ moduleId?: string;
43
+ };
44
+ export type StatsModuleReason = Writable<binding.JsStatsModuleReason> & Record<string, any>;
38
45
  export type KnownStatsCompilation = {
39
46
  /**
40
47
  * webpack version.
@@ -90,7 +97,7 @@ export type KnownStatsChunkOrigin = {
90
97
  type ExtractorsByOption<T, O> = {
91
98
  [x: string]: (object: O, data: T, context: StatsFactoryContext, options: any, factory: StatsFactory) => void;
92
99
  };
93
- type PreprocessedAsset = StatsAsset & {
100
+ export type PreprocessedAsset = StatsAsset & {
94
101
  type: string;
95
102
  related: PreprocessedAsset[];
96
103
  info: binding.JsStatsAssetInfo;
@@ -99,12 +106,19 @@ export type SimpleExtractors = {
99
106
  compilation: ExtractorsByOption<Compilation, StatsCompilation>;
100
107
  asset$visible: ExtractorsByOption<PreprocessedAsset, StatsAsset>;
101
108
  asset: ExtractorsByOption<PreprocessedAsset, StatsAsset>;
109
+ chunkGroup: ExtractorsByOption<{
110
+ name: string;
111
+ chunkGroup: binding.JsStatsChunkGroup;
112
+ }, StatsChunkGroup>;
102
113
  module: ExtractorsByOption<binding.JsStatsModule, StatsModule>;
103
114
  module$visible: ExtractorsByOption<binding.JsStatsModule, StatsModule>;
104
115
  moduleIssuer: ExtractorsByOption<binding.JsStatsModuleIssuer, StatsModuleIssuer>;
105
116
  profile: ExtractorsByOption<binding.JsStatsModuleProfile, StatsProfile>;
106
117
  moduleReason: ExtractorsByOption<binding.JsStatsModuleReason, StatsModuleReason>;
107
118
  chunk: ExtractorsByOption<binding.JsStatsChunk, KnownStatsChunk>;
119
+ error: ExtractorsByOption<binding.JsStatsError, StatsError>;
120
+ warning: ExtractorsByOption<binding.JsStatsWarning, StatsError>;
121
+ moduleTraceItem: ExtractorsByOption<binding.JsStatsModuleTrace, StatsModuleTraceItem>;
108
122
  };
109
123
  export declare const uniqueArray: <T, I>(items: Iterable<T>, selector: (arg: T) => Iterable<I>) => I[];
110
124
  export declare const uniqueOrderedArray: <T, I>(items: Iterable<T>, selector: (arg: T) => Iterable<I>, comparator: Comparator) => I[];
@@ -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;