webpack 5.99.9 → 5.100.1

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 (308) hide show
  1. package/bin/webpack.js +8 -2
  2. package/hot/log.js +15 -15
  3. package/hot/poll.js +1 -0
  4. package/lib/APIPlugin.js +3 -3
  5. package/lib/AbstractMethodError.js +1 -0
  6. package/lib/AutomaticPrefetchPlugin.js +1 -0
  7. package/lib/BannerPlugin.js +1 -1
  8. package/lib/CaseSensitiveModulesWarning.js +4 -4
  9. package/lib/Chunk.js +6 -6
  10. package/lib/ChunkGraph.js +37 -31
  11. package/lib/ChunkGroup.js +4 -4
  12. package/lib/ChunkTemplate.js +1 -1
  13. package/lib/CleanPlugin.js +94 -17
  14. package/lib/CodeGenerationResults.js +1 -1
  15. package/lib/CompatibilityPlugin.js +5 -2
  16. package/lib/Compilation.js +67 -45
  17. package/lib/Compiler.js +46 -16
  18. package/lib/ConcatenationScope.js +15 -6
  19. package/lib/ConstPlugin.js +5 -3
  20. package/lib/ContextModule.js +16 -12
  21. package/lib/ContextModuleFactory.js +4 -3
  22. package/lib/ContextReplacementPlugin.js +4 -2
  23. package/lib/CssModule.js +2 -2
  24. package/lib/DefinePlugin.js +111 -3
  25. package/lib/DelegatedModuleFactoryPlugin.js +18 -18
  26. package/lib/Dependency.js +11 -4
  27. package/lib/DependencyTemplate.js +1 -0
  28. package/lib/DllEntryPlugin.js +3 -1
  29. package/lib/DllPlugin.js +4 -3
  30. package/lib/DllReferencePlugin.js +2 -2
  31. package/lib/DynamicEntryPlugin.js +1 -1
  32. package/lib/EntryOptionPlugin.js +5 -0
  33. package/lib/ErrorHelpers.js +4 -4
  34. package/lib/EvalDevToolModulePlugin.js +3 -3
  35. package/lib/EvalSourceMapDevToolPlugin.js +7 -7
  36. package/lib/ExportsInfo.js +48 -39
  37. package/lib/ExternalModule.js +15 -11
  38. package/lib/ExternalModuleFactoryPlugin.js +5 -2
  39. package/lib/FileSystemInfo.js +51 -36
  40. package/lib/FlagDependencyExportsPlugin.js +14 -7
  41. package/lib/FlagDependencyUsagePlugin.js +1 -1
  42. package/lib/Generator.js +14 -1
  43. package/lib/HookWebpackError.js +1 -0
  44. package/lib/HotModuleReplacementPlugin.js +77 -50
  45. package/lib/IgnorePlugin.js +5 -2
  46. package/lib/InvalidDependenciesModuleWarning.js +1 -1
  47. package/lib/JavascriptMetaInfoPlugin.js +0 -1
  48. package/lib/LibManifestPlugin.js +4 -2
  49. package/lib/LoaderOptionsPlugin.js +6 -4
  50. package/lib/MainTemplate.js +2 -2
  51. package/lib/Module.js +21 -6
  52. package/lib/ModuleFactory.js +1 -0
  53. package/lib/ModuleGraph.js +24 -2
  54. package/lib/ModuleGraphConnection.js +5 -5
  55. package/lib/ModuleInfoHeaderPlugin.js +2 -1
  56. package/lib/ModuleParseError.js +1 -0
  57. package/lib/ModuleSourceTypesConstants.js +12 -12
  58. package/lib/ModuleTemplate.js +1 -1
  59. package/lib/ModuleTypeConstants.js +21 -21
  60. package/lib/MultiCompiler.js +6 -6
  61. package/lib/NormalModule.js +31 -44
  62. package/lib/NormalModuleFactory.js +34 -20
  63. package/lib/NormalModuleReplacementPlugin.js +1 -1
  64. package/lib/NullFactory.js +1 -0
  65. package/lib/OptimizationStages.js +1 -1
  66. package/lib/Parser.js +1 -0
  67. package/lib/ProgressPlugin.js +12 -5
  68. package/lib/ProvidePlugin.js +5 -1
  69. package/lib/RawModule.js +14 -0
  70. package/lib/RecordIdsPlugin.js +3 -3
  71. package/lib/RuntimeGlobals.js +175 -155
  72. package/lib/RuntimeModule.js +1 -0
  73. package/lib/RuntimePlugin.js +33 -7
  74. package/lib/RuntimeTemplate.js +111 -11
  75. package/lib/SourceMapDevToolModuleOptionsPlugin.js +15 -25
  76. package/lib/SourceMapDevToolPlugin.js +19 -17
  77. package/lib/Template.js +2 -2
  78. package/lib/TemplatedPathPlugin.js +1 -1
  79. package/lib/WarnDeprecatedOptionPlugin.js +7 -8
  80. package/lib/WatchIgnorePlugin.js +4 -3
  81. package/lib/WebpackIsIncludedPlugin.js +2 -1
  82. package/lib/WebpackOptionsApply.js +115 -27
  83. package/lib/asset/AssetGenerator.js +15 -11
  84. package/lib/asset/AssetModulesPlugin.js +19 -17
  85. package/lib/asset/AssetSourceGenerator.js +4 -4
  86. package/lib/asset/RawDataUrlModule.js +4 -2
  87. package/lib/async-modules/AwaitDependenciesInitFragment.js +1 -1
  88. package/lib/buildChunkGraph.js +6 -3
  89. package/lib/cache/AddBuildDependenciesPlugin.js +5 -6
  90. package/lib/cache/IdleFileCachePlugin.js +7 -4
  91. package/lib/cache/MemoryCachePlugin.js +1 -0
  92. package/lib/cache/MemoryWithGcCachePlugin.js +1 -0
  93. package/lib/cache/PackFileCacheStrategy.js +26 -20
  94. package/lib/cache/ResolverCachePlugin.js +16 -8
  95. package/lib/cli.js +15 -10
  96. package/lib/config/browserslistTargetHandler.js +3 -3
  97. package/lib/config/defaults.js +25 -17
  98. package/lib/config/normalization.js +2 -1
  99. package/lib/config/target.js +6 -5
  100. package/lib/container/ContainerPlugin.js +1 -1
  101. package/lib/container/ContainerReferencePlugin.js +1 -1
  102. package/lib/container/FallbackModule.js +2 -1
  103. package/lib/container/HoistContainerReferencesPlugin.js +1 -1
  104. package/lib/container/ModuleFederationPlugin.js +2 -2
  105. package/lib/container/RemoteModule.js +1 -1
  106. package/lib/css/CssGenerator.js +9 -6
  107. package/lib/css/CssModulesPlugin.js +44 -31
  108. package/lib/css/CssParser.js +6 -4
  109. package/lib/css/walkCssTokens.js +33 -37
  110. package/lib/debug/ProfilingPlugin.js +6 -6
  111. package/lib/dependencies/AMDDefineDependencyParserPlugin.js +8 -8
  112. package/lib/dependencies/AMDPlugin.js +12 -8
  113. package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +28 -26
  114. package/lib/dependencies/CachedConstDependency.js +1 -5
  115. package/lib/dependencies/CommonJsExportRequireDependency.js +6 -4
  116. package/lib/dependencies/CommonJsExportsParserPlugin.js +22 -25
  117. package/lib/dependencies/CommonJsFullRequireDependency.js +1 -9
  118. package/lib/dependencies/CommonJsImportsParserPlugin.js +100 -114
  119. package/lib/dependencies/CommonJsPlugin.js +15 -16
  120. package/lib/dependencies/ContextDependencyHelpers.js +2 -1
  121. package/lib/dependencies/ContextDependencyTemplateAsId.js +1 -0
  122. package/lib/dependencies/ContextDependencyTemplateAsRequireCall.js +1 -0
  123. package/lib/dependencies/CssIcssExportDependency.js +1 -1
  124. package/lib/dependencies/CssLocalIdentifierDependency.js +2 -2
  125. package/lib/dependencies/CssSelfLocalIdentifierDependency.js +2 -1
  126. package/lib/dependencies/DynamicExports.js +9 -9
  127. package/lib/dependencies/ExportsInfoDependency.js +1 -1
  128. package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +122 -101
  129. package/lib/dependencies/HarmonyExportExpressionDependency.js +1 -1
  130. package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +95 -19
  131. package/lib/dependencies/HarmonyExportInitFragment.js +1 -1
  132. package/lib/dependencies/HarmonyImportDependency.js +11 -5
  133. package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +238 -162
  134. package/lib/dependencies/HarmonyImportSideEffectDependency.js +4 -1
  135. package/lib/dependencies/HarmonyImportSpecifierDependency.js +20 -9
  136. package/lib/dependencies/HarmonyModulesPlugin.js +23 -12
  137. package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +1 -0
  138. package/lib/dependencies/ImportMetaContextPlugin.js +2 -1
  139. package/lib/dependencies/ImportMetaPlugin.js +2 -2
  140. package/lib/dependencies/ImportParserPlugin.js +40 -9
  141. package/lib/dependencies/ImportPlugin.js +3 -1
  142. package/lib/dependencies/LoaderPlugin.js +1 -0
  143. package/lib/dependencies/ModuleDependency.js +3 -1
  144. package/lib/dependencies/ModuleDependencyTemplateAsRequireId.js +1 -0
  145. package/lib/dependencies/RequireContextPlugin.js +3 -1
  146. package/lib/dependencies/RequireEnsurePlugin.js +6 -6
  147. package/lib/dependencies/RequireIncludeDependencyParserPlugin.js +33 -34
  148. package/lib/dependencies/RequireIncludePlugin.js +1 -0
  149. package/lib/dependencies/RuntimeRequirementsDependency.js +1 -1
  150. package/lib/dependencies/SystemPlugin.js +1 -1
  151. package/lib/dependencies/URLContextDependency.js +65 -0
  152. package/lib/dependencies/URLPlugin.js +17 -157
  153. package/lib/dependencies/WorkerPlugin.js +23 -10
  154. package/lib/dependencies/processExportInfo.js +2 -1
  155. package/lib/esm/ModuleChunkFormatPlugin.js +269 -185
  156. package/lib/esm/ModuleChunkLoadingPlugin.js +39 -1
  157. package/lib/esm/ModuleChunkLoadingRuntimeModule.js +70 -3
  158. package/lib/hmr/HotModuleReplacement.runtime.js +0 -1
  159. package/lib/hmr/HotModuleReplacementRuntimeModule.js +1 -1
  160. package/lib/hmr/JavascriptHotModuleReplacementHelper.js +37 -0
  161. package/lib/hmr/LazyCompilationPlugin.js +4 -2
  162. package/lib/hmr/lazyCompilationBackend.js +4 -2
  163. package/lib/ids/ChunkModuleIdRangePlugin.js +6 -3
  164. package/lib/ids/DeterministicChunkIdsPlugin.js +30 -35
  165. package/lib/ids/DeterministicModuleIdsPlugin.js +4 -3
  166. package/lib/ids/HashedModuleIdsPlugin.js +5 -4
  167. package/lib/ids/IdHelpers.js +21 -17
  168. package/lib/ids/NamedChunkIdsPlugin.js +5 -5
  169. package/lib/ids/NamedModuleIdsPlugin.js +4 -4
  170. package/lib/ids/NaturalChunkIdsPlugin.js +2 -1
  171. package/lib/ids/NaturalModuleIdsPlugin.js +1 -1
  172. package/lib/ids/OccurrenceChunkIdsPlugin.js +3 -2
  173. package/lib/ids/OccurrenceModuleIdsPlugin.js +1 -1
  174. package/lib/ids/SyncModuleIdsPlugin.js +1 -1
  175. package/lib/index.js +13 -3
  176. package/lib/javascript/ArrayPushCallbackChunkFormatPlugin.js +113 -119
  177. package/lib/javascript/BasicEvaluatedExpression.js +2 -1
  178. package/lib/javascript/ChunkHelpers.js +1 -0
  179. package/lib/javascript/CommonJsChunkFormatPlugin.js +121 -136
  180. package/lib/javascript/EnableChunkLoadingPlugin.js +6 -3
  181. package/lib/javascript/JavascriptGenerator.js +14 -2
  182. package/lib/javascript/JavascriptModulesPlugin.js +68 -27
  183. package/lib/javascript/JavascriptParser.js +117 -76
  184. package/lib/javascript/JavascriptParserHelpers.js +41 -41
  185. package/lib/javascript/StartupHelpers.js +17 -17
  186. package/lib/json/JsonGenerator.js +4 -2
  187. package/lib/json/JsonModulesPlugin.js +2 -2
  188. package/lib/json/JsonParser.js +1 -1
  189. package/lib/library/AbstractLibraryPlugin.js +6 -2
  190. package/lib/library/AssignLibraryPlugin.js +21 -6
  191. package/lib/library/EnableLibraryPlugin.js +23 -3
  192. package/lib/library/UmdLibraryPlugin.js +15 -6
  193. package/lib/logging/createConsoleLogger.js +3 -3
  194. package/lib/logging/runtime.js +9 -9
  195. package/lib/node/ReadFileChunkLoadingRuntimeModule.js +4 -22
  196. package/lib/node/RequireChunkLoadingRuntimeModule.js +4 -22
  197. package/lib/node/nodeConsole.js +4 -2
  198. package/lib/optimize/AggressiveMergingPlugin.js +45 -46
  199. package/lib/optimize/AggressiveSplittingPlugin.js +13 -12
  200. package/lib/optimize/ConcatenatedModule.js +227 -57
  201. package/lib/optimize/EnsureChunkConditionsPlugin.js +58 -58
  202. package/lib/optimize/FlagIncludedChunksPlugin.js +3 -1
  203. package/lib/optimize/InnerGraph.js +115 -112
  204. package/lib/optimize/InnerGraphPlugin.js +2 -2
  205. package/lib/optimize/LimitChunkCountPlugin.js +4 -2
  206. package/lib/optimize/MangleExportsPlugin.js +4 -3
  207. package/lib/optimize/MergeDuplicateChunksPlugin.js +80 -81
  208. package/lib/optimize/MinChunkSizePlugin.js +6 -3
  209. package/lib/optimize/ModuleConcatenationPlugin.js +31 -22
  210. package/lib/optimize/RealContentHashPlugin.js +26 -20
  211. package/lib/optimize/RemoveEmptyChunksPlugin.js +2 -1
  212. package/lib/optimize/RemoveParentModulesPlugin.js +1 -0
  213. package/lib/optimize/SideEffectsFlagPlugin.js +3 -2
  214. package/lib/optimize/SplitChunksPlugin.js +16 -13
  215. package/lib/rules/BasicEffectRulePlugin.js +4 -2
  216. package/lib/rules/BasicMatcherRulePlugin.js +3 -1
  217. package/lib/rules/ObjectMatcherRulePlugin.js +3 -1
  218. package/lib/rules/RuleSetCompiler.js +19 -5
  219. package/lib/rules/UseEffectRulePlugin.js +17 -9
  220. package/lib/runtime/AsyncModuleRuntimeModule.js +64 -9
  221. package/lib/runtime/CreateFakeNamespaceObjectRuntimeModule.js +1 -1
  222. package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +214 -0
  223. package/lib/runtime/RuntimeIdRuntimeModule.js +2 -1
  224. package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +8 -7
  225. package/lib/schemes/FileUriPlugin.js +1 -1
  226. package/lib/schemes/HttpUriPlugin.js +27 -19
  227. package/lib/schemes/VirtualUrlPlugin.js +222 -0
  228. package/lib/serialization/AggregateErrorSerializer.js +1 -1
  229. package/lib/serialization/BinaryMiddleware.js +5 -4
  230. package/lib/serialization/FileMiddleware.js +7 -4
  231. package/lib/serialization/ObjectMiddleware.js +14 -8
  232. package/lib/serialization/Serializer.js +5 -3
  233. package/lib/serialization/SerializerMiddleware.js +2 -0
  234. package/lib/sharing/ConsumeSharedModule.js +1 -1
  235. package/lib/sharing/ConsumeSharedPlugin.js +3 -3
  236. package/lib/sharing/ConsumeSharedRuntimeModule.js +2 -2
  237. package/lib/sharing/ProvideSharedModule.js +1 -1
  238. package/lib/sharing/ProvideSharedPlugin.js +3 -2
  239. package/lib/sharing/SharePlugin.js +2 -1
  240. package/lib/sharing/ShareRuntimeModule.js +3 -5
  241. package/lib/sharing/utils.js +34 -34
  242. package/lib/stats/DefaultStatsFactoryPlugin.js +49 -46
  243. package/lib/stats/DefaultStatsPresetPlugin.js +13 -13
  244. package/lib/stats/DefaultStatsPrinterPlugin.js +15 -9
  245. package/lib/stats/StatsFactory.js +6 -3
  246. package/lib/stats/StatsPrinter.js +6 -7
  247. package/lib/url/URLParserPlugin.js +266 -0
  248. package/lib/util/ArrayQueue.js +1 -1
  249. package/lib/util/AsyncQueue.js +1 -1
  250. package/lib/util/Hash.js +2 -0
  251. package/lib/util/IterableHelpers.js +1 -1
  252. package/lib/util/LazyBucketSortedSet.js +2 -1
  253. package/lib/util/LazySet.js +11 -6
  254. package/lib/util/ParallelismFactorCalculator.js +1 -1
  255. package/lib/util/SetHelpers.js +3 -3
  256. package/lib/util/SortableSet.js +2 -2
  257. package/lib/util/StackedCacheMap.js +3 -1
  258. package/lib/util/StackedMap.js +2 -2
  259. package/lib/util/StringXor.js +1 -0
  260. package/lib/util/TupleSet.js +1 -0
  261. package/lib/util/URLAbsoluteSpecifier.js +1 -1
  262. package/lib/util/cleverMerge.js +95 -58
  263. package/lib/util/comparators.js +154 -127
  264. package/lib/util/compileBooleanMatcher.js +8 -3
  265. package/lib/util/concatenate.js +8 -7
  266. package/lib/util/conventions.js +72 -73
  267. package/lib/util/create-schema-validation.js +2 -1
  268. package/lib/util/createHash.js +10 -4
  269. package/lib/util/deprecation.js +69 -66
  270. package/lib/util/deterministicGrouping.js +4 -2
  271. package/lib/util/extractUrlAndGlobal.js +1 -1
  272. package/lib/util/findGraphRoots.js +2 -2
  273. package/lib/util/fs.js +30 -23
  274. package/lib/util/hash/md4.js +2 -2
  275. package/lib/util/hash/wasm-hash.js +4 -2
  276. package/lib/util/identifier.js +13 -12
  277. package/lib/util/internalSerializables.js +2 -0
  278. package/lib/util/magicComment.js +5 -5
  279. package/lib/util/processAsyncTree.js +1 -1
  280. package/lib/util/propertyAccess.js +1 -1
  281. package/lib/util/propertyName.js +1 -1
  282. package/lib/util/registerExternalSerializer.js +1 -2
  283. package/lib/util/removeBOM.js +1 -1
  284. package/lib/util/runtime.js +29 -21
  285. package/lib/util/semver.js +1 -1
  286. package/lib/util/serialization.js +3 -0
  287. package/lib/util/source.js +3 -2
  288. package/lib/validateSchema.js +1 -0
  289. package/lib/wasm/EnableWasmLoadingPlugin.js +6 -3
  290. package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +4 -1
  291. package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +46 -49
  292. package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +2 -2
  293. package/lib/wasm-sync/WebAssemblyGenerator.js +2 -3
  294. package/lib/wasm-sync/WebAssemblyInInitialChunkError.js +3 -2
  295. package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +3 -0
  296. package/lib/wasm-sync/WebAssemblyUtils.js +1 -1
  297. package/lib/web/JsonpChunkLoadingRuntimeModule.js +4 -22
  298. package/lib/webpack.js +4 -5
  299. package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +1 -0
  300. package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +6 -24
  301. package/lib/webworker/WebWorkerTemplatePlugin.js +1 -0
  302. package/package.json +119 -113
  303. package/schemas/WebpackOptions.check.js +1 -1
  304. package/schemas/WebpackOptions.json +17 -0
  305. package/schemas/plugins/schemes/VirtualUrlPlugin.check.d.ts +7 -0
  306. package/schemas/plugins/schemes/VirtualUrlPlugin.check.js +6 -0
  307. package/schemas/plugins/schemes/VirtualUrlPlugin.json +77 -0
  308. package/types.d.ts +1243 -409
