@rspack/core 1.0.0-beta.3 → 1.0.0-beta.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 (41) hide show
  1. package/dist/Compilation.d.ts +1 -7
  2. package/dist/Compilation.js +5 -13
  3. package/dist/DependenciesBlock.d.ts +8 -0
  4. package/dist/DependenciesBlock.js +30 -0
  5. package/dist/Dependency.d.ts +8 -0
  6. package/dist/Dependency.js +32 -0
  7. package/dist/Module.d.ts +6 -3
  8. package/dist/Module.js +13 -0
  9. package/dist/NormalModule.d.ts +2 -1
  10. package/dist/NormalModule.js +1 -1
  11. package/dist/builtin-plugin/ExternalsPlugin.d.ts +4 -4
  12. package/dist/builtin-plugin/HtmlRspackPlugin.d.ts +41 -10
  13. package/dist/builtin-plugin/HtmlRspackPlugin.js +16 -4
  14. package/dist/builtin-plugin/LightningCssMiminizerRspackPlugin.d.ts +2 -2
  15. package/dist/builtin-plugin/LightningCssMiminizerRspackPlugin.js +1 -7
  16. package/dist/builtin-plugin/css-extract/hmr/hotModuleReplacement.js +18 -11
  17. package/dist/builtin-plugin/css-extract/loader.d.ts +1 -1
  18. package/dist/builtin-plugin/css-extract/loader.js +2 -10
  19. package/dist/builtin-plugin/index.d.ts +0 -1
  20. package/dist/builtin-plugin/index.js +0 -1
  21. package/dist/config/adapterRuleUse.d.ts +1 -0
  22. package/dist/config/adapterRuleUse.js +2 -6
  23. package/dist/config/defaults.js +22 -13
  24. package/dist/config/zod.d.ts +199 -79
  25. package/dist/config/zod.js +10 -5
  26. package/dist/container/ContainerReferencePlugin.d.ts +1 -1
  27. package/dist/exports.d.ts +0 -1
  28. package/dist/exports.js +7 -10
  29. package/dist/loader-runner/index.js +3 -3
  30. package/dist/node/NodeWatchFileSystem.d.ts +3 -3
  31. package/dist/node/NodeWatchFileSystem.js +6 -6
  32. package/dist/stats/DefaultStatsFactoryPlugin.d.ts +0 -10
  33. package/dist/stats/DefaultStatsFactoryPlugin.js +130 -90
  34. package/dist/stats/DefaultStatsPresetPlugin.js +16 -15
  35. package/dist/stats/StatsFactory.js +5 -6
  36. package/dist/stats/statsFactoryUtils.d.ts +14 -1
  37. package/dist/stats/statsFactoryUtils.js +62 -1
  38. package/dist/util/fs.d.ts +245 -22
  39. package/package.json +3 -3
  40. package/dist/builtin-plugin/SwcCssMinimizerPlugin.d.ts +0 -16
  41. package/dist/builtin-plugin/SwcCssMinimizerPlugin.js +0 -12
@@ -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;
package/dist/exports.d.ts CHANGED
@@ -140,7 +140,6 @@ export type { EvalDevToolModulePluginOptions } from "./builtin-plugin";
140
140
  export type { CssExtractRspackLoaderOptions, CssExtractRspackPluginOptions } from "./builtin-plugin";
141
141
  export { HtmlRspackPlugin } from "./builtin-plugin";
142
142
  export { SwcJsMinimizerRspackPlugin } from "./builtin-plugin";
143
- export { SwcCssMinimizerRspackPlugin } from "./builtin-plugin";
144
143
  export { LightningCssMinimizerRspackPlugin } from "./builtin-plugin";
145
144
  export { CopyRspackPlugin } from "./builtin-plugin";
146
145
  export { SourceMapDevToolPlugin } from "./builtin-plugin";
