@rspack/core 1.0.0-beta.3 → 1.0.0-beta.4

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.
@@ -519,6 +519,7 @@ exports.externalsType = zod_1.z.enum([
519
519
  "system",
520
520
  "promise",
521
521
  "import",
522
+ "module-import",
522
523
  "script",
523
524
  "node-commonjs"
524
525
  ]);
@@ -618,11 +619,11 @@ const devTool = zod_1.z
618
619
  const nodeOptions = zod_1.z.strictObject({
619
620
  __dirname: zod_1.z
620
621
  .boolean()
621
- .or(zod_1.z.enum(["warn-mock", "mock", "eval-only"]))
622
+ .or(zod_1.z.enum(["warn-mock", "mock", "eval-only", "node-module"]))
622
623
  .optional(),
623
624
  __filename: zod_1.z
624
625
  .boolean()
625
- .or(zod_1.z.enum(["warn-mock", "mock", "eval-only"]))
626
+ .or(zod_1.z.enum(["warn-mock", "mock", "eval-only", "node-module"]))
626
627
  .optional(),
627
628
  global: zod_1.z.boolean().or(zod_1.z.literal("warn")).optional()
628
629
  });
@@ -739,7 +740,10 @@ const statsOptions = zod_1.z.strictObject({
739
740
  errorStack: zod_1.z.boolean().optional(),
740
741
  moduleTrace: zod_1.z.boolean().optional(),
741
742
  cachedModules: zod_1.z.boolean().optional(),
742
- cached: zod_1.z.boolean().optional()
743
+ cachedAssets: zod_1.z.boolean().optional(),
744
+ cached: zod_1.z.boolean().optional(),
745
+ errorsSpace: zod_1.z.number().optional(),
746
+ warningsSpace: zod_1.z.number().optional()
743
747
  });
744
748
  const statsValue = zod_1.z.boolean().or(statsPresets).or(statsOptions);