@@ -14,13 +14,13 @@ const AggressiveSplittingPlugin = require("../optimize/AggressiveSplittingPlugin
14
14
  const SizeLimitsPlugin = require("../performance/SizeLimitsPlugin");
15
15
  const { countIterable } = require("../util/IterableHelpers");
16
16
  const {
17
- compareLocations,
18
17
  compareChunksById,
19
- compareNumbers,
20
18
  compareIds,
21
- concatComparators,
19
+ compareLocations,
20
+ compareModulesByIdentifier,
21
+ compareNumbers,
22
22
  compareSelect,
23
- compareModulesByIdentifier
23
+ concatComparators
24
24
  } = require("../util/comparators");
25
25
  const { makePathsRelative, parseResource } = require("../util/identifier");
26
26
 
@@ -358,7 +358,7 @@ const uniqueArray = (items, selector) => {
358
358
  set.add(i);
359
359
  }
360
360
  }
361
- return Array.from(set);
361
+ return [...set];
362
362
  };
363
363
 
364
364
  /**
@@ -495,7 +495,7 @@ const EXTRACT_ERROR = {
495
495
  errorDetails: (
496
496
  object,
497
497
  error,
498
- { type, compilation, cachedGetErrors, cachedGetWarnings },
498
+ { type, compilation, cachedGetErrors },
499
499
  { errorDetails }
500
500
  ) => {
501
501
  if (
@@ -582,6 +582,7 @@ const SIMPLE_EXTRACTORS = {
582
582
  const { logging, loggingDebug, loggingTrace } = options;
583
583
  if (logging || (loggingDebug && loggingDebug.length > 0)) {
584
584
  const util = require("util");
585
+
585
586
  object.logging = {};
586
587
  let acceptedTypes;
587
588
  let collapsedGroups = false;
@@ -654,8 +655,9 @@ const SIMPLE_EXTRACTORS = {
654
655
  if (
655
656
  type === LogType.groupCollapsed &&
656
657
  (debugMode || collapsedGroups)
657
- )
658
+ ) {
658
659
  type = LogType.group;
660
+ }
659
661
 
660
662
  if (depthInCollapsedGroup === 0) {
661
663
  processedLogEntries++;
@@ -821,15 +823,11 @@ const SIMPLE_EXTRACTORS = {
821
823
  }
822
824
  }
823
825
 
824
- const groupedAssets = factory.create(
825
- `${type}.assets`,
826
- Array.from(assets),
827
- {
828
- ...context,
829
- compilationFileToChunks,
830
- compilationAuxiliaryFileToChunks
831
- }
832
- );
826
+ const groupedAssets = factory.create(`${type}.assets`, [...assets], {
827
+ ...context,
828
+ compilationFileToChunks,
829
+ compilationAuxiliaryFileToChunks
830
+ });
833
831
  const limited = spaceLimited(
834
832
  groupedAssets,
835
833
  /** @type {number} */ (options.assetsSpace)