package/dist/exports.js CHANGED
@@ -26,8 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.CssExtractRspackPlugin = exports.EvalDevToolModulePlugin = exports.EvalSourceMapDevToolPlugin = exports.SourceMapDevToolPlugin = exports.CopyRspackPlugin = exports.LightningCssMinimizerRspackPlugin = exports.SwcCssMinimizerRspackPlugin = exports.SwcJsMinimizerRspackPlugin = exports.HtmlRspackPlugin = exports.sharing = exports.container = exports.optimize = exports.webworker = exports.javascript = exports.wasm = exports.library = exports.electron = exports.node = exports.web = exports.NormalModuleReplacementPlugin = exports.LoaderTargetPlugin = exports.LoaderOptionsPlugin = exports.EnvironmentPlugin = exports.HotModuleReplacementPlugin = exports.ExternalsPlugin = exports.DynamicEntryPlugin = exports.EntryPlugin = exports.ProgressPlugin = exports.DefinePlugin = exports.ProvidePlugin = exports.IgnorePlugin = exports.BannerPlugin = exports.EntryOptionPlugin = exports.util = exports.config = exports.sources = exports.WebpackError = exports.Template = exports.ModuleFilenameHelpers = exports.Stats = exports.RuntimeGlobals = exports.NormalModule = exports.MultiStats = exports.WebpackOptionsApply = exports.RspackOptionsApply = exports.MultiCompiler = exports.Compiler = exports.Compilation = exports.version = exports.rspackVersion = void 0;
30
- exports.experiments = void 0;
29
+ exports.experiments = exports.CssExtractRspackPlugin = exports.EvalDevToolModulePlugin = exports.EvalSourceMapDevToolPlugin = exports.SourceMapDevToolPlugin = exports.CopyRspackPlugin = exports.LightningCssMinimizerRspackPlugin = exports.SwcJsMinimizerRspackPlugin = exports.HtmlRspackPlugin = exports.sharing = exports.container = exports.optimize = exports.webworker = exports.javascript = exports.wasm = exports.library = exports.electron = exports.node = exports.web = exports.NormalModuleReplacementPlugin = exports.LoaderTargetPlugin = exports.LoaderOptionsPlugin = exports.EnvironmentPlugin = exports.HotModuleReplacementPlugin = exports.ExternalsPlugin = exports.DynamicEntryPlugin = exports.EntryPlugin = exports.ProgressPlugin = exports.DefinePlugin = exports.ProvidePlugin = exports.IgnorePlugin = exports.BannerPlugin = exports.EntryOptionPlugin = exports.util = exports.config = exports.sources = exports.WebpackError = exports.Template = exports.ModuleFilenameHelpers = exports.Stats = exports.RuntimeGlobals = exports.NormalModule = exports.MultiStats = exports.WebpackOptionsApply = exports.RspackOptionsApply = exports.MultiCompiler = exports.Compiler = exports.Compilation = exports.version = exports.rspackVersion = void 0;
31
30
  const package_json_1 = require("../package.json");
32
31
  // this is a hack to be compatible with plugin which detect webpack's version
33
32
  const rspackVersion = package_json_1.version;