745
749
  const plugin = zod_1.z.union([
@@ -782,11 +786,14 @@ const sharedOptimizationSplitChunksCacheGroup = {
782
786
  chunks: optimizationSplitChunksChunks.optional(),
783
787
  defaultSizeTypes: optimizationSplitChunksDefaultSizeTypes.optional(),
784
788
  minChunks: zod_1.z.number().min(1).optional(),
789
+ usedExports: zod_1.z.boolean().optional(),
785
790
  name: optimizationSplitChunksName.optional(),
786
791
  minSize: optimizationSplitChunksSizes.optional(),
787
792
  maxSize: optimizationSplitChunksSizes.optional(),
788
793
  maxAsyncSize: optimizationSplitChunksSizes.optional(),
789
794
  maxInitialSize: optimizationSplitChunksSizes.optional(),
795
+ maxAsyncRequests: zod_1.z.number().optional(),
796
+ maxInitialRequests: zod_1.z.number().optional(),
790
797
  automaticNameDelimiter: zod_1.z.string().optional()
791
798
  };
792
799
  const optimizationSplitChunksCacheGroup = zod_1.z.strictObject({
@@ -809,8 +816,6 @@ const optimizationSplitChunksOptions = zod_1.z.strictObject({
809
816
  cacheGroups: zod_1.z
810
817
  .record(zod_1.z.literal(false).or(optimizationSplitChunksCacheGroup))
811
818
  .optional(),
812
- maxAsyncRequests: zod_1.z.number().optional(),
813
- maxInitialRequests: zod_1.z.number().optional(),
814
819
  fallbackCacheGroup: zod_1.z
815
820
  .strictObject({
816
821
  chunks: optimizationSplitChunksChunks.optional(),
@@ -21,7 +21,7 @@ export type RemotesConfig = {
21
21
  export declare class ContainerReferencePlugin extends RspackBuiltinPlugin {
22
22
  name: BuiltinPluginName;
23
23
  _options: {
24
- remoteType: "module" | "global" | "system" | "promise" | "commonjs" | "umd" | "amd" | "jsonp" | "import" | "commonjs2" | "var" | "assign" | "this" | "window" | "self" | "commonjs-module" | "commonjs-static" | "amd-require" | "umd2" | "script" | "node-commonjs";
24
+ remoteType: "module" | "global" | "system" | "promise" | "commonjs" | "umd" | "amd" | "jsonp" | "import" | "commonjs2" | "var" | "assign" | "this" | "window" | "self" | "commonjs-module" | "commonjs-static" | "amd-require" | "umd2" | "module-import" | "script" | "node-commonjs";
25
25
  remotes: [string, {
26
26
  external: string[];
27
27
  shareScope: string;
@@ -1,14 +1,4 @@
1
1
  import type { Compiler } from "../Compiler";
2
- /**
3
- * only support below factories:
4
- * - compilation
5
- * - compilation.assets
6
- * - compilation.assets[].asset
7
- * - compilation.chunks
8
- * - compilation.chunks[].chunk
9
- * - compilation.modules
10
- * - compilation.modules[].module
11
- */
12
2
  export declare class DefaultStatsFactoryPlugin {
13
3
  apply(compiler: Compiler): void;
14
4
  }
@@ -102,9 +102,9 @@ const ASSETS_GROUPERS = {
102
102
  // groupByFlag("comparedForEmit");
103
103
  // groupByFlag("isOverSizeLimit");
104
104
  }
105
- // if (groupAssetsByEmitStatus || !options.cachedAssets) {
106
- // groupByFlag("cached", !options.cachedAssets);
107
- // }
105
+ if (groupAssetsByEmitStatus || !options.cachedAssets) {
106
+ groupByFlag("cached", !options.cachedAssets);
107
+ }
108
108
  if (groupAssetsByPath || groupAssetsByExtension) {
109
109
  groupConfigs.push({
110
110
  getKeys: asset => {
@@ -411,16 +411,28 @@ const SORTERS = {
411
411
  "chunk.rootModules": MODULES_SORTER,
412
412
  "chunk.modules": MODULES_SORTER,
413
413
  "module.modules": MODULES_SORTER,
414
- // not support module.reasons (missing Module.identifier())
414
+ "module.reasons": {
415
+ _: comparators => {
416
+ comparators.push((0, comparators_1.compareSelect)((x) => x.moduleIdentifier, compareIds));
417
+ comparators.push((0, comparators_1.compareSelect)((x) => x.resolvedModuleIdentifier, compareIds));
418
+ comparators.push((0, comparators_1.compareSelect)((x) => x.dependency, (0, comparators_1.compareSelect)((x) => x.type, compareIds)
419
+ // concatComparators(
420
+ // compareSelect(
421
+ // /**
422
+ // * @param {Dependency} x dependency
423
+ // * @returns {DependencyLocation} location
424
+ // */
425
+ // x => x.loc,
426
+ // compareLocations
427
+ // ),
428
+ // compareSelect(x => x.type, compareIds)
429
+ // )
430
+ ));
431
+ }
432
+ },
415
433
  "chunk.origins": {
416
434
  _: comparators => {
417
- comparators.push(
418
- // compareSelect(
419
- // origin =>
420
- // origin.module ? chunkGraph.getModuleId(origin.module) : undefined,
421
- // compareIds
422
- // ),
423
- (0, comparators_1.compareSelect)((origin) => origin.loc, compareIds), (0, comparators_1.compareSelect)((origin) => origin.request, compareIds));
435
+ comparators.push((0, comparators_1.compareSelect)((origin) => origin.moduleId, compareIds), (0, comparators_1.compareSelect)((origin) => origin.loc, compareIds), (0, comparators_1.compareSelect)((origin) => origin.request, compareIds));
424
436
  }
425
437
  }
426
438
  };
@@ -749,28 +761,24 @@ const SIMPLE_EXTRACTORS = {
749
761
  },
750
762
  errors: (object, compilation, context, options, factory) => {
751
763
  const { type, cachedGetErrors } = context;
752
- // const rawErrors = cachedGetErrors!(compilation);
764
+ const rawErrors = cachedGetErrors(compilation);
753
765
  const factorizedErrors = factory.create(`${type}.errors`, cachedGetErrors(compilation), context);
754
- // let filtered = 0;
755
- // if (options.errorDetails === "auto" && rawErrors.length >= 3) {
756
- // filtered = rawErrors
757
- // .map(e => typeof e !== "string" && e.details)
758
- // .filter(Boolean).length;
759
- // }
760
- // if (
761
- // options.errorDetails === true ||
762
- // !Number.isFinite(options.errorsSpace)
763
- // ) {
764
- // object.errors = factorizedErrors;
765
- // if (filtered) object.filteredErrorDetailsCount = filtered;
766
- // return;
767
- // }
768
- // const [errors, filteredBySpace] = errorsSpaceLimit(
769
- // factorizedErrors,
770
- // options.errorsSpace
771
- // );
772
- // object.filteredErrorDetailsCount = filtered + filteredBySpace;
773
- object.errors = factorizedErrors;
766
+ let filtered = 0;
767
+ if (options.errorDetails === "auto" && rawErrors.length >= 3) {
768
+ filtered = rawErrors
769
+ .map(e => typeof e !== "string" && e.details)
770
+ .filter(Boolean).length;
771
+ }
772
+ if (options.errorDetails === true ||
773
+ !Number.isFinite(options.errorsSpace)) {
774
+ object.errors = factorizedErrors;
775
+ if (filtered)
776
+ object.filteredErrorDetailsCount = filtered;
777
+ return;
778
+ }
779
+ const { errors, filtered: filteredBySpace } = (0, statsFactoryUtils_1.errorsSpaceLimit)(factorizedErrors, options.errorsSpace);
780
+ object.filteredErrorDetailsCount = filtered + filteredBySpace;
781
+ object.errors = errors;
774
782
  },
775
783
  errorsCount: (object, compilation, { cachedGetErrors }) => {
776
784
  object.errorsCount = (0, statsFactoryUtils_1.countWithChildren)(compilation, c => cachedGetErrors(c));
@@ -778,26 +786,22 @@ const SIMPLE_EXTRACTORS = {
778
786
  warnings: (object, compilation, context, options, factory) => {
779
787
  const { type, cachedGetWarnings } = context;
780
788
  const rawWarnings = factory.create(`${type}.warnings`, cachedGetWarnings(compilation), context);
781
- // let filtered = 0;
782
- // if (options.errorDetails === "auto") {
783
- // filtered = cachedGetWarnings!(compilation)
784
- // .map(e => typeof e !== "string" && e.details)
785
- // .filter(Boolean).length;
786
- // }
787
- // if (
788
- // options.errorDetails === true ||
789
- // !Number.isFinite(options.warningsSpace)
790
- // ) {
791
- // object.warnings = rawWarnings;
792
- // if (filtered) object.filteredWarningDetailsCount = filtered;
793
- // return;
794
- // }
795
- // const [warnings, filteredBySpace] = errorsSpaceLimit(
796
- // rawWarnings,
797
- // options.warningsSpace
798
- // );
799
- // object.filteredWarningDetailsCount = filtered + filteredBySpace;
800
- object.warnings = rawWarnings;
789
+ let filtered = 0;
790
+ if (options.errorDetails === "auto") {
791
+ filtered = cachedGetWarnings(compilation)
792
+ .map(e => typeof e !== "string" && e.details)
793
+ .filter(Boolean).length;
794
+ }
795
+ if (options.errorDetails === true ||
796
+ !Number.isFinite(options.warningsSpace)) {
797
+ object.warnings = rawWarnings;
798
+ if (filtered)
799
+ object.filteredWarningDetailsCount = filtered;
800
+ return;
801
+ }
802
+ const { errors: warnings, filtered: filteredBySpace } = (0, statsFactoryUtils_1.errorsSpaceLimit)(rawWarnings, options.warningsSpace);
803
+ object.filteredWarningDetailsCount = filtered + filteredBySpace;
804
+ object.warnings = warnings;
801
805
  },
802
806
  warningsCount: (object, compilation, context) => {
803
807
  const { cachedGetWarnings } = context;
@@ -821,8 +825,11 @@ const SIMPLE_EXTRACTORS = {
821
825
  related: Object.fromEntries(asset.info.related.map(i => [i.name, i.value]))
822
826
  };
823
827
  // - comparedForEmit
824
- // - cached
825
- Object.assign(object, factory.create(`${context.type}$visible`, asset, context));
828
+ const cached = !object.emitted;
829
+ object.cached = cached;
830
+ if (!cached || options.cachedAssets) {
831
+ Object.assign(object, factory.create(`${context.type}$visible`, asset, context));
832
+ }
826
833
  }
827
834
  },
828
835
  asset$visible: {
@@ -843,6 +850,9 @@ const SIMPLE_EXTRACTORS = {
843
850
  ids: (object, asset) => {
844
851
  object.chunks = asset.chunks;
845
852
  object.auxiliaryChunks = asset.auxiliaryChunks;
853
+ },
854
+ performance: (object, asset) => {
855
+ object.isOverSizeLimit = asset.info.isOverSizeLimit;
846
856
  }
847
857
  },
848
858
  chunkGroup: {
@@ -858,7 +868,10 @@ const SIMPLE_EXTRACTORS = {
858
868
  object.auxiliaryAssets = chunkGroup.auxiliaryAssets;
859
869
  object.auxiliaryAssetsSize = chunkGroup.auxiliaryAssetsSize;
860
870
  object.children = chunkGroup.children;
861
- // - childAssets
871
+ object.childAssets = chunkGroup.childAssets;
872
+ },
873
+ performance: (object, { chunkGroup }) => {
874
+ object.isOverSizeLimit = chunkGroup.isOverSizeLimit;
862
875
  }
863
876
  },
864
877
  module: {
@@ -929,8 +942,10 @@ const SIMPLE_EXTRACTORS = {
929
942
  },
930
943
  reasons: (object, module, context, options, factory) => {
931
944
  const { type } = context;
932
- object.reasons = factory.create(`${type.slice(0, -8)}.reasons`, module.commonAttributes.reasons, context);
933
- // object.filteredReasons
945
+ const groupsReasons = factory.create(`${type.slice(0, -8)}.reasons`, module.commonAttributes.reasons, context);
946
+ const limited = (0, statsFactoryUtils_1.spaceLimited)(groupsReasons, options.reasonsSpace);
947
+ object.reasons = limited.children;
948
+ object.filteredReasons = limited.filteredChildren;
934
949
  },
935
950
  source: (object, module) => {
936
951
  const { commonAttributes } = module;
@@ -997,6 +1012,7 @@ const SIMPLE_EXTRACTORS = {
997
1012
  if (module.moduleDescriptor) {
998
1013
  object.identifier = module.moduleDescriptor.identifier;
999
1014
  object.name = module.moduleDescriptor.name;
1015
+ // - profile
1000
1016
  }
1001
1017
  },
1002
1018
  ids: (object, module) => {
@@ -1011,11 +1027,22 @@ const SIMPLE_EXTRACTORS = {
1011
1027
  }
1012
1028
  object.type = reason.type;
1013
1029
  object.userRequest = reason.userRequest;
1030
+ if (reason.resolvedModuleDescriptor) {
1031
+ object.resolvedModuleIdentifier =
1032
+ reason.resolvedModuleDescriptor.identifier;
1033
+ object.resolvedModule = reason.resolvedModuleDescriptor.name;
1034
+ }
1035
+ // - explanation
1036
+ // - active
1037
+ // - loc
1014
1038
  },
1015
1039
  ids: (object, reason) => {
1016
1040
  object.moduleId = reason.moduleDescriptor
1017
1041
  ? reason.moduleDescriptor.id
1018
1042
  : null;
1043
+ object.resolvedModuleId = reason.resolvedModuleDescriptor
1044
+ ? reason.resolvedModuleDescriptor.id
1045
+ : null;
1019
1046
  }
1020
1047
  },
1021
1048
  chunk: {
@@ -1045,24 +1072,32 @@ const SIMPLE_EXTRACTORS = {
1045
1072
  },
1046
1073
  chunkModules: (object, chunk, context, options, factory) => {
1047
1074
  const { type } = context;
1048
- object.modules = factory.create(`${type}.modules`, chunk.modules, context);
1075
+ const groupedModules = factory.create(`${type}.modules`, chunk.modules, context);
1076
+ const limited = (0, statsFactoryUtils_1.spaceLimited)(groupedModules, options.chunkModulesSpace);
1077
+ object.modules = limited.children;
1078
+ object.filteredModules = limited.filteredChildren;
1049
1079
  },
1050
1080
  chunkOrigins: (object, chunk, context, options, factory) => {
1051
- object.origins = chunk.origins.map(origin => {
1052
- const { moduleDescriptor, loc, request } = origin;
1053
- const statsChunkOrigin = {
1054
- module: moduleDescriptor ? moduleDescriptor.identifier : "",
1055
- moduleIdentifier: moduleDescriptor ? moduleDescriptor.identifier : "",
1056
- moduleName: moduleDescriptor ? moduleDescriptor.name : "",
1057
- moduleId: moduleDescriptor ? moduleDescriptor.id : undefined,
1058
- loc,
1059
- request
1060
- };
1061
- return statsChunkOrigin;
1062
- });
1081
+ const { type } = context;
1082
+ object.origins = factory.create(`${type}.origins`, chunk.origins, context);
1083
+ }
1084
+ },
1085
+ chunkOrigin: {
1086
+ _: (object, origin, context) => {
1087
+ const { moduleDescriptor, loc, request } = origin;
1088
+ const statsChunkOrigin = {
1089
+ module: moduleDescriptor ? moduleDescriptor.identifier : "",
1090
+ moduleIdentifier: moduleDescriptor ? moduleDescriptor.identifier : "",
1091
+ moduleName: moduleDescriptor ? moduleDescriptor.name : "",
1092
+ loc,
1093
+ request
1094
+ };
1095
+ Object.assign(object, statsChunkOrigin);
1096
+ },
1097
+ ids: (object, origin) => {
1098
+ object.moduleId = origin.moduleDescriptor?.id;
1063
1099
  }
1064
1100
  },
1065
- // chunkOrigin
1066
1101
  error: EXTRACT_ERROR,
1067
1102
  warning: EXTRACT_ERROR,
1068
1103
  moduleTraceItem: {
@@ -1081,18 +1116,21 @@ const SIMPLE_EXTRACTORS = {
1081
1116
  object.moduleId = module.moduleDescriptor.id;
1082
1117
  }
1083
1118
  }
1084
- // moduleTraceDependency
1119
+ // - moduleTraceDependency
1120
+ };
1121
+ const FILTER = {
1122
+ "module.reasons": {
1123
+ "!orphanModules": reason => {
1124
+ if (reason.moduleChunks === 0) {
1125
+ return false;
1126
+ }
1127
+ }
1128
+ }
1129
+ };
1130
+ const FILTER_RESULTS = {
1131
+ // Deprecated: "compilation.warnings": {}
1132
+ // Keep this object to retain this phase.
1085
1133
  };
1086
- /**
1087
- * only support below factories:
1088
- * - compilation
1089
- * - compilation.assets
1090
- * - compilation.assets[].asset
1091
- * - compilation.chunks
1092
- * - compilation.chunks[].chunk
1093
- * - compilation.modules
1094
- * - compilation.modules[].module
1095
- */
1096
1134
  class DefaultStatsFactoryPlugin {
1097
1135
  apply(compiler) {
1098
1136
  compiler.hooks.compilation.tap("DefaultStatsFactoryPlugin", compilation => {
@@ -1104,14 +1142,16 @@ class DefaultStatsFactoryPlugin {
1104
1142
  .for(hookFor)
1105
1143
  .tap("DefaultStatsFactoryPlugin", (obj, data, ctx) => fn(obj, data, ctx, options, stats));
1106
1144
  });
1107
- // not support filter module.reasons.!orphanModules
1108
- // iterateConfig(FILTER, options, (hookFor, fn) => {
1109
- // stats.hooks.filter
1110
- // .for(hookFor)
1111
- // .tap("DefaultStatsFactoryPlugin", (item, ctx, idx, i) =>
1112
- // fn(item, ctx, options, idx, i)
1113
- // );
1114
- // });
1145
+ (0, statsFactoryUtils_1.iterateConfig)(FILTER, options, (hookFor, fn) => {
1146
+ stats.hooks.filter
1147
+ .for(hookFor)
1148
+ .tap("DefaultStatsFactoryPlugin", (item, ctx, idx, i) => fn(item, ctx, options, idx, i));
1149
+ });
1150
+ (0, statsFactoryUtils_1.iterateConfig)(FILTER_RESULTS, options, (hookFor, fn) => {
1151
+ stats.hooks.filterResults
1152
+ .for(hookFor)
1153
+ .tap("DefaultStatsFactoryPlugin", (item, ctx, idx, i) => fn(item, ctx, options, idx, i));
1154
+ });
1115
1155
  (0, statsFactoryUtils_1.iterateConfig)(SORTERS, options, (hookFor, fn) => {
1116
1156
  stats.hooks.sort
1117
1157
  .for(hookFor)
@@ -39,12 +39,13 @@ const NAMED_PRESETS = {
39
39
  orphanModules: true,
40
40
  runtimeModules: true,
41
41
  // exclude: false,
42
- // errorsSpace: Infinity,
43
- // warningsSpace: Infinity,
42
+ excludeModules: false,
43
+ errorsSpace: Number.POSITIVE_INFINITY,
44
+ warningsSpace: Number.POSITIVE_INFINITY,
44
45
  modulesSpace: Number.POSITIVE_INFINITY,
45
- // chunkModulesSpace: Infinity,
46
+ chunkModulesSpace: Number.POSITIVE_INFINITY,
46
47
  assetsSpace: Number.POSITIVE_INFINITY,
47
- // reasonsSpace: Infinity,
48
+ reasonsSpace: Number.POSITIVE_INFINITY,
48
49
  children: true
49
50
  },
50
51
  detailed: {
@@ -66,20 +67,20 @@ const NAMED_PRESETS = {
66
67
  publicPath: true,
67
68
  logging: true,
68
69
  runtimeModules: true,
69
- // exclude: false,
70
- // errorsSpace: 1000,
71
- // warningsSpace: 1000,
70
+ excludeModules: false,
71
+ errorsSpace: 1000,
72
+ warningsSpace: 1000,
72
73
  modulesSpace: 1000,
73
- assetsSpace: 1000
74
- // reasonsSpace: 1000
74
+ assetsSpace: 1000,
75
+ reasonsSpace: 1000
75
76
  },
76
77
  minimal: {
77
78
  all: false,
78
79
  version: true,
79
80
  timings: true,
80
81
  modules: true,
81
- // errorsSpace: 0,
82
- // warningsSpace: 0,
82
+ errorsSpace: 0,
83
+ warningsSpace: 0,
83
84
  modulesSpace: 0,
84
85
  assets: true,
85
86
  assetsSpace: 0,
@@ -93,7 +94,7 @@ const NAMED_PRESETS = {
93
94
  all: false,
94
95
  errors: true,
95
96
  errorsCount: true,
96
- // errorsSpace: Infinity,
97
+ errorsSpace: Number.POSITIVE_INFINITY,
97
98
  moduleTrace: true,
98
99
  logging: "error"
99
100
  },
@@ -101,10 +102,10 @@ const NAMED_PRESETS = {
101
102
  all: false,
102
103
  errors: true,
103
104
  errorsCount: true,
104
- // errorsSpace: Infinity,
105
+ errorsSpace: Number.POSITIVE_INFINITY,
105
106
  warnings: true,
106
107
  warningsCount: true,
107
- // warningsSpace: Infinity,
108
+ warningsSpace: Number.POSITIVE_INFINITY,
108
109
  logging: "warn"
109
110
  },
110
111
  summary: {
@@ -197,7 +198,7 @@ const DEFAULTS = {
197
198
  cachedModules: ({ all, cached }, { forToString }) => cached !== undefined ? cached : forToString ? all === true : all !== false,
198
199
  moduleAssets: OFF_FOR_TO_STRING,
199
200
  depth: OFF_FOR_TO_STRING,
200
- // cachedAssets: OFF_FOR_TO_STRING,
201
+ cachedAssets: OFF_FOR_TO_STRING,
201
202
  reasons: OFF_FOR_TO_STRING,
202
203
  reasonsSpace: (o, { forToString }) => forToString ? 15 : Number.POSITIVE_INFINITY,
203
204
  groupReasonsByOrigin: ON_FOR_TO_STRING,
@@ -39,12 +39,11 @@ class StatsFactory {
39
39
  ]))
40
40
  });
41
41
  const hooks = this.hooks;
42
- this._caches = Object.keys(hooks).reduce((prev, curr) => {
43
- return {
44
- ...prev,
45
- [curr]: new Map()
46
- };
47
- }, {});
42
+ const caches = {};
43
+ for (const key of Object.keys(hooks)) {
44
+ caches[key] = new Map();
45
+ }
46
+ this._caches = caches;
48
47
  this._inCreate = false;
49
48
  }
50
49
  _getAllLevelHooks(hookMap, cache, type) {
@@ -1,5 +1,6 @@
1
1
  /// <reference types="node" />
2
2
  import type * as binding from "@rspack/binding";
3
+ import type { JsOriginRecord } from "@rspack/binding";
3
4
  import type { Compilation, NormalizedStatsOptions } from "../Compilation";
4
5
  import { type Comparator } from "../util/comparators";
5
6
  import type { StatsFactory, StatsFactoryContext } from "./StatsFactory";
@@ -23,8 +24,10 @@ export type KnownStatsChunkGroup = {
23
24
  prefetch?: StatsChunkGroup[];
24
25
  };
25
26
  childAssets?: {
26
- [index: string]: string[];
27
+ preload?: string[];
28
+ prefetch?: string[];
27
29
  };
30
+ isOverSizeLimit?: boolean;
28
31
  };
29
32
  export type KnownStatsChunk = {
30
33
  type: string;
@@ -70,6 +73,8 @@ export type KnownStatsAsset = {
70
73
  info: AssetInfo;
71
74
  size: number;
72
75
  emitted: boolean;
76
+ cached: boolean;
77
+ related?: StatsAsset[];
73
78
  chunkNames?: (string | number)[];
74
79
  chunkIdHints?: (string | number)[];
75
80
  chunks?: (string | null | undefined)[];
@@ -163,9 +168,12 @@ export type KnownStatsModuleReason = {
163
168
  moduleIdentifier?: string;
164
169
  module?: string;
165
170
  moduleName?: string;
171
+ resolvedModuleIdentifier?: string;
172
+ resolvedModule?: string;
166
173
  type?: string;
167
174
  userRequest?: string;
168
175
  moduleId?: string | null;
176
+ resolvedModuleId?: string | number | null;
169
177
  };
170
178
  export type StatsModuleReason = KnownStatsModuleReason & Record<string, any>;
171
179
  export type KnownStatsChunkOrigin = {
@@ -243,6 +251,7 @@ export type SimpleExtractors = {
243
251
  profile: ExtractorsByOption<binding.JsStatsModuleProfile, StatsProfile>;
244
252
  moduleReason: ExtractorsByOption<binding.JsStatsModuleReason, StatsModuleReason>;
245
253
  chunk: ExtractorsByOption<binding.JsStatsChunk, KnownStatsChunk>;
254
+ chunkOrigin: ExtractorsByOption<JsOriginRecord, StatsChunkOrigin>;
246
255
  error: ExtractorsByOption<binding.JsStatsError, StatsError>;
247
256
  warning: ExtractorsByOption<binding.JsStatsWarning, StatsError>;
248
257
  moduleTraceItem: ExtractorsByOption<binding.JsStatsModuleTrace, StatsModuleTraceItem>;
@@ -275,4 +284,8 @@ export declare const mergeToObject: (items: {
275
284
  name: string;
276
285
  }[]) => Object;
277
286
  export declare function resolveStatsMillisecond(s: binding.JsStatsMillisecond): number;
287
+ export declare const errorsSpaceLimit: (errors: StatsError[], max: number) => {
288
+ errors: StatsError[];
289
+ filtered: number;
290
+ };
278
291
  export {};
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.resolveStatsMillisecond = exports.mergeToObject = exports.moduleGroup = exports.assetGroup = exports.sortByField = exports.countWithChildren = exports.spaceLimited = exports.collapse = exports.getTotalItems = exports.iterateConfig = exports.uniqueOrderedArray = exports.uniqueArray = void 0;
3
+ exports.errorsSpaceLimit = exports.resolveStatsMillisecond = exports.mergeToObject = exports.moduleGroup = exports.assetGroup = exports.sortByField = exports.countWithChildren = exports.spaceLimited = exports.collapse = exports.getTotalItems = exports.iterateConfig = exports.uniqueOrderedArray = exports.uniqueArray = void 0;
4
4
  const comparators_1 = require("../util/comparators");
5
5
  const uniqueArray = (items, selector) => {
6
6
  const set = new Set();
@@ -279,3 +279,64 @@ function resolveStatsMillisecond(s) {
279
279
  return s.secs * 1000 + s.subsecMillis;
280
280
  }
281
281
  exports.resolveStatsMillisecond = resolveStatsMillisecond;
282
+ const errorsSpaceLimit = (errors, max) => {
283
+ let filtered = 0;
284
+ // Can not fit into limit
285
+ // print only messages
286
+ if (errors.length + 1 >= max) {
287
+ return {
288
+ errors: errors.map(error => {
289
+ if (typeof error === "string" || !error.details)
290
+ return error;
291
+ filtered++;
292
+ return { ...error, details: "" };
293
+ }),
294
+ filtered
295
+ };
296
+ }
297
+ let fullLength = errors.length;
298
+ let result = errors;
299
+ let i = 0;
300
+ for (; i < errors.length; i++) {
301
+ const error = errors[i];
302
+ if (typeof error !== "string" && error.details) {
303
+ const splitted = error.details.split("\n");
304
+ const len = splitted.length;
305
+ fullLength += len;
306
+ if (fullLength > max) {
307
+ result = i > 0 ? errors.slice(0, i) : [];
308
+ const overLimit = fullLength - max + 1;
309
+ const error = errors[i++];
310
+ result.push({
311
+ ...error,
312
+ details: error.details.split("\n").slice(0, -overLimit).join("\n"),
313
+ filteredDetails: overLimit
314
+ });
315
+ filtered = errors.length - i;
316
+ for (; i < errors.length; i++) {
317
+ const error = errors[i];
318
+ if (typeof error === "string" || !error.details)
319
+ result.push(error);
320
+ result.push({ ...error, details: "" });
321
+ }
322
+ break;
323
+ }
324
+ if (fullLength === max) {
325
+ result = errors.slice(0, ++i);
326
+ filtered = errors.length - i;
327
+ for (; i < errors.length; i++) {
328
+ const error = errors[i];
329
+ if (typeof error === "string" || !error.details)
330
+ result.push(error);
331
+ result.push({ ...error, details: "" });
332
+ }
333
+ break;
334
+ }
335
+ }
336
+ }
337
+ return {
338
+ errors: result,
339
+ filtered
340
+ };
341
+ };
342
+ exports.errorsSpaceLimit = errorsSpaceLimit;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rspack/core",
3
- "version": "1.0.0-beta.3",
3
+ "version": "1.0.0-beta.4",
4
4
  "webpackVersion": "5.75.0",
5
5
  "license": "MIT",
6
6
  "description": "The fast Rust-based web bundler with webpack-compatible API",
@@ -58,9 +58,9 @@
58
58
  },
59
59
  "dependencies": {
60
60
  "@module-federation/runtime-tools": "0.2.3",
61
+ "@rspack/lite-tapable": "1.0.0-beta.5",
61
62
  "caniuse-lite": "^1.0.30001616",
62
- "@rspack/binding": "1.0.0-beta.3",
63
- "@rspack/lite-tapable": "1.0.0-beta.3"
63
+ "@rspack/binding": "1.0.0-beta.4"
64
64
  },
65
65
  "peerDependencies": {
66
66
  "@swc/helpers": ">=0.5.1"