@@ -841,13 +839,13 @@ const SIMPLE_EXTRACTORS = {
841
839
  const { type } = context;
842
840
  object.chunks = factory.create(
843
841
  `${type}.chunks`,
844
- Array.from(compilation.chunks),
842
+ [...compilation.chunks],
845
843
  context
846
844
  );
847
845
  },
848
846
  modules: (object, compilation, context, options, factory) => {
849
847
  const { type } = context;
850
- const array = Array.from(compilation.modules);
848
+ const array = [...compilation.modules];
851
849
  const groupedModules = factory.create(`${type}.modules`, array, context);
852
850
  const limited = spaceLimited(groupedModules, options.modulesSpace);
853
851
  object.modules = limited.children;
@@ -980,9 +978,10 @@ const SIMPLE_EXTRACTORS = {
980
978
  !warningsFilter &&
981
979
  /** @type {KnownNormalizedStatsOptions["warningsFilter"]} */
982
980
  (warningsFilter).length === 0
983
- )
981
+ ) {
984
982
  // Type is wrong, because we don't need the real value for counting
985
983
  return /** @type {EXPECTED_ANY[]} */ (cachedGetWarnings(c));
984
+ }
986
985
  return factory
987
986
  .create(`${type}${childType}.warnings`, cachedGetWarnings(c), context)