@@ -154,19 +153,17 @@ Object.defineProperty(exports, "HtmlRspackPlugin", { enumerable: true, get: func
154
153
  var builtin_plugin_21 = require("./builtin-plugin");
155
154
  Object.defineProperty(exports, "SwcJsMinimizerRspackPlugin", { enumerable: true, get: function () { return builtin_plugin_21.SwcJsMinimizerRspackPlugin; } });
156
155
  var builtin_plugin_22 = require("./builtin-plugin");
157
- Object.defineProperty(exports, "SwcCssMinimizerRspackPlugin", { enumerable: true, get: function () { return builtin_plugin_22.SwcCssMinimizerRspackPlugin; } });
156
+ Object.defineProperty(exports, "LightningCssMinimizerRspackPlugin", { enumerable: true, get: function () { return builtin_plugin_22.LightningCssMinimizerRspackPlugin; } });
158
157
  var builtin_plugin_23 = require("./builtin-plugin");
159
- Object.defineProperty(exports, "LightningCssMinimizerRspackPlugin", { enumerable: true, get: function () { return builtin_plugin_23.LightningCssMinimizerRspackPlugin; } });
158
+ Object.defineProperty(exports, "CopyRspackPlugin", { enumerable: true, get: function () { return builtin_plugin_23.CopyRspackPlugin; } });
160
159
  var builtin_plugin_24 = require("./builtin-plugin");
161
- Object.defineProperty(exports, "CopyRspackPlugin", { enumerable: true, get: function () { return builtin_plugin_24.CopyRspackPlugin; } });
160
+ Object.defineProperty(exports, "SourceMapDevToolPlugin", { enumerable: true, get: function () { return builtin_plugin_24.SourceMapDevToolPlugin; } });
162
161
  var builtin_plugin_25 = require("./builtin-plugin");
163
- Object.defineProperty(exports, "SourceMapDevToolPlugin", { enumerable: true, get: function () { return builtin_plugin_25.SourceMapDevToolPlugin; } });
162
+ Object.defineProperty(exports, "EvalSourceMapDevToolPlugin", { enumerable: true, get: function () { return builtin_plugin_25.EvalSourceMapDevToolPlugin; } });
164
163
  var builtin_plugin_26 = require("./builtin-plugin");
165
- Object.defineProperty(exports, "EvalSourceMapDevToolPlugin", { enumerable: true, get: function () { return builtin_plugin_26.EvalSourceMapDevToolPlugin; } });
164
+ Object.defineProperty(exports, "EvalDevToolModulePlugin", { enumerable: true, get: function () { return builtin_plugin_26.EvalDevToolModulePlugin; } });
166
165
  var builtin_plugin_27 = require("./builtin-plugin");
167
- Object.defineProperty(exports, "EvalDevToolModulePlugin", { enumerable: true, get: function () { return builtin_plugin_27.EvalDevToolModulePlugin; } });
168
- var builtin_plugin_28 = require("./builtin-plugin");
169
- Object.defineProperty(exports, "CssExtractRspackPlugin", { enumerable: true, get: function () { return builtin_plugin_28.CssExtractRspackPlugin; } });
166
+ Object.defineProperty(exports, "CssExtractRspackPlugin", { enumerable: true, get: function () { return builtin_plugin_27.CssExtractRspackPlugin; } });
170
167
  ///// Experiments Stuff /////
171
168
  const binding_1 = require("@rspack/binding");
172
169
  exports.experiments = {
@@ -335,7 +335,7 @@ async function runLoaders(compiler, context) {
335
335
  return new Promise((resolve, reject) => {
336
336
  compiler
337
337
  ._lastCompilation.__internal_getInner()
338
- .importModule(request, options.publicPath, options.baseUri, context._module.moduleIdentifier, loaderContext.context, (err, res) => {
338
+ .importModule(request, options.layer, options.publicPath, options.baseUri, context._module.moduleIdentifier, loaderContext.context, (err, res) => {
339
339
  if (err)
340
340
  reject(err);
341
341
  else {
@@ -361,7 +361,7 @@ async function runLoaders(compiler, context) {
361
361
  }
362
362
  return compiler
363
363
  ._lastCompilation.__internal_getInner()
364
- .importModule(request, options.publicPath, options.baseUri, context._module.moduleIdentifier, loaderContext.context, (err, res) => {
364
+ .importModule(request, options.layer, options.publicPath, options.baseUri, context._module.moduleIdentifier, loaderContext.context, (err, res) => {
365
365
  if (err) {
366
366
  callback(err, undefined);
367
367
  }
@@ -613,7 +613,7 @@ async function runLoaders(compiler, context) {
613
613
  let compilation = compiler._lastCompilation;
614
614
  let step = 0;
615
615
  while (compilation) {
616
- NormalModule_1.NormalModule.getCompilationHooks(compilation).loader.call(loaderContext);
616
+ NormalModule_1.NormalModule.getCompilationHooks(compilation).loader.call(loaderContext, loaderContext._module);
617
617
  compilation = compilation.compiler.parentCompilation;
618
618
  step++;
619
619
  if (step > 1000) {
@@ -8,11 +8,11 @@
8
8
  * https://github.com/webpack/webpack/blob/main/LICENSE
9
9
  */
10
10
  import Watchpack from "../../compiled/watchpack";
11
- import type { FileSystemInfoEntry, WatchFileSystem, Watcher } from "../util/fs";
11
+ import type { FileSystemInfoEntry, InputFileSystem, WatchFileSystem, Watcher } from "../util/fs";
12
12
  export default class NodeWatchFileSystem implements WatchFileSystem {
13
- inputFileSystem: any;
13
+ inputFileSystem: InputFileSystem;
14
14
  watcherOptions: Watchpack.WatchOptions;
15
15
  watcher: Watchpack;
16
- constructor(inputFileSystem: any);
16
+ constructor(inputFileSystem: InputFileSystem);
17
17
  watch(files: Iterable<string>, directories: Iterable<string>, missing: Iterable<string>, startTime: number, options: Watchpack.WatchOptions, callback: (error: Error, fileTimeInfoEntries: Map<string, FileSystemInfoEntry | "ignore">, contextTimeInfoEntries: Map<string, FileSystemInfoEntry | "ignore">, changedFiles: Set<string>, removedFiles: Set<string>) => void, callbackUndelayed: (fileName: string, changeTime: number) => void): Watcher;
18
18
  }
@@ -63,10 +63,10 @@ class NodeWatchFileSystem {
63
63
  if (this.inputFileSystem?.purge) {
64
64
  const fs = this.inputFileSystem;
65
65
  for (const item of changes) {
66
- fs.purge(item);
66
+ fs.purge?.(item);
67
67
  }
68
68
  for (const item of removals) {
69
- fs.purge(item);
69
+ fs.purge?.(item);
70
70
  }
71
71
  }
72
72
  const { fileTimeInfoEntries, contextTimeInfoEntries } = fetchTimeInfo();
@@ -96,7 +96,7 @@ class NodeWatchFileSystem {
96
96
  if (items && this.inputFileSystem && this.inputFileSystem.purge) {
97
97
  const fs = this.inputFileSystem;
98
98
  for (const item of items) {
99
- fs.purge(item);
99
+ fs.purge?.(item);
100
100
  }
101
101
  }
102
102
  return items;
@@ -106,7 +106,7 @@ class NodeWatchFileSystem {
106
106
  if (items && this.inputFileSystem && this.inputFileSystem.purge) {
107
107
  const fs = this.inputFileSystem;
108
108
  for (const item of items) {
109
- fs.purge(item);
109
+ fs.purge?.(item);
110
110
  }
111
111
  }
112
112
  return items;
@@ -124,12 +124,12 @@ class NodeWatchFileSystem {
124
124
  const fs = this.inputFileSystem;
125
125
  if (removals) {
126
126
  for (const item of removals) {
127
- fs.purge(item);
127
+ fs.purge?.(item);
128
128
  }
129
129
  }
130
130
  if (changes) {
131
131
  for (const item of changes) {
132
- fs.purge(item);
132
+ fs.purge?.(item);
133
133
  }
134
134
  }
135
135
  }
@@ -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) {