988
987
  .filter(
@@ -1038,7 +1037,7 @@ const SIMPLE_EXTRACTORS = {
1038
1037
  _: (
1039
1038
  object,
1040
1039
  asset,
1041
- { compilation, compilationFileToChunks, compilationAuxiliaryFileToChunks }
1040
+ { compilationFileToChunks, compilationAuxiliaryFileToChunks }
1042
1041
  ) => {
1043
1042
  const chunks = compilationFileToChunks.get(asset.name) || [];
1044
1043
  const auxiliaryChunks =
@@ -1050,7 +1049,7 @@ const SIMPLE_EXTRACTORS = {
1050
1049
  );
1051
1050
  object.chunkIdHints = uniqueOrderedArray(
1052
1051
  chunks,
1053
- c => Array.from(c.idNameHints),
1052
+ c => [...c.idNameHints],
1054
1053
  compareIds
1055
1054
  );
1056
1055
  object.auxiliaryChunkNames = uniqueOrderedArray(
@@ -1060,7 +1059,7 @@ const SIMPLE_EXTRACTORS = {
1060
1059
  );
1061
1060
  object.auxiliaryChunkIdHints = uniqueOrderedArray(
1062
1061
  auxiliaryChunks,
1063
- c => Array.from(c.idNameHints),
1062
+ c => [...c.idNameHints],
1064
1063
  compareIds
1065
1064
  );
1066
1065
  object.filteredRelated = asset.related ? asset.related.length : undefined;
@@ -1200,7 +1199,7 @@ const SIMPLE_EXTRACTORS = {
1200
1199
  }
1201
1200
  }
1202
1201
  }
1203
- return Array.from(set);
1202
+ return [...set];
1204
1203
  })
1205
1204
  : undefined
1206
1205
  };
@@ -1330,7 +1329,7 @@ const SIMPLE_EXTRACTORS = {
1330
1329
  } = context;
1331
1330
  const groupsReasons = factory.create(
1332
1331
  `${type.slice(0, -8)}.reasons`,
1333
- Array.from(moduleGraph.getIncomingConnections(module)),
1332
+ [...moduleGraph.getIncomingConnections(module)],
1334
1333
  context
1335
1334
  );
1336
1335
  const limited = spaceLimited(
@@ -1352,7 +1351,7 @@ const SIMPLE_EXTRACTORS = {
1352
1351
  } else if (typeof usedExports === "boolean") {
1353
1352
  object.usedExports = usedExports;
1354
1353
  } else {
1355
- object.usedExports = Array.from(usedExports);
1354
+ object.usedExports = [...usedExports];
1356
1355
  }
1357
1356
  },
1358
1357
  providedExports: (object, module, { compilation: { moduleGraph } }) => {
@@ -1506,15 +1505,15 @@ const SIMPLE_EXTRACTORS = {
1506
1505
  size: chunkGraph.getChunkModulesSize(chunk),
1507
1506
  sizes: chunkGraph.getChunkModulesSizes(chunk),
1508
1507
  names: chunk.name ? [chunk.name] : [],
1509
- idHints: Array.from(chunk.idNameHints),
1508
+ idHints: [...chunk.idNameHints],
1510
1509
  runtime:
1511
1510
  chunk.runtime === undefined
1512
1511
  ? undefined
1513
1512
  : typeof chunk.runtime === "string"
1514
1513
  ? [makePathsRelative(chunk.runtime)]
1515
1514
  : Array.from(chunk.runtime.sort(), makePathsRelative),
1516
- files: Array.from(chunk.files),
1517
- auxiliaryFiles: Array.from(chunk.auxiliaryFiles).sort(compareIds),
1515
+ files: [...chunk.files],
1516
+ auxiliaryFiles: [...chunk.auxiliaryFiles].sort(compareIds),
1518
1517
  hash: /** @type {string} */ (chunk.renderedHash),
1519
1518
  childrenByOrder: childIdByOrder
1520
1519
  };
@@ -1523,7 +1522,7 @@ const SIMPLE_EXTRACTORS = {
1523
1522
  ids: (object, chunk) => {
1524
1523
  object.id = /** @type {ChunkId} */ (chunk.id);
1525
1524
  },
1526
- chunkRelations: (object, chunk, { compilation: { chunkGraph } }) => {
1525
+ chunkRelations: (object, chunk, _context) => {
1527
1526
  /** @type {Set<string|number>} */
1528
1527
  const parents = new Set();
1529
1528
  /** @type {Set<string|number>} */
@@ -1543,13 +1542,14 @@ const SIMPLE_EXTRACTORS = {
1543
1542
  }
1544
1543
  }
1545
1544
  for (const sibling of chunkGroup.chunks) {
1546
- if (sibling !== chunk)
1545
+ if (sibling !== chunk) {
1547
1546
  siblings.add(/** @type {ChunkId} */ (sibling.id));
1547
+ }
1548
1548
  }
1549
1549
  }
1550
- object.siblings = Array.from(siblings).sort(compareIds);
1551
- object.parents = Array.from(parents).sort(compareIds);
1552
- object.children = Array.from(children).sort(compareIds);
1550
+ object.siblings = [...siblings].sort(compareIds);
1551
+ object.parents = [...parents].sort(compareIds);
1552
+ object.children = [...children].sort(compareIds);
1553
1553
  },
1554
1554
  chunkModules: (object, chunk, context, options, factory) => {
1555
1555
  const {
@@ -1624,15 +1624,13 @@ const SIMPLE_EXTRACTORS = {
1624
1624
  object.originName = origin.readableIdentifier(requestShortener);
1625
1625
  object.moduleIdentifier = module.identifier();
1626
1626
  object.moduleName = module.readableIdentifier(requestShortener);
1627
- const dependencies = Array.from(
1628
- moduleGraph.getIncomingConnections(module)
1629
- )
1627
+ const dependencies = [...moduleGraph.getIncomingConnections(module)]
1630
1628
  .filter(c => c.resolvedOriginModule === origin && c.dependency)
1631
1629
  .map(c => c.dependency);
1632
1630
  object.dependencies = factory.create(
1633
1631
  `${type}.dependencies`,
1634
1632
  /** @type {Dependency[]} */
1635
- (Array.from(new Set(dependencies))),
1633
+ ([...new Set(dependencies)]),
1636
1634
  context
1637
1635
  );
1638
1636
  },
@@ -1705,7 +1703,7 @@ const SORTERS = {
1705
1703
  "chunk.modules": MODULES_SORTER,
1706
1704
  "module.modules": MODULES_SORTER,
1707
1705
  "module.reasons": {
1708
- _: (comparators, { compilation: { chunkGraph } }) => {
1706
+ _: (comparators, _context) => {
1709
1707
  comparators.push(
1710
1708
  compareSelect(x => x.originModule, compareModulesByIdentifier)
1711
1709
  );
@@ -1868,7 +1866,7 @@ const spaceLimited = (
1868
1866
  if (groupsSize + items.length <= max) {
1869
1867
  // The total size in the current state fits into the max
1870
1868
  // keep all
1871
- children = groups.length > 0 ? groups.concat(items) : items;
1869
+ children = groups.length > 0 ? [...groups, ...items] : items;
1872
1870
  } else if (groups.length === 0) {
1873
1871
  // slice items to max
1874
1872
  // inner space marks that lines for filteredChildren already reserved
@@ -1931,7 +1929,7 @@ const spaceLimited = (
1931
1929
  }
1932
1930
  }
1933
1931
  }
1934
- children = groups.concat(items);
1932
+ children = [...groups, ...items];
1935
1933
  } else if (limit === max) {
1936
1934
  // If we have only enough space to show one line per group and one line for the filtered items
1937
1935
  // collapse all groups and items
@@ -1956,7 +1954,7 @@ const errorsSpaceLimit = (errors, max) => {
1956
1954
  let filtered = 0;
1957
1955
  // Can not fit into limit
1958
1956
  // print only messages
1959
- if (errors.length + 1 >= max)
1957
+ if (errors.length + 1 >= max) {
1960
1958
  return [
1961
1959
  errors.map(error => {
1962
1960
  if (typeof error === "string" || !error.details) return error;
@@ -1965,6 +1963,7 @@ const errorsSpaceLimit = (errors, max) => {
1965
1963
  }),
1966
1964
  filtered
1967
1965
  ];
1966
+ }
1968
1967
  let fullLength = errors.length;
1969
1968
  let result = errors;
1970
1969
 
@@ -2123,12 +2122,13 @@ const ASSETS_GROUPERS = {
2123
2122
  const keys = [];
2124
2123
  if (groupAssetsByPath) {
2125
2124
  keys.push(".");
2126
- if (extension)
2125
+ if (extension) {
2127
2126
  keys.push(
2128
2127
  path.length
2129
2128
  ? `${path.join("/")}/*${extension}`
2130
2129
  : `*${extension}`
2131
2130
  );
2131
+ }
2132
2132
  while (path.length > 0) {
2133
2133
  keys.push(`${path.join("/")}/`);
2134
2134
  path.pop();
@@ -2147,7 +2147,7 @@ const ASSETS_GROUPERS = {
2147
2147
  });
2148
2148
  }
2149
2149
  },
2150
- groupAssetsByInfo: (groupConfigs, context, options) => {
2150
+ groupAssetsByInfo: (groupConfigs, _context, _options) => {
2151
2151
  /**
2152
2152
  * @param {string} name name
2153
2153
  */
@@ -2168,7 +2168,7 @@ const ASSETS_GROUPERS = {
2168
2168
  groupByAssetInfoFlag("development");
2169
2169
  groupByAssetInfoFlag("hotModuleReplacement");
2170
2170
  },
2171
- groupAssetsByChunk: (groupConfigs, context, options) => {
2171
+ groupAssetsByChunk: (groupConfigs, _context, _options) => {
2172
2172
  /**
2173
2173
  * @param {keyof KnownStatsAsset} name name
2174
2174
  */
@@ -2319,12 +2319,13 @@ const MODULES_GROUPERS = type => ({
2319
2319
  const path = pathMatch ? pathMatch[1].split(/[/\\]/) : [];
2320
2320
  const keys = [];
2321
2321
  if (groupModulesByPath) {
2322
- if (extension)
2322
+ if (extension) {
2323
2323
  keys.push(
2324
2324
  path.length
2325
2325
  ? `${path.join("/")}/*${extension}`
2326
2326
  : `*${extension}`
2327
2327
  );
2328
+ }
2328
2329
  while (path.length > 0) {
2329
2330
  keys.push(`${path.join("/")}/`);
2330
2331
  path.pop();
@@ -2511,8 +2512,9 @@ const iterateConfig = (config, options, fn) => {
2511
2512
  value === false ||
2512
2513
  value === undefined ||
2513
2514
  (Array.isArray(value) && value.length === 0)
2514
- )
2515
+ ) {
2515
2516
  continue;
2517
+ }
2516
2518
  }
2517
2519
  }
2518
2520
  fn(hookFor, subConfig[option]);
@@ -2684,4 +2686,5 @@ class DefaultStatsFactoryPlugin {
2684
2686
  });
2685
2687
  }
2686
2688
  }
2689
+
2687
2690
  module.exports = DefaultStatsFactoryPlugin;
@@ -182,7 +182,7 @@ const AUTO_FOR_TO_STRING = ({ all }, { forToString }) => {
182
182
  /** @typedef {keyof NormalizedStatsOptions} DefaultsKeys */
183
183
  /** @typedef {{ [Key in DefaultsKeys]: (options: Partial<NormalizedStatsOptions>, context: CreateStatsOptionsContext, compilation: Compilation) => NormalizedStatsOptions[Key] | RequestShortener }} Defaults */
184
184
 
185
- /** @type {Partial<Defaults>} */
185
+ /** @type {Defaults} */
186
186
  const DEFAULTS = {
187
187
  context: (options, context, compilation) => compilation.compiler.context,
188
188
  requestShortener: (options, context, compilation) =>
@@ -307,9 +307,9 @@ const normalizeFilter = item => {
307
307
  };
308
308
 
309
309
  /** @typedef {keyof (KnownNormalizedStatsOptions | StatsOptions)} NormalizerKeys */
310
- /** @typedef {{ [Key in NormalizerKeys]: (value: StatsOptions[Key]) => KnownNormalizedStatsOptions[Key] }} Normalizers */
310
+ /** @typedef {{ [Key in NormalizerKeys]?: (value: StatsOptions[Key]) => KnownNormalizedStatsOptions[Key] }} Normalizers */
311
311
 
312
- /** @type {Partial<Normalizers>} */
312
+ /** @type {Normalizers} */
313
313
  const NORMALIZER = {
314
314
  excludeModules: value => {
315
315
  if (!Array.isArray(value)) {
@@ -384,28 +384,28 @@ class DefaultStatsPresetPlugin {
384
384
  const defaults = NAMED_PRESETS[/** @type {keyof NamedPresets} */ (key)];
385
385
  compilation.hooks.statsPreset
386
386
  .for(key)
387
- .tap(PLUGIN_NAME, (options, context) => {
387
+ .tap(PLUGIN_NAME, (options, _context) => {
388
388
  applyDefaults(options, defaults);
389
389
  });
390
390
  }
391
391
  compilation.hooks.statsNormalize.tap(PLUGIN_NAME, (options, context) => {
392
392
  for (const key of Object.keys(DEFAULTS)) {
393
- if (options[key] === undefined)
394
- options[key] =
395
- /** @type {Defaults[DefaultsKeys]} */
396
- (DEFAULTS[/** @type {DefaultsKeys} */ (key)])(
397
- options,
398
- context,
399
- compilation
400
- );
393
+ if (options[key] === undefined) {
394
+ options[key] = DEFAULTS[/** @type {DefaultsKeys} */ (key)](
395
+ options,
396
+ context,
397
+ compilation
398
+ );
399
+ }
401
400
  }
402
401
  for (const key of Object.keys(NORMALIZER)) {
403
402
  options[key] =
404
- /** @type {TODO} */
403
+ /** @type {NonNullable<Normalizers[keyof Normalizers]>} */
405
404
  (NORMALIZER[/** @type {NormalizerKeys} */ (key)])(options[key]);
406
405
  }
407
406
  });
408
407
  });
409
408
  }
410
409
  }
410
+
411
411
  module.exports = DefaultStatsPresetPlugin;
@@ -277,8 +277,9 @@ const COMPILATION_SIMPLE_PRINTERS = {
277
277
  (errorsCount === 0 && warningsCount === 0) ||
278
278
  timeMessage ||
279
279
  hashMessage
280
- )
280
+ ) {
281
281
  return `${builtAtMessage}${subjectMessage} ${statusMessage}${timeMessage}${hashMessage}`;
282
+ }
282
283
  },
283
284
  "compilation.filteredWarningDetailsCount": count =>
284
285
  count
@@ -493,7 +494,7 @@ const MODULE_SIMPLE_PRINTERS = {
493
494
  const [prefix, resource] = getModuleName(name);
494
495
  return `${prefix || ""}${bold(resource || "")}`;
495
496
  },
496
- "module.identifier": identifier => undefined,
497
+ "module.identifier": _identifier => undefined,
497
498
  "module.layer": (layer, { formatLayer }) =>
498
499
  layer ? formatLayer(layer) : undefined,
499
500
  "module.sizes": printSizes,
@@ -547,8 +548,9 @@ const MODULE_SIMPLE_PRINTERS = {
547
548
  if (usedExports === null) return cyan(formatFlag("used exports unknown"));
548
549
  if (usedExports === false) return cyan(formatFlag("module unused"));
549
550
  if (Array.isArray(usedExports)) {
550
- if (usedExports.length === 0)
551
+ if (usedExports.length === 0) {
551
552
  return cyan(formatFlag("no exports used"));
553
+ }
552
554
  const providedExportsCount = Array.isArray(module.providedExports)
553
555
  ? module.providedExports.length
554
556
  : null;
@@ -569,7 +571,7 @@ const MODULE_SIMPLE_PRINTERS = {
569
571
  yellow(optimizationBailout),
570
572
  "module.issuerPath": (issuerPath, { module }) =>
571
573
  module.profile ? undefined : "",
572
- "module.profile": profile => undefined,
574
+ "module.profile": _profile => undefined,
573
575
  "module.filteredModules": (filteredModules, { module: { modules } }) =>
574
576
  filteredModules > 0
575
577
  ? `${moreCount(modules, filteredModules)} nested ${plural(
@@ -829,7 +831,7 @@ const ERROR_PRINTERS = {
829
831
  " "
830
832
  )
831
833
  : undefined,
832
- "error.moduleTrace": moduleTrace => undefined,
834
+ "error.moduleTrace": _moduleTrace => undefined,
833
835
  "error.separator!": () => "\n"
834
836
  };
835
837
 
@@ -1407,15 +1409,17 @@ const SIMPLE_ELEMENT_JOINERS = {
1407
1409
  items.map(item => {
1408
1410
  switch (item.element) {
1409
1411
  case "moduleId":
1410
- if (moduleReason.moduleId === moduleReason.module && item.content)
1412
+ if (moduleReason.moduleId === moduleReason.module && item.content) {
1411
1413
  hasName = true;
1414
+ }
1412
1415
  break;
1413
1416
  case "module":
1414
1417
  if (hasName) return false;
1415
1418
  break;
1416
1419
  case "resolvedModule":
1417
- if (moduleReason.module === moduleReason.resolvedModule)
1420
+ if (moduleReason.module === moduleReason.resolvedModule) {
1418
1421
  return false;
1422
+ }
1419
1423
  break;
1420
1424
  case "children":
1421
1425
  if (item.content) {
@@ -1564,7 +1568,7 @@ const RESULT_MODIFIER = {
1564
1568
  * @returns {string[]} result
1565
1569
  */
1566
1570
  const createOrder = (array, preferredOrder) => {
1567
- const originalArray = array.slice();
1571
+ const originalArray = [...array];
1568
1572
  /** @type {Set<string>} */
1569
1573
  const set = new Set(array);
1570
1574
  /** @type {Set<string>} */
@@ -1621,6 +1625,7 @@ class DefaultStatsPrinterPlugin {
1621
1625
  `${start}${
1622
1626
  typeof str === "string"
1623
1627
  ? str.replace(
1628
+ // eslint-disable-next-line no-control-regex
1624
1629
  /((\u001B\[39m|\u001B\[22m|\u001B\[0m)+)/g,
1625
1630
  `$1${start}`
1626
1631
  )
@@ -1851,7 +1856,7 @@ class DefaultStatsPrinterPlugin {
1851
1856
  const preferredOrder = PREFERRED_ORDERS[key];
1852
1857
  stats.hooks.sortElements
1853
1858
  .for(key)
1854
- .tap(PLUGIN_NAME, (elements, context) => {
1859
+ .tap(PLUGIN_NAME, (elements, _context) => {
1855
1860
  createOrder(elements, preferredOrder);
1856
1861
  });
1857
1862
  }
@@ -1886,4 +1891,5 @@ class DefaultStatsPrinterPlugin {
1886
1891
  });
1887
1892
  }
1888
1893
  }
1894
+
1889
1895
  module.exports = DefaultStatsPrinterPlugin;
@@ -121,7 +121,8 @@ class StatsFactory {
121
121
  getItemFactory: new HookMap(() => new SyncBailHook(["item", "context"]))
122
122
  });
123
123
  const hooks = this.hooks;
124
- this._caches = /** @type {TODO} */ ({});
124
+ this._caches =
125
+ /** @type {{ [Key in keyof StatsFactoryHooks]: Map<string, SyncBailHook<EXPECTED_ANY, EXPECTED_ANY>[]> }} */ ({});
125
126
  for (const key of Object.keys(hooks)) {
126
127
  this._caches[/** @type {keyof StatsFactoryHooks} */ (key)] = new Map();
127
128
  }
@@ -205,7 +206,7 @@ class StatsFactory {
205
206
  */
206
207
  _forEachLevelFilter(hookMap, cache, type, items, fn, forceClone) {
207
208
  const hooks = this._getAllLevelHooks(hookMap, cache, type);
208
- if (hooks.length === 0) return forceClone ? items.slice() : items;
209
+ if (hooks.length === 0) return forceClone ? [...items] : items;
209
210
  let i = 0;
210
211
  return items.filter((item, idx) => {
211
212
  for (const hook of hooks) {
@@ -236,8 +237,9 @@ class StatsFactory {
236
237
  this._inCreate = true;
237
238
  return this._create(type, data, baseContext);
238
239
  } finally {
239
- for (const key of Object.keys(this._caches))
240
+ for (const key of Object.keys(this._caches)) {
240
241
  this._caches[/** @type {keyof StatsFactoryHooks} */ (key)].clear();
242
+ }
241
243
  this._inCreate = false;
242
244
  }
243
245
  }
@@ -397,4 +399,5 @@ class StatsFactory {
397
399
  );
398
400
  }
399
401
  }
402
+
400
403
  module.exports = StatsFactory;
@@ -5,7 +5,7 @@
5
5
 
6
6
  "use strict";
7
7
 
8
- const { HookMap, SyncWaterfallHook, SyncBailHook } = require("tapable");
8
+ const { HookMap, SyncBailHook, SyncWaterfallHook } = require("tapable");
9
9
 
10
10
  /** @typedef {import("./DefaultStatsFactoryPlugin").StatsAsset} StatsAsset */
11
11
  /** @typedef {import("./DefaultStatsFactoryPlugin").StatsChunk} StatsChunk */
@@ -102,9 +102,7 @@ class StatsPrinter {
102
102
  print: new HookMap(() => new SyncBailHook(["object", "context"])),
103
103
  result: new HookMap(() => new SyncWaterfallHook(["result", "context"]))
104
104
  });
105
- /**
106
- * @type {TODO}
107
- */
105
+ /** @type {Map<StatsPrintHooks[keyof StatsPrintHooks], Map<string, import("tapable").Hook<EXPECTED_ANY, EXPECTED_ANY>[]>>} */
108
106
  this._levelHookCache = new Map();
109
107
  this._inPrint = false;
110
108
  }
@@ -126,7 +124,7 @@ class StatsPrinter {
126
124
  }
127
125
  const cacheEntry = cache.get(type);
128
126
  if (cacheEntry !== undefined) {
129
- return cacheEntry;
127
+ return /** @type {H[]} */ (cacheEntry);
130
128
  }
131
129
  /** @type {H[]} */
132
130
  const hooks = [];
@@ -146,7 +144,7 @@ class StatsPrinter {
146
144
  * @private
147
145
  * @template {StatsPrintHooks[keyof StatsPrintHooks]} HM
148
146
  * @template {HM extends HookMap<infer H> ? H : never} H
149
- * @template {H extends import("tapable").Hook<any, infer R> ? R : never} R
147
+ * @template {H extends import("tapable").Hook<EXPECTED_ANY, infer R> ? R : never} R
150
148
  * @param {HM} hookMap hook map
151
149
  * @param {string} type type
152
150
  * @param {(hooK: H) => R | undefined | void} fn fn
@@ -217,7 +215,7 @@ class StatsPrinter {
217
215
  );
218
216
  if (printResult === undefined) {
219
217
  if (Array.isArray(object)) {
220
- const sortedItems = object.slice();
218
+ const sortedItems = [...object];
221
219
  this._forEachLevel(this.hooks.sortItems, type, h =>
222
220
  h.call(
223
221
  sortedItems,
@@ -298,4 +296,5 @@ class StatsPrinter {
298
296
  );
299
297
  }
300
298
  }
299
+
301
300
  module.exports = StatsPrinter;