@depup/webpack 5.105.4-depup.37

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 (709) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +38 -0
  3. package/bin/webpack.js +196 -0
  4. package/hot/dev-server.js +90 -0
  5. package/hot/emitter-event-target.js +7 -0
  6. package/hot/emitter.js +2 -0
  7. package/hot/lazy-compilation-node.js +66 -0
  8. package/hot/lazy-compilation-universal.js +18 -0
  9. package/hot/lazy-compilation-web.js +93 -0
  10. package/hot/load-http.js +7 -0
  11. package/hot/log-apply-result.js +49 -0
  12. package/hot/log.js +78 -0
  13. package/hot/only-dev-server.js +118 -0
  14. package/hot/poll.js +41 -0
  15. package/hot/signal.js +66 -0
  16. package/lib/APIPlugin.js +392 -0
  17. package/lib/AbstractMethodError.js +56 -0
  18. package/lib/AsyncDependenciesBlock.js +128 -0
  19. package/lib/AsyncDependencyToInitialChunkError.js +34 -0
  20. package/lib/AutomaticPrefetchPlugin.js +66 -0
  21. package/lib/BannerPlugin.js +138 -0
  22. package/lib/Cache.js +168 -0
  23. package/lib/CacheFacade.js +349 -0
  24. package/lib/CaseSensitiveModulesWarning.js +72 -0
  25. package/lib/Chunk.js +899 -0
  26. package/lib/ChunkGraph.js +1968 -0
  27. package/lib/ChunkGroup.js +615 -0
  28. package/lib/ChunkRenderError.js +38 -0
  29. package/lib/ChunkTemplate.js +181 -0
  30. package/lib/CleanPlugin.js +495 -0
  31. package/lib/CodeGenerationError.js +35 -0
  32. package/lib/CodeGenerationResults.js +167 -0
  33. package/lib/CommentCompilationWarning.js +33 -0
  34. package/lib/CompatibilityPlugin.js +240 -0
  35. package/lib/Compilation.js +5876 -0
  36. package/lib/Compiler.js +1413 -0
  37. package/lib/ConcatenationScope.js +181 -0
  38. package/lib/ConcurrentCompilationError.js +18 -0
  39. package/lib/ConditionalInitFragment.js +120 -0
  40. package/lib/ConstPlugin.js +567 -0
  41. package/lib/ContextExclusionPlugin.js +33 -0
  42. package/lib/ContextModule.js +1411 -0
  43. package/lib/ContextModuleFactory.js +514 -0
  44. package/lib/ContextReplacementPlugin.js +227 -0
  45. package/lib/CssModule.js +179 -0
  46. package/lib/DefinePlugin.js +878 -0
  47. package/lib/DelegatedModule.js +279 -0
  48. package/lib/DelegatedModuleFactoryPlugin.js +116 -0
  49. package/lib/DelegatedPlugin.js +49 -0
  50. package/lib/DependenciesBlock.js +120 -0
  51. package/lib/Dependency.js +390 -0
  52. package/lib/DependencyTemplate.js +71 -0
  53. package/lib/DependencyTemplates.js +67 -0
  54. package/lib/DllEntryPlugin.js +76 -0
  55. package/lib/DllModule.js +175 -0
  56. package/lib/DllModuleFactory.js +38 -0
  57. package/lib/DllPlugin.js +73 -0
  58. package/lib/DllReferencePlugin.js +189 -0
  59. package/lib/DotenvPlugin.js +468 -0
  60. package/lib/DynamicEntryPlugin.js +93 -0
  61. package/lib/EntryOptionPlugin.js +98 -0
  62. package/lib/EntryPlugin.js +72 -0
  63. package/lib/Entrypoint.js +120 -0
  64. package/lib/EnvironmentNotSupportAsyncWarning.js +51 -0
  65. package/lib/EnvironmentPlugin.js +74 -0
  66. package/lib/ErrorHelpers.js +100 -0
  67. package/lib/EvalDevToolModulePlugin.js +135 -0
  68. package/lib/EvalSourceMapDevToolPlugin.js +252 -0
  69. package/lib/ExportsInfo.js +1663 -0
  70. package/lib/ExportsInfoApiPlugin.js +87 -0
  71. package/lib/ExternalModule.js +1169 -0
  72. package/lib/ExternalModuleFactoryPlugin.js +370 -0
  73. package/lib/ExternalsPlugin.js +93 -0
  74. package/lib/FalseIIFEUmdWarning.js +20 -0
  75. package/lib/FileSystemInfo.js +4131 -0
  76. package/lib/FlagAllModulesAsUsedPlugin.js +55 -0
  77. package/lib/FlagDependencyExportsPlugin.js +437 -0
  78. package/lib/FlagDependencyUsagePlugin.js +348 -0
  79. package/lib/FlagEntryExportAsUsedPlugin.js +56 -0
  80. package/lib/Generator.js +188 -0
  81. package/lib/GraphHelpers.js +46 -0
  82. package/lib/HarmonyLinkingError.js +17 -0
  83. package/lib/HookWebpackError.js +121 -0
  84. package/lib/HotModuleReplacementPlugin.js +930 -0
  85. package/lib/HotUpdateChunk.js +16 -0
  86. package/lib/IgnoreErrorModuleFactory.js +39 -0
  87. package/lib/IgnorePlugin.js +105 -0
  88. package/lib/IgnoreWarningsPlugin.js +41 -0
  89. package/lib/InitFragment.js +204 -0
  90. package/lib/InvalidDependenciesModuleWarning.js +44 -0
  91. package/lib/JavascriptMetaInfoPlugin.js +78 -0
  92. package/lib/LibManifestPlugin.js +144 -0
  93. package/lib/LibraryTemplatePlugin.js +48 -0
  94. package/lib/LoaderOptionsPlugin.js +81 -0
  95. package/lib/LoaderTargetPlugin.js +39 -0
  96. package/lib/MainTemplate.js +371 -0
  97. package/lib/ManifestPlugin.js +242 -0
  98. package/lib/Module.js +1319 -0
  99. package/lib/ModuleBuildError.js +83 -0
  100. package/lib/ModuleDependencyError.js +44 -0
  101. package/lib/ModuleDependencyWarning.js +49 -0
  102. package/lib/ModuleError.js +69 -0
  103. package/lib/ModuleFactory.js +57 -0
  104. package/lib/ModuleFilenameHelpers.js +388 -0
  105. package/lib/ModuleGraph.js +1024 -0
  106. package/lib/ModuleGraphConnection.js +199 -0
  107. package/lib/ModuleHashingError.js +31 -0
  108. package/lib/ModuleInfoHeaderPlugin.js +318 -0
  109. package/lib/ModuleNotFoundError.js +90 -0
  110. package/lib/ModuleParseError.js +125 -0
  111. package/lib/ModuleProfile.js +108 -0
  112. package/lib/ModuleRestoreError.js +46 -0
  113. package/lib/ModuleSourceTypeConstants.js +179 -0
  114. package/lib/ModuleStoreError.js +45 -0
  115. package/lib/ModuleTemplate.js +173 -0
  116. package/lib/ModuleTypeConstants.js +190 -0
  117. package/lib/ModuleWarning.js +68 -0
  118. package/lib/MultiCompiler.js +678 -0
  119. package/lib/MultiStats.js +213 -0
  120. package/lib/MultiWatching.js +77 -0
  121. package/lib/NoEmitOnErrorsPlugin.js +30 -0
  122. package/lib/NoModeWarning.js +23 -0
  123. package/lib/NodeStuffInWebError.js +35 -0
  124. package/lib/NodeStuffPlugin.js +587 -0
  125. package/lib/NormalModule.js +1798 -0
  126. package/lib/NormalModuleFactory.js +1455 -0
  127. package/lib/NormalModuleReplacementPlugin.js +75 -0
  128. package/lib/NullFactory.js +24 -0
  129. package/lib/OptimizationStages.js +10 -0
  130. package/lib/OptionsApply.js +24 -0
  131. package/lib/Parser.js +40 -0
  132. package/lib/PlatformPlugin.js +41 -0
  133. package/lib/PrefetchPlugin.js +56 -0
  134. package/lib/ProgressPlugin.js +712 -0
  135. package/lib/ProvidePlugin.js +121 -0
  136. package/lib/RawModule.js +180 -0
  137. package/lib/RecordIdsPlugin.js +216 -0
  138. package/lib/RequestShortener.js +36 -0
  139. package/lib/RequireJsStuffPlugin.js +84 -0
  140. package/lib/ResolverFactory.js +156 -0
  141. package/lib/RuntimeGlobals.js +450 -0
  142. package/lib/RuntimeModule.js +242 -0
  143. package/lib/RuntimePlugin.js +547 -0
  144. package/lib/RuntimeTemplate.js +1288 -0
  145. package/lib/SelfModuleFactory.js +33 -0
  146. package/lib/SingleEntryPlugin.js +8 -0
  147. package/lib/SizeFormatHelpers.js +25 -0
  148. package/lib/SourceMapDevToolModuleOptionsPlugin.js +52 -0
  149. package/lib/SourceMapDevToolPlugin.js +646 -0
  150. package/lib/Stats.js +89 -0
  151. package/lib/Template.js +427 -0
  152. package/lib/TemplatedPathPlugin.js +400 -0
  153. package/lib/UnhandledSchemeError.js +34 -0
  154. package/lib/UnsupportedFeatureWarning.js +35 -0
  155. package/lib/UseStrictPlugin.js +81 -0
  156. package/lib/WarnCaseSensitiveModulesPlugin.js +64 -0
  157. package/lib/WarnDeprecatedOptionPlugin.js +60 -0
  158. package/lib/WarnNoModeSetPlugin.js +27 -0
  159. package/lib/WatchIgnorePlugin.js +155 -0
  160. package/lib/Watching.js +531 -0
  161. package/lib/WebpackError.js +81 -0
  162. package/lib/WebpackIsIncludedPlugin.js +93 -0
  163. package/lib/WebpackOptionsApply.js +941 -0
  164. package/lib/WebpackOptionsDefaulter.js +26 -0
  165. package/lib/asset/AssetBytesGenerator.js +172 -0
  166. package/lib/asset/AssetBytesParser.js +37 -0
  167. package/lib/asset/AssetGenerator.js +816 -0
  168. package/lib/asset/AssetModulesPlugin.js +358 -0
  169. package/lib/asset/AssetParser.js +73 -0
  170. package/lib/asset/AssetSourceGenerator.js +171 -0
  171. package/lib/asset/AssetSourceParser.js +37 -0
  172. package/lib/asset/RawDataUrlModule.js +179 -0
  173. package/lib/async-modules/AsyncModuleHelpers.js +52 -0
  174. package/lib/async-modules/AwaitDependenciesInitFragment.js +90 -0
  175. package/lib/async-modules/InferAsyncModulesPlugin.js +54 -0
  176. package/lib/buildChunkGraph.js +1392 -0
  177. package/lib/cache/AddBuildDependenciesPlugin.js +32 -0
  178. package/lib/cache/AddManagedPathsPlugin.js +40 -0
  179. package/lib/cache/IdleFileCachePlugin.js +242 -0
  180. package/lib/cache/MemoryCachePlugin.js +57 -0
  181. package/lib/cache/MemoryWithGcCachePlugin.js +142 -0
  182. package/lib/cache/PackFileCacheStrategy.js +1600 -0
  183. package/lib/cache/ResolverCachePlugin.js +450 -0
  184. package/lib/cache/getLazyHashedEtag.js +91 -0
  185. package/lib/cache/mergeEtags.js +71 -0
  186. package/lib/cli.js +859 -0
  187. package/lib/config/browserslistTargetHandler.js +388 -0
  188. package/lib/config/defaults.js +2086 -0
  189. package/lib/config/normalization.js +681 -0
  190. package/lib/config/target.js +389 -0
  191. package/lib/container/ContainerEntryDependency.js +50 -0
  192. package/lib/container/ContainerEntryModule.js +303 -0
  193. package/lib/container/ContainerEntryModuleFactory.js +27 -0
  194. package/lib/container/ContainerExposedDependency.js +62 -0
  195. package/lib/container/ContainerPlugin.js +118 -0
  196. package/lib/container/ContainerReferencePlugin.js +139 -0
  197. package/lib/container/FallbackDependency.js +66 -0
  198. package/lib/container/FallbackItemDependency.js +34 -0
  199. package/lib/container/FallbackModule.js +193 -0
  200. package/lib/container/FallbackModuleFactory.js +27 -0
  201. package/lib/container/HoistContainerReferencesPlugin.js +256 -0
  202. package/lib/container/ModuleFederationPlugin.js +131 -0
  203. package/lib/container/RemoteModule.js +225 -0
  204. package/lib/container/RemoteRuntimeModule.js +144 -0
  205. package/lib/container/RemoteToExternalDependency.js +33 -0
  206. package/lib/container/options.js +105 -0
  207. package/lib/css/CssGenerator.js +587 -0
  208. package/lib/css/CssLoadingRuntimeModule.js +513 -0
  209. package/lib/css/CssMergeStyleSheetsRuntimeModule.js +56 -0
  210. package/lib/css/CssModulesPlugin.js +939 -0
  211. package/lib/css/CssParser.js +2621 -0
  212. package/lib/css/walkCssTokens.js +1740 -0
  213. package/lib/debug/ProfilingPlugin.js +589 -0
  214. package/lib/dependencies/AMDDefineDependency.js +267 -0
  215. package/lib/dependencies/AMDDefineDependencyParserPlugin.js +504 -0
  216. package/lib/dependencies/AMDPlugin.js +243 -0
  217. package/lib/dependencies/AMDRequireArrayDependency.js +124 -0
  218. package/lib/dependencies/AMDRequireContextDependency.js +69 -0
  219. package/lib/dependencies/AMDRequireDependenciesBlock.js +28 -0
  220. package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +425 -0
  221. package/lib/dependencies/AMDRequireDependency.js +189 -0
  222. package/lib/dependencies/AMDRequireItemDependency.js +41 -0
  223. package/lib/dependencies/AMDRuntimeModules.js +50 -0
  224. package/lib/dependencies/CachedConstDependency.js +135 -0
  225. package/lib/dependencies/CommonJsDependencyHelpers.js +65 -0
  226. package/lib/dependencies/CommonJsExportRequireDependency.js +416 -0
  227. package/lib/dependencies/CommonJsExportsDependency.js +184 -0
  228. package/lib/dependencies/CommonJsExportsParserPlugin.js +425 -0
  229. package/lib/dependencies/CommonJsFullRequireDependency.js +162 -0
  230. package/lib/dependencies/CommonJsImportsParserPlugin.js +611 -0
  231. package/lib/dependencies/CommonJsPlugin.js +316 -0
  232. package/lib/dependencies/CommonJsRequireContextDependency.js +73 -0
  233. package/lib/dependencies/CommonJsRequireDependency.js +42 -0
  234. package/lib/dependencies/CommonJsSelfReferenceDependency.js +156 -0
  235. package/lib/dependencies/ConstDependency.js +118 -0
  236. package/lib/dependencies/ContextDependency.js +183 -0
  237. package/lib/dependencies/ContextDependencyHelpers.js +277 -0
  238. package/lib/dependencies/ContextDependencyTemplateAsId.js +63 -0
  239. package/lib/dependencies/ContextDependencyTemplateAsRequireCall.js +62 -0
  240. package/lib/dependencies/ContextElementDependency.js +147 -0
  241. package/lib/dependencies/CreateRequireParserPlugin.js +356 -0
  242. package/lib/dependencies/CreateScriptUrlDependency.js +75 -0
  243. package/lib/dependencies/CriticalDependencyWarning.js +29 -0
  244. package/lib/dependencies/CssIcssExportDependency.js +539 -0
  245. package/lib/dependencies/CssIcssImportDependency.js +183 -0
  246. package/lib/dependencies/CssIcssSymbolDependency.js +131 -0
  247. package/lib/dependencies/CssImportDependency.js +120 -0
  248. package/lib/dependencies/CssUrlDependency.js +189 -0
  249. package/lib/dependencies/DelegatedSourceDependency.js +33 -0
  250. package/lib/dependencies/DllEntryDependency.js +61 -0
  251. package/lib/dependencies/DynamicExports.js +73 -0
  252. package/lib/dependencies/EntryDependency.js +30 -0
  253. package/lib/dependencies/ExportsInfoDependency.js +161 -0
  254. package/lib/dependencies/ExternalModuleDependency.js +109 -0
  255. package/lib/dependencies/ExternalModuleInitFragment.js +137 -0
  256. package/lib/dependencies/ExternalModuleInitFragmentDependency.js +87 -0
  257. package/lib/dependencies/HarmonyAcceptDependency.js +237 -0
  258. package/lib/dependencies/HarmonyAcceptImportDependency.js +37 -0
  259. package/lib/dependencies/HarmonyCompatibilityDependency.js +91 -0
  260. package/lib/dependencies/HarmonyDetectionParserPlugin.js +103 -0
  261. package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +165 -0
  262. package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +254 -0
  263. package/lib/dependencies/HarmonyExportExpressionDependency.js +211 -0
  264. package/lib/dependencies/HarmonyExportHeaderDependency.js +78 -0
  265. package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +1494 -0
  266. package/lib/dependencies/HarmonyExportInitFragment.js +191 -0
  267. package/lib/dependencies/HarmonyExportSpecifierDependency.js +127 -0
  268. package/lib/dependencies/HarmonyExports.js +46 -0
  269. package/lib/dependencies/HarmonyImportDependency.js +459 -0
  270. package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +576 -0
  271. package/lib/dependencies/HarmonyImportSideEffectDependency.js +91 -0
  272. package/lib/dependencies/HarmonyImportSpecifierDependency.js +514 -0
  273. package/lib/dependencies/HarmonyModulesPlugin.js +158 -0
  274. package/lib/dependencies/HarmonyTopLevelThisParserPlugin.js +39 -0
  275. package/lib/dependencies/ImportContextDependency.js +81 -0
  276. package/lib/dependencies/ImportDependency.js +158 -0
  277. package/lib/dependencies/ImportEagerDependency.js +76 -0
  278. package/lib/dependencies/ImportMetaContextDependency.js +42 -0
  279. package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +312 -0
  280. package/lib/dependencies/ImportMetaContextPlugin.js +72 -0
  281. package/lib/dependencies/ImportMetaHotAcceptDependency.js +41 -0
  282. package/lib/dependencies/ImportMetaHotDeclineDependency.js +42 -0
  283. package/lib/dependencies/ImportMetaPlugin.js +447 -0
  284. package/lib/dependencies/ImportParserPlugin.js +602 -0
  285. package/lib/dependencies/ImportPhase.js +125 -0
  286. package/lib/dependencies/ImportPlugin.js +98 -0
  287. package/lib/dependencies/ImportWeakDependency.js +74 -0
  288. package/lib/dependencies/JsonExportsDependency.js +137 -0
  289. package/lib/dependencies/LoaderDependency.js +38 -0
  290. package/lib/dependencies/LoaderImportDependency.js +39 -0
  291. package/lib/dependencies/LoaderPlugin.js +294 -0
  292. package/lib/dependencies/LocalModule.js +60 -0
  293. package/lib/dependencies/LocalModuleDependency.js +84 -0
  294. package/lib/dependencies/LocalModulesHelpers.js +68 -0
  295. package/lib/dependencies/ModuleDecoratorDependency.js +136 -0
  296. package/lib/dependencies/ModuleDependency.js +100 -0
  297. package/lib/dependencies/ModuleDependencyTemplateAsId.js +35 -0
  298. package/lib/dependencies/ModuleDependencyTemplateAsRequireId.js +39 -0
  299. package/lib/dependencies/ModuleHotAcceptDependency.js +41 -0
  300. package/lib/dependencies/ModuleHotDeclineDependency.js +42 -0
  301. package/lib/dependencies/ModuleInitFragmentDependency.js +87 -0
  302. package/lib/dependencies/NullDependency.js +42 -0
  303. package/lib/dependencies/PrefetchDependency.js +27 -0
  304. package/lib/dependencies/ProvidedDependency.js +156 -0
  305. package/lib/dependencies/PureExpressionDependency.js +161 -0
  306. package/lib/dependencies/RequireContextDependency.js +38 -0
  307. package/lib/dependencies/RequireContextDependencyParserPlugin.js +69 -0
  308. package/lib/dependencies/RequireContextPlugin.js +167 -0
  309. package/lib/dependencies/RequireEnsureDependenciesBlock.js +29 -0
  310. package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +145 -0
  311. package/lib/dependencies/RequireEnsureDependency.js +115 -0
  312. package/lib/dependencies/RequireEnsureItemDependency.js +36 -0
  313. package/lib/dependencies/RequireEnsurePlugin.js +86 -0
  314. package/lib/dependencies/RequireHeaderDependency.js +70 -0
  315. package/lib/dependencies/RequireIncludeDependency.js +79 -0
  316. package/lib/dependencies/RequireIncludeDependencyParserPlugin.js +100 -0
  317. package/lib/dependencies/RequireIncludePlugin.js +63 -0
  318. package/lib/dependencies/RequireResolveContextDependency.js +67 -0
  319. package/lib/dependencies/RequireResolveDependency.js +58 -0
  320. package/lib/dependencies/RequireResolveHeaderDependency.js +81 -0
  321. package/lib/dependencies/RuntimeRequirementsDependency.js +85 -0
  322. package/lib/dependencies/StaticExportsDependency.js +72 -0
  323. package/lib/dependencies/SystemPlugin.js +168 -0
  324. package/lib/dependencies/SystemRuntimeModule.js +35 -0
  325. package/lib/dependencies/URLContextDependency.js +65 -0
  326. package/lib/dependencies/URLDependency.js +165 -0
  327. package/lib/dependencies/URLPlugin.js +67 -0
  328. package/lib/dependencies/UnsupportedDependency.js +82 -0
  329. package/lib/dependencies/WebAssemblyExportImportedDependency.js +93 -0
  330. package/lib/dependencies/WebAssemblyImportDependency.js +108 -0
  331. package/lib/dependencies/WebpackIsIncludedDependency.js +84 -0
  332. package/lib/dependencies/WorkerDependency.js +141 -0
  333. package/lib/dependencies/WorkerPlugin.js +565 -0
  334. package/lib/dependencies/getFunctionExpression.js +66 -0
  335. package/lib/dependencies/processExportInfo.js +67 -0
  336. package/lib/electron/ElectronTargetPlugin.js +71 -0
  337. package/lib/errors/BuildCycleError.js +30 -0
  338. package/lib/esm/ExportWebpackRequireRuntimeModule.js +30 -0
  339. package/lib/esm/ModuleChunkFormatPlugin.js +273 -0
  340. package/lib/esm/ModuleChunkLoadingPlugin.js +143 -0
  341. package/lib/esm/ModuleChunkLoadingRuntimeModule.js +426 -0
  342. package/lib/formatLocation.js +67 -0
  343. package/lib/hmr/HotModuleReplacement.runtime.js +419 -0
  344. package/lib/hmr/HotModuleReplacementRuntimeModule.js +42 -0
  345. package/lib/hmr/JavascriptHotModuleReplacement.runtime.js +471 -0
  346. package/lib/hmr/JavascriptHotModuleReplacementHelper.js +37 -0
  347. package/lib/hmr/LazyCompilationPlugin.js +473 -0
  348. package/lib/hmr/lazyCompilationBackend.js +167 -0
  349. package/lib/ids/ChunkModuleIdRangePlugin.js +94 -0
  350. package/lib/ids/DeterministicChunkIdsPlugin.js +73 -0
  351. package/lib/ids/DeterministicModuleIdsPlugin.js +98 -0
  352. package/lib/ids/HashedModuleIdsPlugin.js +85 -0
  353. package/lib/ids/IdHelpers.js +492 -0
  354. package/lib/ids/NamedChunkIdsPlugin.js +92 -0
  355. package/lib/ids/NamedModuleIdsPlugin.js +68 -0
  356. package/lib/ids/NaturalChunkIdsPlugin.js +35 -0
  357. package/lib/ids/NaturalModuleIdsPlugin.js +40 -0
  358. package/lib/ids/OccurrenceChunkIdsPlugin.js +86 -0
  359. package/lib/ids/OccurrenceModuleIdsPlugin.js +168 -0
  360. package/lib/ids/SyncModuleIdsPlugin.js +161 -0
  361. package/lib/index.js +681 -0
  362. package/lib/javascript/ArrayPushCallbackChunkFormatPlugin.js +153 -0
  363. package/lib/javascript/BasicEvaluatedExpression.js +603 -0
  364. package/lib/javascript/ChunkFormatHelpers.js +70 -0
  365. package/lib/javascript/ChunkHelpers.js +45 -0
  366. package/lib/javascript/CommonJsChunkFormatPlugin.js +148 -0
  367. package/lib/javascript/EnableChunkLoadingPlugin.js +127 -0
  368. package/lib/javascript/JavascriptGenerator.js +277 -0
  369. package/lib/javascript/JavascriptModulesPlugin.js +1905 -0
  370. package/lib/javascript/JavascriptParser.js +5476 -0
  371. package/lib/javascript/JavascriptParserHelpers.js +129 -0
  372. package/lib/javascript/StartupHelpers.js +178 -0
  373. package/lib/json/JsonData.js +74 -0
  374. package/lib/json/JsonGenerator.js +234 -0
  375. package/lib/json/JsonModulesPlugin.js +66 -0
  376. package/lib/json/JsonParser.js +93 -0
  377. package/lib/library/AbstractLibraryPlugin.js +339 -0
  378. package/lib/library/AmdLibraryPlugin.js +181 -0
  379. package/lib/library/AssignLibraryPlugin.js +445 -0
  380. package/lib/library/EnableLibraryPlugin.js +306 -0
  381. package/lib/library/ExportPropertyLibraryPlugin.js +116 -0
  382. package/lib/library/JsonpLibraryPlugin.js +92 -0
  383. package/lib/library/ModuleLibraryPlugin.js +438 -0
  384. package/lib/library/SystemLibraryPlugin.js +256 -0
  385. package/lib/library/UmdLibraryPlugin.js +355 -0
  386. package/lib/logging/Logger.js +223 -0
  387. package/lib/logging/createConsoleLogger.js +217 -0
  388. package/lib/logging/runtime.js +45 -0
  389. package/lib/logging/truncateArgs.js +83 -0
  390. package/lib/node/CommonJsChunkLoadingPlugin.js +120 -0
  391. package/lib/node/NodeEnvironmentPlugin.js +73 -0
  392. package/lib/node/NodeSourcePlugin.js +19 -0
  393. package/lib/node/NodeTargetPlugin.js +102 -0
  394. package/lib/node/NodeTemplatePlugin.js +42 -0
  395. package/lib/node/NodeWatchFileSystem.js +198 -0
  396. package/lib/node/ReadFileChunkLoadingRuntimeModule.js +286 -0
  397. package/lib/node/ReadFileCompileAsyncWasmPlugin.js +123 -0
  398. package/lib/node/ReadFileCompileWasmPlugin.js +127 -0
  399. package/lib/node/RequireChunkLoadingRuntimeModule.js +239 -0
  400. package/lib/node/nodeConsole.js +185 -0
  401. package/lib/optimize/AggressiveMergingPlugin.js +98 -0
  402. package/lib/optimize/AggressiveSplittingPlugin.js +352 -0
  403. package/lib/optimize/ConcatenatedModule.js +2290 -0
  404. package/lib/optimize/EnsureChunkConditionsPlugin.js +88 -0
  405. package/lib/optimize/FlagIncludedChunksPlugin.js +137 -0
  406. package/lib/optimize/InnerGraph.js +368 -0
  407. package/lib/optimize/InnerGraphPlugin.js +455 -0
  408. package/lib/optimize/LimitChunkCountPlugin.js +302 -0
  409. package/lib/optimize/MangleExportsPlugin.js +194 -0
  410. package/lib/optimize/MergeDuplicateChunksPlugin.js +138 -0
  411. package/lib/optimize/MinChunkSizePlugin.js +121 -0
  412. package/lib/optimize/MinMaxSizeWarning.js +35 -0
  413. package/lib/optimize/ModuleConcatenationPlugin.js +971 -0
  414. package/lib/optimize/RealContentHashPlugin.js +488 -0
  415. package/lib/optimize/RemoveEmptyChunksPlugin.js +60 -0
  416. package/lib/optimize/RemoveParentModulesPlugin.js +216 -0
  417. package/lib/optimize/RuntimeChunkPlugin.js +52 -0
  418. package/lib/optimize/SideEffectsFlagPlugin.js +417 -0
  419. package/lib/optimize/SplitChunksPlugin.js +1836 -0
  420. package/lib/performance/AssetsOverSizeLimitWarning.js +37 -0
  421. package/lib/performance/EntrypointsOverSizeLimitWarning.js +40 -0
  422. package/lib/performance/NoAsyncChunksWarning.js +21 -0
  423. package/lib/performance/SizeLimitsPlugin.js +183 -0
  424. package/lib/prefetch/ChunkPrefetchFunctionRuntimeModule.js +46 -0
  425. package/lib/prefetch/ChunkPrefetchPreloadPlugin.js +95 -0
  426. package/lib/prefetch/ChunkPrefetchStartupRuntimeModule.js +56 -0
  427. package/lib/prefetch/ChunkPrefetchTriggerRuntimeModule.js +52 -0
  428. package/lib/prefetch/ChunkPreloadTriggerRuntimeModule.js +46 -0
  429. package/lib/rules/BasicEffectRulePlugin.js +56 -0
  430. package/lib/rules/BasicMatcherRulePlugin.js +68 -0
  431. package/lib/rules/ObjectMatcherRulePlugin.js +79 -0
  432. package/lib/rules/RuleSetCompiler.js +447 -0
  433. package/lib/rules/UseEffectRulePlugin.js +236 -0
  434. package/lib/runtime/AsyncModuleRuntimeModule.js +199 -0
  435. package/lib/runtime/AutoPublicPathRuntimeModule.js +90 -0
  436. package/lib/runtime/BaseUriRuntimeModule.js +35 -0
  437. package/lib/runtime/ChunkNameRuntimeModule.js +28 -0
  438. package/lib/runtime/CompatGetDefaultExportRuntimeModule.js +40 -0
  439. package/lib/runtime/CompatRuntimeModule.js +83 -0
  440. package/lib/runtime/CreateFakeNamespaceObjectRuntimeModule.js +69 -0
  441. package/lib/runtime/CreateScriptRuntimeModule.js +38 -0
  442. package/lib/runtime/CreateScriptUrlRuntimeModule.js +38 -0
  443. package/lib/runtime/DefinePropertyGettersRuntimeModule.js +42 -0
  444. package/lib/runtime/EnsureChunkRuntimeModule.js +69 -0
  445. package/lib/runtime/GetChunkFilenameRuntimeModule.js +299 -0
  446. package/lib/runtime/GetFullHashRuntimeModule.js +31 -0
  447. package/lib/runtime/GetMainFilenameRuntimeModule.js +49 -0
  448. package/lib/runtime/GetTrustedTypesPolicyRuntimeModule.js +99 -0
  449. package/lib/runtime/GlobalRuntimeModule.js +47 -0
  450. package/lib/runtime/HasOwnPropertyRuntimeModule.js +35 -0
  451. package/lib/runtime/HelperRuntimeModule.js +18 -0
  452. package/lib/runtime/LoadScriptRuntimeModule.js +174 -0
  453. package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +232 -0
  454. package/lib/runtime/MakeNamespaceObjectRuntimeModule.js +39 -0
  455. package/lib/runtime/NonceRuntimeModule.js +24 -0
  456. package/lib/runtime/OnChunksLoadedRuntimeModule.js +78 -0
  457. package/lib/runtime/PublicPathRuntimeModule.js +38 -0
  458. package/lib/runtime/RelativeUrlRuntimeModule.js +44 -0
  459. package/lib/runtime/RuntimeIdRuntimeModule.js +33 -0
  460. package/lib/runtime/StartupChunkDependenciesPlugin.js +88 -0
  461. package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +77 -0
  462. package/lib/runtime/StartupEntrypointRuntimeModule.js +54 -0
  463. package/lib/runtime/SystemContextRuntimeModule.js +23 -0
  464. package/lib/runtime/ToBinaryRuntimeModule.js +72 -0
  465. package/lib/schemes/DataUriPlugin.js +47 -0
  466. package/lib/schemes/FileUriPlugin.js +54 -0
  467. package/lib/schemes/HttpUriPlugin.js +1410 -0
  468. package/lib/schemes/VirtualUrlPlugin.js +248 -0
  469. package/lib/serialization/AggregateErrorSerializer.js +41 -0
  470. package/lib/serialization/ArraySerializer.js +38 -0
  471. package/lib/serialization/BinaryMiddleware.js +1164 -0
  472. package/lib/serialization/DateObjectSerializer.js +28 -0
  473. package/lib/serialization/ErrorObjectSerializer.js +49 -0
  474. package/lib/serialization/FileMiddleware.js +766 -0
  475. package/lib/serialization/MapObjectSerializer.js +48 -0
  476. package/lib/serialization/NullPrototypeObjectSerializer.js +53 -0
  477. package/lib/serialization/ObjectMiddleware.js +877 -0
  478. package/lib/serialization/PlainObjectSerializer.js +119 -0
  479. package/lib/serialization/RegExpObjectSerializer.js +29 -0
  480. package/lib/serialization/Serializer.js +82 -0
  481. package/lib/serialization/SerializerMiddleware.js +226 -0
  482. package/lib/serialization/SetObjectSerializer.js +40 -0
  483. package/lib/serialization/SingleItemMiddleware.js +36 -0
  484. package/lib/serialization/types.js +13 -0
  485. package/lib/sharing/ConsumeSharedFallbackDependency.js +33 -0
  486. package/lib/sharing/ConsumeSharedModule.js +344 -0
  487. package/lib/sharing/ConsumeSharedPlugin.js +380 -0
  488. package/lib/sharing/ConsumeSharedRuntimeModule.js +358 -0
  489. package/lib/sharing/ProvideForSharedDependency.js +33 -0
  490. package/lib/sharing/ProvideSharedDependency.js +80 -0
  491. package/lib/sharing/ProvideSharedModule.js +196 -0
  492. package/lib/sharing/ProvideSharedModuleFactory.js +37 -0
  493. package/lib/sharing/ProvideSharedPlugin.js +248 -0
  494. package/lib/sharing/SharePlugin.js +91 -0
  495. package/lib/sharing/ShareRuntimeModule.js +152 -0
  496. package/lib/sharing/resolveMatchedConfigs.js +106 -0
  497. package/lib/sharing/utils.js +421 -0
  498. package/lib/stats/DefaultStatsFactoryPlugin.js +2791 -0
  499. package/lib/stats/DefaultStatsPresetPlugin.js +417 -0
  500. package/lib/stats/DefaultStatsPrinterPlugin.js +1860 -0
  501. package/lib/stats/StatsFactory.js +406 -0
  502. package/lib/stats/StatsPrinter.js +300 -0
  503. package/lib/url/URLParserPlugin.js +266 -0
  504. package/lib/util/AppendOnlyStackedSet.js +78 -0
  505. package/lib/util/ArrayHelpers.js +46 -0
  506. package/lib/util/ArrayQueue.js +104 -0
  507. package/lib/util/AsyncQueue.js +411 -0
  508. package/lib/util/Hash.js +68 -0
  509. package/lib/util/IterableHelpers.js +46 -0
  510. package/lib/util/LazyBucketSortedSet.js +272 -0
  511. package/lib/util/LazySet.js +236 -0
  512. package/lib/util/MapHelpers.js +34 -0
  513. package/lib/util/ParallelismFactorCalculator.js +70 -0
  514. package/lib/util/Queue.js +52 -0
  515. package/lib/util/Semaphore.js +51 -0
  516. package/lib/util/SetHelpers.js +94 -0
  517. package/lib/util/SortableSet.js +176 -0
  518. package/lib/util/StackedCacheMap.js +140 -0
  519. package/lib/util/StackedMap.js +164 -0
  520. package/lib/util/StringXor.js +103 -0
  521. package/lib/util/TupleQueue.js +70 -0
  522. package/lib/util/TupleSet.js +185 -0
  523. package/lib/util/URLAbsoluteSpecifier.js +86 -0
  524. package/lib/util/WeakTupleMap.js +227 -0
  525. package/lib/util/binarySearchBounds.js +136 -0
  526. package/lib/util/chainedImports.js +99 -0
  527. package/lib/util/cleverMerge.js +676 -0
  528. package/lib/util/comparators.js +645 -0
  529. package/lib/util/compileBooleanMatcher.js +313 -0
  530. package/lib/util/concatenate.js +232 -0
  531. package/lib/util/conventions.js +126 -0
  532. package/lib/util/create-schema-validation.js +41 -0
  533. package/lib/util/createHash.js +91 -0
  534. package/lib/util/dataURL.js +39 -0
  535. package/lib/util/deprecation.js +350 -0
  536. package/lib/util/deterministicGrouping.js +561 -0
  537. package/lib/util/extractSourceMap.js +318 -0
  538. package/lib/util/extractUrlAndGlobal.js +18 -0
  539. package/lib/util/findGraphRoots.js +211 -0
  540. package/lib/util/fs.js +675 -0
  541. package/lib/util/generateDebugId.js +33 -0
  542. package/lib/util/hash/BatchedHash.js +115 -0
  543. package/lib/util/hash/BulkUpdateHash.js +145 -0
  544. package/lib/util/hash/DebugHash.js +75 -0
  545. package/lib/util/hash/hash-digest.js +217 -0
  546. package/lib/util/hash/md4.js +20 -0
  547. package/lib/util/hash/wasm-hash.js +232 -0
  548. package/lib/util/hash/xxhash64.js +20 -0
  549. package/lib/util/identifier.js +471 -0
  550. package/lib/util/internalSerializables.js +222 -0
  551. package/lib/util/magicComment.js +25 -0
  552. package/lib/util/makeSerializable.js +60 -0
  553. package/lib/util/memoize.js +36 -0
  554. package/lib/util/nonNumericOnlyHash.js +22 -0
  555. package/lib/util/numberHash.js +95 -0
  556. package/lib/util/objectToMap.js +15 -0
  557. package/lib/util/processAsyncTree.js +68 -0
  558. package/lib/util/propertyAccess.js +30 -0
  559. package/lib/util/propertyName.js +76 -0
  560. package/lib/util/registerExternalSerializer.js +334 -0
  561. package/lib/util/removeBOM.js +25 -0
  562. package/lib/util/runtime.js +717 -0
  563. package/lib/util/semver.js +604 -0
  564. package/lib/util/serialization.js +153 -0
  565. package/lib/util/smartGrouping.js +221 -0
  566. package/lib/util/source.js +62 -0
  567. package/lib/util/traverseDestructuringAssignmentProperties.js +45 -0
  568. package/lib/validateSchema.js +177 -0
  569. package/lib/wasm/EnableWasmLoadingPlugin.js +146 -0
  570. package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +154 -0
  571. package/lib/wasm-async/AsyncWebAssemblyGenerator.js +74 -0
  572. package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +212 -0
  573. package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +209 -0
  574. package/lib/wasm-async/AsyncWebAssemblyParser.js +80 -0
  575. package/lib/wasm-async/UniversalCompileAsyncWasmPlugin.js +107 -0
  576. package/lib/wasm-sync/UnsupportedWebAssemblyFeatureError.js +20 -0
  577. package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +422 -0
  578. package/lib/wasm-sync/WasmFinalizeExportsPlugin.js +91 -0
  579. package/lib/wasm-sync/WebAssemblyGenerator.js +535 -0
  580. package/lib/wasm-sync/WebAssemblyInInitialChunkError.js +111 -0
  581. package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +236 -0
  582. package/lib/wasm-sync/WebAssemblyModulesPlugin.js +151 -0
  583. package/lib/wasm-sync/WebAssemblyParser.js +201 -0
  584. package/lib/wasm-sync/WebAssemblyUtils.js +66 -0
  585. package/lib/web/FetchCompileAsyncWasmPlugin.js +70 -0
  586. package/lib/web/FetchCompileWasmPlugin.js +86 -0
  587. package/lib/web/JsonpChunkLoadingPlugin.js +101 -0
  588. package/lib/web/JsonpChunkLoadingRuntimeModule.js +455 -0
  589. package/lib/web/JsonpTemplatePlugin.js +37 -0
  590. package/lib/webpack.js +227 -0
  591. package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +110 -0
  592. package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +231 -0
  593. package/lib/webworker/WebWorkerTemplatePlugin.js +26 -0
  594. package/module.d.ts +238 -0
  595. package/package.json +258 -0
  596. package/schemas/WebpackOptions.check.d.ts +7 -0
  597. package/schemas/WebpackOptions.check.js +6 -0
  598. package/schemas/WebpackOptions.json +6179 -0
  599. package/schemas/_container.json +155 -0
  600. package/schemas/_sharing.json +118 -0
  601. package/schemas/plugins/BannerPlugin.check.d.ts +7 -0
  602. package/schemas/plugins/BannerPlugin.check.js +6 -0
  603. package/schemas/plugins/BannerPlugin.json +115 -0
  604. package/schemas/plugins/DllPlugin.check.d.ts +7 -0
  605. package/schemas/plugins/DllPlugin.check.js +6 -0
  606. package/schemas/plugins/DllPlugin.json +36 -0
  607. package/schemas/plugins/DllReferencePlugin.check.d.ts +7 -0
  608. package/schemas/plugins/DllReferencePlugin.check.js +6 -0
  609. package/schemas/plugins/DllReferencePlugin.json +206 -0
  610. package/schemas/plugins/IgnorePlugin.check.d.ts +7 -0
  611. package/schemas/plugins/IgnorePlugin.check.js +6 -0
  612. package/schemas/plugins/IgnorePlugin.json +34 -0
  613. package/schemas/plugins/LoaderOptionsPlugin.check.d.ts +7 -0
  614. package/schemas/plugins/LoaderOptionsPlugin.check.js +6 -0
  615. package/schemas/plugins/LoaderOptionsPlugin.json +27 -0
  616. package/schemas/plugins/ManifestPlugin.check.d.ts +7 -0
  617. package/schemas/plugins/ManifestPlugin.check.js +6 -0
  618. package/schemas/plugins/ManifestPlugin.json +98 -0
  619. package/schemas/plugins/ProgressPlugin.check.d.ts +7 -0
  620. package/schemas/plugins/ProgressPlugin.check.js +6 -0
  621. package/schemas/plugins/ProgressPlugin.json +65 -0
  622. package/schemas/plugins/SourceMapDevToolPlugin.check.d.ts +7 -0
  623. package/schemas/plugins/SourceMapDevToolPlugin.check.js +6 -0
  624. package/schemas/plugins/SourceMapDevToolPlugin.json +168 -0
  625. package/schemas/plugins/WatchIgnorePlugin.check.d.ts +7 -0
  626. package/schemas/plugins/WatchIgnorePlugin.check.js +6 -0
  627. package/schemas/plugins/WatchIgnorePlugin.json +25 -0
  628. package/schemas/plugins/asset/AssetGeneratorOptions.check.d.ts +7 -0
  629. package/schemas/plugins/asset/AssetGeneratorOptions.check.js +6 -0
  630. package/schemas/plugins/asset/AssetGeneratorOptions.json +3 -0
  631. package/schemas/plugins/asset/AssetInlineGeneratorOptions.check.d.ts +7 -0
  632. package/schemas/plugins/asset/AssetInlineGeneratorOptions.check.js +6 -0
  633. package/schemas/plugins/asset/AssetInlineGeneratorOptions.json +3 -0
  634. package/schemas/plugins/asset/AssetParserOptions.check.d.ts +7 -0
  635. package/schemas/plugins/asset/AssetParserOptions.check.js +6 -0
  636. package/schemas/plugins/asset/AssetParserOptions.json +3 -0
  637. package/schemas/plugins/asset/AssetResourceGeneratorOptions.check.d.ts +7 -0
  638. package/schemas/plugins/asset/AssetResourceGeneratorOptions.check.js +6 -0
  639. package/schemas/plugins/asset/AssetResourceGeneratorOptions.json +3 -0
  640. package/schemas/plugins/container/ContainerPlugin.check.d.ts +7 -0
  641. package/schemas/plugins/container/ContainerPlugin.check.js +6 -0
  642. package/schemas/plugins/container/ContainerPlugin.json +294 -0
  643. package/schemas/plugins/container/ContainerReferencePlugin.check.d.ts +7 -0
  644. package/schemas/plugins/container/ContainerReferencePlugin.check.js +6 -0
  645. package/schemas/plugins/container/ContainerReferencePlugin.json +132 -0
  646. package/schemas/plugins/container/ExternalsType.check.d.ts +7 -0
  647. package/schemas/plugins/container/ExternalsType.check.js +6 -0
  648. package/schemas/plugins/container/ExternalsType.json +3 -0
  649. package/schemas/plugins/container/ModuleFederationPlugin.check.d.ts +7 -0
  650. package/schemas/plugins/container/ModuleFederationPlugin.check.js +6 -0
  651. package/schemas/plugins/container/ModuleFederationPlugin.json +525 -0
  652. package/schemas/plugins/css/CssGeneratorOptions.check.d.ts +7 -0
  653. package/schemas/plugins/css/CssGeneratorOptions.check.js +6 -0
  654. package/schemas/plugins/css/CssGeneratorOptions.json +3 -0
  655. package/schemas/plugins/css/CssModuleGeneratorOptions.check.d.ts +7 -0
  656. package/schemas/plugins/css/CssModuleGeneratorOptions.check.js +6 -0
  657. package/schemas/plugins/css/CssModuleGeneratorOptions.json +3 -0
  658. package/schemas/plugins/css/CssModuleParserOptions.check.d.ts +7 -0
  659. package/schemas/plugins/css/CssModuleParserOptions.check.js +6 -0
  660. package/schemas/plugins/css/CssModuleParserOptions.json +3 -0
  661. package/schemas/plugins/css/CssParserOptions.check.d.ts +7 -0
  662. package/schemas/plugins/css/CssParserOptions.check.js +6 -0
  663. package/schemas/plugins/css/CssParserOptions.json +3 -0
  664. package/schemas/plugins/debug/ProfilingPlugin.check.d.ts +7 -0
  665. package/schemas/plugins/debug/ProfilingPlugin.check.js +6 -0
  666. package/schemas/plugins/debug/ProfilingPlugin.json +12 -0
  667. package/schemas/plugins/ids/HashedModuleIdsPlugin.check.d.ts +7 -0
  668. package/schemas/plugins/ids/HashedModuleIdsPlugin.check.js +6 -0
  669. package/schemas/plugins/ids/HashedModuleIdsPlugin.json +57 -0
  670. package/schemas/plugins/ids/OccurrenceChunkIdsPlugin.check.d.ts +7 -0
  671. package/schemas/plugins/ids/OccurrenceChunkIdsPlugin.check.js +6 -0
  672. package/schemas/plugins/ids/OccurrenceChunkIdsPlugin.json +11 -0
  673. package/schemas/plugins/ids/OccurrenceModuleIdsPlugin.check.d.ts +7 -0
  674. package/schemas/plugins/ids/OccurrenceModuleIdsPlugin.check.js +6 -0
  675. package/schemas/plugins/ids/OccurrenceModuleIdsPlugin.json +11 -0
  676. package/schemas/plugins/json/JsonModulesPluginGenerator.check.d.ts +7 -0
  677. package/schemas/plugins/json/JsonModulesPluginGenerator.check.js +6 -0
  678. package/schemas/plugins/json/JsonModulesPluginGenerator.json +3 -0
  679. package/schemas/plugins/json/JsonModulesPluginParser.check.d.ts +7 -0
  680. package/schemas/plugins/json/JsonModulesPluginParser.check.js +6 -0
  681. package/schemas/plugins/json/JsonModulesPluginParser.json +3 -0
  682. package/schemas/plugins/optimize/AggressiveSplittingPlugin.check.d.ts +7 -0
  683. package/schemas/plugins/optimize/AggressiveSplittingPlugin.check.js +6 -0
  684. package/schemas/plugins/optimize/AggressiveSplittingPlugin.json +23 -0
  685. package/schemas/plugins/optimize/LimitChunkCountPlugin.check.d.ts +7 -0
  686. package/schemas/plugins/optimize/LimitChunkCountPlugin.check.js +6 -0
  687. package/schemas/plugins/optimize/LimitChunkCountPlugin.json +21 -0
  688. package/schemas/plugins/optimize/MergeDuplicateChunksPlugin.check.d.ts +7 -0
  689. package/schemas/plugins/optimize/MergeDuplicateChunksPlugin.check.js +6 -0
  690. package/schemas/plugins/optimize/MergeDuplicateChunksPlugin.json +11 -0
  691. package/schemas/plugins/optimize/MinChunkSizePlugin.check.d.ts +7 -0
  692. package/schemas/plugins/optimize/MinChunkSizePlugin.check.js +6 -0
  693. package/schemas/plugins/optimize/MinChunkSizePlugin.json +20 -0
  694. package/schemas/plugins/schemes/HttpUriPlugin.check.d.ts +7 -0
  695. package/schemas/plugins/schemes/HttpUriPlugin.check.js +6 -0
  696. package/schemas/plugins/schemes/HttpUriPlugin.json +74 -0
  697. package/schemas/plugins/schemes/VirtualUrlPlugin.check.d.ts +7 -0
  698. package/schemas/plugins/schemes/VirtualUrlPlugin.check.js +6 -0
  699. package/schemas/plugins/schemes/VirtualUrlPlugin.json +77 -0
  700. package/schemas/plugins/sharing/ConsumeSharedPlugin.check.d.ts +7 -0
  701. package/schemas/plugins/sharing/ConsumeSharedPlugin.check.js +6 -0
  702. package/schemas/plugins/sharing/ConsumeSharedPlugin.json +120 -0
  703. package/schemas/plugins/sharing/ProvideSharedPlugin.check.d.ts +7 -0
  704. package/schemas/plugins/sharing/ProvideSharedPlugin.check.js +6 -0
  705. package/schemas/plugins/sharing/ProvideSharedPlugin.json +94 -0
  706. package/schemas/plugins/sharing/SharePlugin.check.d.ts +7 -0
  707. package/schemas/plugins/sharing/SharePlugin.check.js +6 -0
  708. package/schemas/plugins/sharing/SharePlugin.json +133 -0
  709. package/types.d.ts +20217 -0
@@ -0,0 +1,2791 @@
1
+ /*
2
+ MIT License http://www.opensource.org/licenses/mit-license.php
3
+ Author Tobias Koppers @sokra
4
+ */
5
+
6
+ "use strict";
7
+
8
+ const util = require("util");
9
+ const { WEBPACK_MODULE_TYPE_RUNTIME } = require("../ModuleTypeConstants");
10
+ const ModuleDependency = require("../dependencies/ModuleDependency");
11
+ const formatLocation = require("../formatLocation");
12
+ const { LogType } = require("../logging/Logger");
13
+ const AggressiveSplittingPlugin = require("../optimize/AggressiveSplittingPlugin");
14
+ const SizeLimitsPlugin = require("../performance/SizeLimitsPlugin");
15
+ const { countIterable } = require("../util/IterableHelpers");
16
+ const {
17
+ compareChunksById,
18
+ compareIds,
19
+ compareLocations,
20
+ compareModulesByIdentifier,
21
+ compareNumbers,
22
+ compareSelect,
23
+ concatComparators
24
+ } = require("../util/comparators");
25
+ const { makePathsRelative, parseResource } = require("../util/identifier");
26
+
27
+ /** @typedef {import("webpack-sources").Source} Source */
28
+ /** @typedef {import("../../declarations/WebpackOptions").StatsValue} StatsValue */
29
+ /** @typedef {import("./StatsFactory")} StatsFactory */
30
+ /** @typedef {import("./StatsFactory").StatsFactoryContext} StatsFactoryContext */
31
+ /** @typedef {import("../Chunk")} Chunk */
32
+ /** @typedef {import("../Chunk").ChunkId} ChunkId */
33
+ /** @typedef {import("../Chunk").ChunkName} ChunkName */
34
+ /** @typedef {import("../ChunkGraph").ModuleId} ModuleId */
35
+ /** @typedef {import("../ChunkGroup")} ChunkGroup */
36
+ /** @typedef {import("../ChunkGroup").OriginRecord} OriginRecord */
37
+ /** @typedef {import("../Compilation")} Compilation */
38
+ /** @typedef {import("../Compilation").Asset} Asset */
39
+ /** @typedef {import("../Compilation").AssetInfo} AssetInfo */
40
+ /** @typedef {import("../Compilation").ExcludeModulesType} ExcludeModulesType */
41
+ /** @typedef {import("../Compilation").KnownNormalizedStatsOptions} KnownNormalizedStatsOptions */
42
+ /** @typedef {import("../Compilation").NormalizedStatsOptions} NormalizedStatsOptions */
43
+ /** @typedef {import("../Compiler")} Compiler */
44
+ /** @typedef {import("../Dependency")} Dependency */
45
+ /** @typedef {import("../Dependency").DependencyLocation} DependencyLocation */
46
+ /** @typedef {import("../Module")} Module */
47
+ /** @typedef {import("../Module").NameForCondition} NameForCondition */
48
+ /** @typedef {import("../Module").BuildInfo} BuildInfo */
49
+ /** @typedef {import("../ModuleGraphConnection")} ModuleGraphConnection */
50
+ /** @typedef {import("../ModuleProfile")} ModuleProfile */
51
+ /** @typedef {import("../WebpackError")} WebpackError */
52
+ /** @typedef {import("../serialization/AggregateErrorSerializer").AggregateError} AggregateError */
53
+ /** @typedef {import("../serialization/ErrorObjectSerializer").ErrorWithCause} ErrorWithCause */
54
+ /** @typedef {import("../ExportsInfo").ExportInfoName} ExportInfoName */
55
+
56
+ /**
57
+ * @template T
58
+ * @typedef {import("../util/comparators").Comparator<T>} Comparator<T>
59
+ */
60
+
61
+ /**
62
+ * @template I, G
63
+ * @typedef {import("../util/smartGrouping").GroupConfig<I, G>} GroupConfig
64
+ */
65
+
66
+ /** @typedef {KnownStatsCompilation & Record<string, EXPECTED_ANY>} StatsCompilation */
67
+ /**
68
+ * @typedef {object} KnownStatsCompilation
69
+ * @property {EXPECTED_ANY=} env
70
+ * @property {string=} name
71
+ * @property {string=} hash
72
+ * @property {string=} version
73
+ * @property {number=} time
74
+ * @property {number=} builtAt
75
+ * @property {boolean=} needAdditionalPass
76
+ * @property {string=} publicPath
77
+ * @property {string=} outputPath
78
+ * @property {Record<string, string[]>=} assetsByChunkName
79
+ * @property {StatsAsset[]=} assets
80
+ * @property {number=} filteredAssets
81
+ * @property {StatsChunk[]=} chunks
82
+ * @property {StatsModule[]=} modules
83
+ * @property {number=} filteredModules
84
+ * @property {Record<string, StatsChunkGroup>=} entrypoints
85
+ * @property {Record<string, StatsChunkGroup>=} namedChunkGroups
86
+ * @property {StatsError[]=} errors
87
+ * @property {number=} errorsCount
88
+ * @property {StatsError[]=} warnings
89
+ * @property {number=} warningsCount
90
+ * @property {StatsCompilation[]=} children
91
+ * @property {Record<string, StatsLogging>=} logging
92
+ * @property {number=} filteredWarningDetailsCount
93
+ * @property {number=} filteredErrorDetailsCount
94
+ */
95
+
96
+ /** @typedef {KnownStatsLogging & Record<string, EXPECTED_ANY>} StatsLogging */
97
+ /**
98
+ * @typedef {object} KnownStatsLogging
99
+ * @property {StatsLoggingEntry[]} entries
100
+ * @property {number} filteredEntries
101
+ * @property {boolean} debug
102
+ */
103
+
104
+ /** @typedef {KnownStatsLoggingEntry & Record<string, EXPECTED_ANY>} StatsLoggingEntry */
105
+ /**
106
+ * @typedef {object} KnownStatsLoggingEntry
107
+ * @property {string} type
108
+ * @property {string=} message
109
+ * @property {string[]=} trace
110
+ * @property {StatsLoggingEntry[]=} children
111
+ * @property {EXPECTED_ANY[]=} args
112
+ * @property {number=} time
113
+ */
114
+
115
+ /** @typedef {KnownStatsAsset & Record<string, EXPECTED_ANY>} StatsAsset */
116
+ /** @typedef {string[]} ChunkIdHints */
117
+ /**
118
+ * @typedef {object} KnownStatsAsset
119
+ * @property {string} type
120
+ * @property {string} name
121
+ * @property {AssetInfo} info
122
+ * @property {number} size
123
+ * @property {boolean} emitted
124
+ * @property {boolean} comparedForEmit
125
+ * @property {boolean} cached
126
+ * @property {StatsAsset[]=} related
127
+ * @property {ChunkId[]=} chunks
128
+ * @property {ChunkName[]=} chunkNames
129
+ * @property {ChunkIdHints=} chunkIdHints
130
+ * @property {ChunkId[]=} auxiliaryChunks
131
+ * @property {ChunkName[]=} auxiliaryChunkNames
132
+ * @property {ChunkIdHints=} auxiliaryChunkIdHints
133
+ * @property {number=} filteredRelated
134
+ * @property {boolean=} isOverSizeLimit
135
+ */
136
+
137
+ /** @typedef {KnownStatsChunkGroup & Record<string, EXPECTED_ANY>} StatsChunkGroup */
138
+ /**
139
+ * @typedef {object} KnownStatsChunkGroup
140
+ * @property {ChunkName=} name
141
+ * @property {ChunkId[]=} chunks
142
+ * @property {({ name: string, size?: number })[]=} assets
143
+ * @property {number=} filteredAssets
144
+ * @property {number=} assetsSize
145
+ * @property {({ name: string, size?: number })[]=} auxiliaryAssets
146
+ * @property {number=} filteredAuxiliaryAssets
147
+ * @property {number=} auxiliaryAssetsSize
148
+ * @property {Record<string, StatsChunkGroup[]>=} children
149
+ * @property {Record<string, string[]>=} childAssets
150
+ * @property {boolean=} isOverSizeLimit
151
+ */
152
+
153
+ /** @typedef {Module[]} ModuleIssuerPath */
154
+ /** @typedef {KnownStatsModule & Record<string, EXPECTED_ANY>} StatsModule */
155
+ /**
156
+ * @typedef {object} KnownStatsModule
157
+ * @property {string=} type
158
+ * @property {string=} moduleType
159
+ * @property {(string | null)=} layer
160
+ * @property {string=} identifier
161
+ * @property {string=} name
162
+ * @property {NameForCondition | null=} nameForCondition
163
+ * @property {number=} index
164
+ * @property {number=} preOrderIndex
165
+ * @property {number=} index2
166
+ * @property {number=} postOrderIndex
167
+ * @property {number=} size
168
+ * @property {Record<string, number>=} sizes
169
+ * @property {boolean=} cacheable
170
+ * @property {boolean=} built
171
+ * @property {boolean=} codeGenerated
172
+ * @property {boolean=} buildTimeExecuted
173
+ * @property {boolean=} cached
174
+ * @property {boolean=} optional
175
+ * @property {boolean=} orphan
176
+ * @property {ModuleId=} id
177
+ * @property {ModuleId | null=} issuerId
178
+ * @property {ChunkId[]=} chunks
179
+ * @property {string[]=} assets
180
+ * @property {boolean=} dependent
181
+ * @property {(string | null)=} issuer
182
+ * @property {(string | null)=} issuerName
183
+ * @property {StatsModuleIssuer[] | null=} issuerPath
184
+ * @property {boolean=} failed
185
+ * @property {number=} errors
186
+ * @property {number=} warnings
187
+ * @property {StatsProfile=} profile
188
+ * @property {StatsModuleReason[]=} reasons
189
+ * @property {boolean | null | ExportInfoName[]=} usedExports
190
+ * @property {ExportInfoName[] | null=} providedExports
191
+ * @property {string[]=} optimizationBailout
192
+ * @property {(number | null)=} depth
193
+ * @property {StatsModule[]=} modules
194
+ * @property {number=} filteredModules
195
+ * @property {ReturnType<Source["source"]>=} source
196
+ */
197
+
198
+ /** @typedef {KnownStatsProfile & Record<string, EXPECTED_ANY>} StatsProfile */
199
+ /**
200
+ * @typedef {object} KnownStatsProfile
201
+ * @property {number} total
202
+ * @property {number} resolving
203
+ * @property {number} restoring
204
+ * @property {number} building
205
+ * @property {number} integration
206
+ * @property {number} storing
207
+ * @property {number} additionalResolving
208
+ * @property {number} additionalIntegration
209
+ * @property {number} factory
210
+ * @property {number} dependencies
211
+ */
212
+
213
+ /** @typedef {KnownStatsModuleIssuer & Record<string, EXPECTED_ANY>} StatsModuleIssuer */
214
+ /**
215
+ * @typedef {object} KnownStatsModuleIssuer
216
+ * @property {string} identifier
217
+ * @property {string} name
218
+ * @property {ModuleId=} id
219
+ * @property {StatsProfile} profile
220
+ */
221
+
222
+ /** @typedef {KnownStatsModuleReason & Record<string, EXPECTED_ANY>} StatsModuleReason */
223
+ /**
224
+ * @typedef {object} KnownStatsModuleReason
225
+ * @property {string | null} moduleIdentifier
226
+ * @property {string | null} module
227
+ * @property {string | null} moduleName
228
+ * @property {string | null} resolvedModuleIdentifier
229
+ * @property {string | null} resolvedModule
230
+ * @property {string | null} type
231
+ * @property {boolean} active
232
+ * @property {string | null} explanation
233
+ * @property {string | null} userRequest
234
+ * @property {(string | null)=} loc
235
+ * @property {ModuleId | null=} moduleId
236
+ * @property {ModuleId | null=} resolvedModuleId
237
+ */
238
+
239
+ /** @typedef {KnownStatsChunk & Record<string, EXPECTED_ANY>} StatsChunk */
240
+ /**
241
+ * @typedef {object} KnownStatsChunk
242
+ * @property {boolean} rendered
243
+ * @property {boolean} initial
244
+ * @property {boolean} entry
245
+ * @property {boolean} recorded
246
+ * @property {string=} reason
247
+ * @property {number} size
248
+ * @property {Record<string, number>} sizes
249
+ * @property {string[]} names
250
+ * @property {string[]} idHints
251
+ * @property {string[]=} runtime
252
+ * @property {string[]} files
253
+ * @property {string[]} auxiliaryFiles
254
+ * @property {string} hash
255
+ * @property {Record<string, ChunkId[]>} childrenByOrder
256
+ * @property {ChunkId=} id
257
+ * @property {ChunkId[]=} siblings
258
+ * @property {ChunkId[]=} parents
259
+ * @property {ChunkId[]=} children
260
+ * @property {StatsModule[]=} modules
261
+ * @property {number=} filteredModules
262
+ * @property {StatsChunkOrigin[]=} origins
263
+ */
264
+
265
+ /** @typedef {KnownStatsChunkOrigin & Record<string, EXPECTED_ANY>} StatsChunkOrigin */
266
+ /**
267
+ * @typedef {object} KnownStatsChunkOrigin
268
+ * @property {string} module
269
+ * @property {string} moduleIdentifier
270
+ * @property {string} moduleName
271
+ * @property {string} loc
272
+ * @property {string} request
273
+ * @property {ModuleId=} moduleId
274
+ */
275
+
276
+ /** @typedef {KnownStatsModuleTraceItem & Record<string, EXPECTED_ANY>} StatsModuleTraceItem */
277
+ /**
278
+ * @typedef {object} KnownStatsModuleTraceItem
279
+ * @property {string=} originIdentifier
280
+ * @property {string=} originName
281
+ * @property {string=} moduleIdentifier
282
+ * @property {string=} moduleName
283
+ * @property {StatsModuleTraceDependency[]=} dependencies
284
+ * @property {ModuleId=} originId
285
+ * @property {ModuleId=} moduleId
286
+ */
287
+
288
+ /** @typedef {KnownStatsModuleTraceDependency & Record<string, EXPECTED_ANY>} StatsModuleTraceDependency */
289
+ /**
290
+ * @typedef {object} KnownStatsModuleTraceDependency
291
+ * @property {string=} loc
292
+ */
293
+
294
+ /** @typedef {KnownStatsError & Record<string, EXPECTED_ANY>} StatsError */
295
+ /**
296
+ * @typedef {object} KnownStatsError
297
+ * @property {string} message
298
+ * @property {string=} chunkName
299
+ * @property {boolean=} chunkEntry
300
+ * @property {boolean=} chunkInitial
301
+ * @property {string=} file
302
+ * @property {string=} moduleIdentifier
303
+ * @property {string=} moduleName
304
+ * @property {string=} loc
305
+ * @property {ChunkId=} chunkId
306
+ * @property {ModuleId=} moduleId
307
+ * @property {StatsModuleTraceItem[]=} moduleTrace
308
+ * @property {string=} details
309
+ * @property {string=} stack
310
+ * @property {KnownStatsError=} cause
311
+ * @property {KnownStatsError[]=} errors
312
+ * @property {string=} compilerPath
313
+ */
314
+
315
+ /** @typedef {Asset & { type: string, related: PreprocessedAsset[] | undefined }} PreprocessedAsset */
316
+
317
+ /**
318
+ * @template T
319
+ * @template O
320
+ * @typedef {Record<string, (object: O, data: T, context: StatsFactoryContext, options: NormalizedStatsOptions, factory: StatsFactory) => void>} ExtractorsByOption
321
+ */
322
+
323
+ /** @typedef {{ name: string, chunkGroup: ChunkGroup }} ChunkGroupInfoWithName */
324
+ /** @typedef {{ origin: Module, module: Module }} ModuleTrace */
325
+
326
+ /**
327
+ * @typedef {object} SimpleExtractors
328
+ * @property {ExtractorsByOption<Compilation, StatsCompilation>} compilation
329
+ * @property {ExtractorsByOption<PreprocessedAsset, StatsAsset>} asset
330
+ * @property {ExtractorsByOption<PreprocessedAsset, StatsAsset>} asset$visible
331
+ * @property {ExtractorsByOption<ChunkGroupInfoWithName, StatsChunkGroup>} chunkGroup
332
+ * @property {ExtractorsByOption<Module, StatsModule>} module
333
+ * @property {ExtractorsByOption<Module, StatsModule>} module$visible
334
+ * @property {ExtractorsByOption<Module, StatsModuleIssuer>} moduleIssuer
335
+ * @property {ExtractorsByOption<ModuleProfile, StatsProfile>} profile
336
+ * @property {ExtractorsByOption<ModuleGraphConnection, StatsModuleReason>} moduleReason
337
+ * @property {ExtractorsByOption<Chunk, StatsChunk>} chunk
338
+ * @property {ExtractorsByOption<OriginRecord, StatsChunkOrigin>} chunkOrigin
339
+ * @property {ExtractorsByOption<WebpackError, StatsError>} error
340
+ * @property {ExtractorsByOption<WebpackError, StatsError>} warning
341
+ * @property {ExtractorsByOption<WebpackError, StatsError>} cause
342
+ * @property {ExtractorsByOption<ModuleTrace, StatsModuleTraceItem>} moduleTraceItem
343
+ * @property {ExtractorsByOption<Dependency, StatsModuleTraceDependency>} moduleTraceDependency
344
+ */
345
+
346
+ /**
347
+ * @template T
348
+ * @template I
349
+ * @param {Iterable<T>} items items to select from
350
+ * @param {(item: T) => Iterable<I>} selector selector function to select values from item
351
+ * @returns {I[]} array of values
352
+ */
353
+ const uniqueArray = (items, selector) => {
354
+ /** @type {Set<I>} */
355
+ const set = new Set();
356
+ for (const item of items) {
357
+ for (const i of selector(item)) {
358
+ set.add(i);
359
+ }
360
+ }
361
+ return [...set];
362
+ };
363
+
364
+ /**
365
+ * @template T
366
+ * @template I
367
+ * @param {Iterable<T>} items items to select from
368
+ * @param {(item: T) => Iterable<I>} selector selector function to select values from item
369
+ * @param {Comparator<I>} comparator comparator function
370
+ * @returns {I[]} array of values
371
+ */
372
+ const uniqueOrderedArray = (items, selector, comparator) =>
373
+ uniqueArray(items, selector).sort(comparator);
374
+
375
+ /**
376
+ * @template T
377
+ * @template R
378
+ * @typedef {{ [P in keyof T]: R }} MappedValues<T, R>
379
+ */
380
+
381
+ /**
382
+ * @template {object} T
383
+ * @template {object} R
384
+ * @param {T} obj object to be mapped
385
+ * @param {(value: T[keyof T], key: keyof T) => R} fn mapping function
386
+ * @returns {MappedValues<T, R>} mapped object
387
+ */
388
+ const mapObject = (obj, fn) => {
389
+ /** @type {MappedValues<T, R>} */
390
+ const newObj = Object.create(null);
391
+ for (const key of /** @type {(keyof T)[]} */ (Object.keys(obj))) {
392
+ newObj[key] = fn(obj[key], key);
393
+ }
394
+ return newObj;
395
+ };
396
+
397
+ /**
398
+ * @template T
399
+ * @param {Compilation} compilation the compilation
400
+ * @param {(compilation: Compilation, name: string) => T[]} getItems get items
401
+ * @returns {number} total number
402
+ */
403
+ const countWithChildren = (compilation, getItems) => {
404
+ let count = getItems(compilation, "").length;
405
+ for (const child of compilation.children) {
406
+ count += countWithChildren(child, (c, type) =>
407
+ getItems(c, `.children[].compilation${type}`)
408
+ );
409
+ }
410
+ return count;
411
+ };
412
+
413
+ /** @type {ExtractorsByOption<string | ErrorWithCause | AggregateError | WebpackError, StatsError>} */
414
+ const EXTRACT_ERROR = {
415
+ _: (object, error, context, { requestShortener }) => {
416
+ // TODO webpack 6 disallow strings in the errors/warnings list
417
+ if (typeof error === "string") {
418
+ object.message = error;
419
+ } else {
420
+ if (/** @type {WebpackError} */ (error).chunk) {
421
+ const chunk = /** @type {WebpackError} */ (error).chunk;
422
+ object.chunkName =
423
+ /** @type {string | undefined} */
424
+ (chunk.name);
425
+ object.chunkEntry = chunk.hasRuntime();
426
+ object.chunkInitial = chunk.canBeInitial();
427
+ }
428
+
429
+ if (/** @type {WebpackError} */ (error).file) {
430
+ object.file = /** @type {WebpackError} */ (error).file;
431
+ }
432
+
433
+ if (/** @type {WebpackError} */ (error).module) {
434
+ object.moduleIdentifier =
435
+ /** @type {WebpackError} */
436
+ (error).module.identifier();
437
+ object.moduleName =
438
+ /** @type {WebpackError} */
439
+ (error).module.readableIdentifier(requestShortener);
440
+ }
441
+
442
+ if (/** @type {WebpackError} */ (error).loc) {
443
+ object.loc = formatLocation(/** @type {WebpackError} */ (error).loc);
444
+ }
445
+
446
+ object.message = error.message;
447
+ }
448
+ },
449
+ ids: (object, error, { compilation: { chunkGraph } }) => {
450
+ if (typeof error !== "string") {
451
+ if (/** @type {WebpackError} */ (error).chunk) {
452
+ object.chunkId = /** @type {ChunkId} */ (
453
+ /** @type {WebpackError} */
454
+ (error).chunk.id
455
+ );
456
+ }
457
+
458
+ if (/** @type {WebpackError} */ (error).module) {
459
+ object.moduleId =
460
+ /** @type {ModuleId} */
461
+ (chunkGraph.getModuleId(/** @type {WebpackError} */ (error).module));
462
+ }
463
+ }
464
+ },
465
+ moduleTrace: (object, error, context, options, factory) => {
466
+ if (
467
+ typeof error !== "string" &&
468
+ /** @type {WebpackError} */ (error).module
469
+ ) {
470
+ const {
471
+ type,
472
+ compilation: { moduleGraph }
473
+ } = context;
474
+ /** @type {Set<Module>} */
475
+ const visitedModules = new Set();
476
+ /** @type {ModuleTrace[]} */
477
+ const moduleTrace = [];
478
+ let current = /** @type {WebpackError} */ (error).module;
479
+ while (current) {
480
+ if (visitedModules.has(current)) break; // circular (technically impossible, but how knows)
481
+ visitedModules.add(current);
482
+ const origin = moduleGraph.getIssuer(current);
483
+ if (!origin) break;
484
+ moduleTrace.push({ origin, module: current });
485
+ current = origin;
486
+ }
487
+ object.moduleTrace = factory.create(
488
+ `${type}.moduleTrace`,
489
+ moduleTrace,
490
+ context
491
+ );
492
+ }
493
+ },
494
+ errorDetails: (
495
+ object,
496
+ error,
497
+ { type, compilation, cachedGetErrors },
498
+ { errorDetails }
499
+ ) => {
500
+ if (
501
+ typeof error !== "string" &&
502
+ (errorDetails === true ||
503
+ (type.endsWith(".error") && cachedGetErrors(compilation).length < 3))
504
+ ) {
505
+ object.details = /** @type {WebpackError} */ (error).details;
506
+ }
507
+ },
508
+ errorStack: (object, error, _context, { errorStack }) => {
509
+ if (typeof error !== "string" && errorStack) {
510
+ object.stack = error.stack;
511
+ }
512
+ },
513
+ errorCause: (object, error, context, options, factory) => {
514
+ if (
515
+ typeof error !== "string" &&
516
+ /** @type {ErrorWithCause} */ (error).cause
517
+ ) {
518
+ const rawCause = /** @type {ErrorWithCause} */ (error).cause;
519
+ /** @type {Error} */
520
+ const cause =
521
+ typeof rawCause === "string"
522
+ ? /** @type {Error} */ ({ message: rawCause })
523
+ : /** @type {Error} */ (rawCause);
524
+ const { type } = context;
525
+
526
+ object.cause = factory.create(`${type}.cause`, cause, context);
527
+ }
528
+ },
529
+ errorErrors: (object, error, context, options, factory) => {
530
+ if (
531
+ typeof error !== "string" &&
532
+ /** @type {AggregateError} */
533
+ (error).errors
534
+ ) {
535
+ const { type } = context;
536
+ object.errors = factory.create(
537
+ `${type}.errors`,
538
+ /** @type {Error[]} */
539
+ (/** @type {AggregateError} */ (error).errors),
540
+ context
541
+ );
542
+ }
543
+ }
544
+ };
545
+
546
+ /** @typedef {((value: string) => boolean)} FilterItemTypeFn */
547
+
548
+ /** @type {SimpleExtractors} */
549
+ const SIMPLE_EXTRACTORS = {
550
+ compilation: {
551
+ _: (object, compilation, context, options) => {
552
+ if (!context.makePathsRelative) {
553
+ context.makePathsRelative = makePathsRelative.bindContextCache(
554
+ compilation.compiler.context,
555
+ compilation.compiler.root
556
+ );
557
+ }
558
+ if (!context.cachedGetErrors) {
559
+ /** @type {WeakMap<Compilation, Error[]>} */
560
+ const map = new WeakMap();
561
+ context.cachedGetErrors = (compilation) =>
562
+ map.get(compilation) ||
563
+ // eslint-disable-next-line no-sequences
564
+ ((errors) => (map.set(compilation, errors), errors))(
565
+ compilation.getErrors()
566
+ );
567
+ }
568
+ if (!context.cachedGetWarnings) {
569
+ /** @type {WeakMap<Compilation, Error[]>} */
570
+ const map = new WeakMap();
571
+ context.cachedGetWarnings = (compilation) =>
572
+ map.get(compilation) ||
573
+ // eslint-disable-next-line no-sequences
574
+ ((warnings) => (map.set(compilation, warnings), warnings))(
575
+ compilation.getWarnings()
576
+ );
577
+ }
578
+ if (compilation.name) {
579
+ object.name = compilation.name;
580
+ }
581
+ if (compilation.needAdditionalPass) {
582
+ object.needAdditionalPass = true;
583
+ }
584
+
585
+ const { logging, loggingDebug, loggingTrace } = options;
586
+ if (logging || (loggingDebug && loggingDebug.length > 0)) {
587
+ const util = require("util");
588
+
589
+ object.logging = {};
590
+ /** @type {Set<keyof LogType>} */
591
+ let acceptedTypes;
592
+ let collapsedGroups = false;
593
+ switch (logging) {
594
+ case "error":
595
+ acceptedTypes = new Set([LogType.error]);
596
+ break;
597
+ case "warn":
598
+ acceptedTypes = new Set([LogType.error, LogType.warn]);
599
+ break;
600
+ case "info":
601
+ acceptedTypes = new Set([
602
+ LogType.error,
603
+ LogType.warn,
604
+ LogType.info
605
+ ]);
606
+ break;
607
+ case "log":
608
+ acceptedTypes = new Set([
609
+ LogType.error,
610
+ LogType.warn,
611
+ LogType.info,
612
+ LogType.log,
613
+ LogType.group,
614
+ LogType.groupEnd,
615
+ LogType.groupCollapsed,
616
+ LogType.clear
617
+ ]);
618
+ break;
619
+ case "verbose":
620
+ acceptedTypes = new Set([
621
+ LogType.error,
622
+ LogType.warn,
623
+ LogType.info,
624
+ LogType.log,
625
+ LogType.group,
626
+ LogType.groupEnd,
627
+ LogType.groupCollapsed,
628
+ LogType.profile,
629
+ LogType.profileEnd,
630
+ LogType.time,
631
+ LogType.status,
632
+ LogType.clear
633
+ ]);
634
+ collapsedGroups = true;
635
+ break;
636
+ default:
637
+ acceptedTypes = new Set();
638
+ break;
639
+ }
640
+ const cachedMakePathsRelative = makePathsRelative.bindContextCache(
641
+ options.context,
642
+ compilation.compiler.root
643
+ );
644
+ let depthInCollapsedGroup = 0;
645
+ for (const [origin, logEntries] of compilation.logging) {
646
+ const debugMode = loggingDebug.some((fn) => fn(origin));
647
+ if (logging === false && !debugMode) continue;
648
+ /** @type {KnownStatsLoggingEntry[]} */
649
+ const groupStack = [];
650
+ /** @type {KnownStatsLoggingEntry[]} */
651
+ const rootList = [];
652
+ let currentList = rootList;
653
+ let processedLogEntries = 0;
654
+ for (const entry of logEntries) {
655
+ let type = entry.type;
656
+ if (!debugMode && !acceptedTypes.has(type)) continue;
657
+
658
+ // Expand groups in verbose and debug modes
659
+ if (
660
+ type === LogType.groupCollapsed &&
661
+ (debugMode || collapsedGroups)
662
+ ) {
663
+ type = LogType.group;
664
+ }
665
+
666
+ if (depthInCollapsedGroup === 0) {
667
+ processedLogEntries++;
668
+ }
669
+
670
+ if (type === LogType.groupEnd) {
671
+ groupStack.pop();
672
+ currentList =
673
+ groupStack.length > 0
674
+ ? /** @type {KnownStatsLoggingEntry[]} */ (
675
+ groupStack[groupStack.length - 1].children
676
+ )
677
+ : rootList;
678
+ if (depthInCollapsedGroup > 0) depthInCollapsedGroup--;
679
+ continue;
680
+ }
681
+ /** @type {undefined | string} */
682
+ let message;
683
+ if (entry.type === LogType.time) {
684
+ const [label, first, second] =
685
+ /** @type {[string, number, number]} */
686
+ (entry.args);
687
+ message = `${label}: ${first * 1000 + second / 1000000} ms`;
688
+ } else if (entry.args && entry.args.length > 0) {
689
+ message = util.format(entry.args[0], ...entry.args.slice(1));
690
+ }
691
+ /** @type {KnownStatsLoggingEntry} */
692
+ const newEntry = {
693
+ ...entry,
694
+ type,
695
+ message,
696
+ trace: loggingTrace ? entry.trace : undefined,
697
+ children:
698
+ type === LogType.group || type === LogType.groupCollapsed
699
+ ? []
700
+ : undefined
701
+ };
702
+ currentList.push(newEntry);
703
+ if (newEntry.children) {
704
+ groupStack.push(newEntry);
705
+ currentList = newEntry.children;
706
+ if (depthInCollapsedGroup > 0) {
707
+ depthInCollapsedGroup++;
708
+ } else if (type === LogType.groupCollapsed) {
709
+ depthInCollapsedGroup = 1;
710
+ }
711
+ }
712
+ }
713
+ let name = cachedMakePathsRelative(origin).replace(/\|/g, " ");
714
+ if (name in object.logging) {
715
+ let i = 1;
716
+ while (`${name}#${i}` in object.logging) {
717
+ i++;
718
+ }
719
+ name = `${name}#${i}`;
720
+ }
721
+ object.logging[name] = {
722
+ entries: rootList,
723
+ filteredEntries: logEntries.length - processedLogEntries,
724
+ debug: debugMode
725
+ };
726
+ }
727
+ }
728
+ },
729
+ hash: (object, compilation) => {
730
+ object.hash = compilation.hash;
731
+ },
732
+ version: (object) => {
733
+ object.version = require("../../package.json").version;
734
+ },
735
+ env: (object, compilation, context, { _env }) => {
736
+ object.env = _env;
737
+ },
738
+ timings: (object, compilation) => {
739
+ object.time =
740
+ /** @type {number} */ (compilation.endTime) -
741
+ /** @type {number} */ (compilation.startTime);
742
+ },
743
+ builtAt: (object, compilation) => {
744
+ object.builtAt = /** @type {number} */ (compilation.endTime);
745
+ },
746
+ publicPath: (object, compilation) => {
747
+ object.publicPath = compilation.getPath(
748
+ compilation.outputOptions.publicPath
749
+ );
750
+ },
751
+ outputPath: (object, compilation) => {
752
+ object.outputPath = compilation.outputOptions.path;
753
+ },
754
+ assets: (object, compilation, context, options, factory) => {
755
+ const { type } = context;
756
+ /** @type {Map<string, Chunk[]>} */
757
+ const compilationFileToChunks = new Map();
758
+ /** @type {Map<string, Chunk[]>} */
759
+ const compilationAuxiliaryFileToChunks = new Map();
760
+ for (const chunk of compilation.chunks) {
761
+ for (const file of chunk.files) {
762
+ let array = compilationFileToChunks.get(file);
763
+ if (array === undefined) {
764
+ array = [];
765
+ compilationFileToChunks.set(file, array);
766
+ }
767
+ array.push(chunk);
768
+ }
769
+ for (const file of chunk.auxiliaryFiles) {
770
+ let array = compilationAuxiliaryFileToChunks.get(file);
771
+ if (array === undefined) {
772
+ array = [];
773
+ compilationAuxiliaryFileToChunks.set(file, array);
774
+ }
775
+ array.push(chunk);
776
+ }
777
+ }
778
+ /** @type {Map<string, PreprocessedAsset>} */
779
+ const assetMap = new Map();
780
+ /** @type {Set<PreprocessedAsset>} */
781
+ const assets = new Set();
782
+ for (const asset of compilation.getAssets()) {
783
+ /** @type {PreprocessedAsset} */
784
+ const item = {
785
+ ...asset,
786
+ type: "asset",
787
+ related: undefined
788
+ };
789
+ assets.add(item);
790
+ assetMap.set(asset.name, item);
791
+ }
792
+ for (const item of assetMap.values()) {
793
+ const related = item.info.related;
794
+ if (!related) continue;
795
+ for (const type of Object.keys(related)) {
796
+ const relatedEntry = related[type];
797
+ const deps = Array.isArray(relatedEntry)
798
+ ? relatedEntry
799
+ : [relatedEntry];
800
+ for (const dep of deps) {
801
+ if (!dep) continue;
802
+ const depItem = assetMap.get(dep);
803
+ if (!depItem) continue;
804
+ assets.delete(depItem);
805
+ depItem.type = type;
806
+ item.related = item.related || [];
807
+ item.related.push(depItem);
808
+ }
809
+ }
810
+ }
811
+
812
+ object.assetsByChunkName = {};
813
+ for (const [file, chunks] of [
814
+ ...compilationFileToChunks,
815
+ ...compilationAuxiliaryFileToChunks
816
+ ]) {
817
+ for (const chunk of chunks) {
818
+ const name = chunk.name;
819
+ if (!name) continue;
820
+ if (
821
+ !Object.prototype.hasOwnProperty.call(
822
+ object.assetsByChunkName,
823
+ name
824
+ )
825
+ ) {
826
+ object.assetsByChunkName[name] = [];
827
+ }
828
+ object.assetsByChunkName[name].push(file);
829
+ }
830
+ }
831
+
832
+ const groupedAssets = factory.create(`${type}.assets`, [...assets], {
833
+ ...context,
834
+ compilationFileToChunks,
835
+ compilationAuxiliaryFileToChunks
836
+ });
837
+ const limited = spaceLimited(
838
+ groupedAssets,
839
+ /** @type {number} */ (options.assetsSpace)
840
+ );
841
+ object.assets = limited.children;
842
+ object.filteredAssets = limited.filteredChildren;
843
+ },
844
+ chunks: (object, compilation, context, options, factory) => {
845
+ const { type } = context;
846
+ object.chunks = factory.create(
847
+ `${type}.chunks`,
848
+ [...compilation.chunks],
849
+ context
850
+ );
851
+ },
852
+ modules: (object, compilation, context, options, factory) => {
853
+ const { type } = context;
854
+ const array = [...compilation.modules];
855
+ const groupedModules = factory.create(`${type}.modules`, array, context);
856
+ const limited = spaceLimited(groupedModules, options.modulesSpace);
857
+ object.modules = limited.children;
858
+ object.filteredModules = limited.filteredChildren;
859
+ },
860
+ entrypoints: (
861
+ object,
862
+ compilation,
863
+ context,
864
+ { entrypoints, chunkGroups, chunkGroupAuxiliary, chunkGroupChildren },
865
+ factory
866
+ ) => {
867
+ const { type } = context;
868
+ /** @type {ChunkGroupInfoWithName[]} */
869
+ const array = Array.from(compilation.entrypoints, ([key, value]) => ({
870
+ name: key,
871
+ chunkGroup: value
872
+ }));
873
+ if (entrypoints === "auto" && !chunkGroups) {
874
+ if (array.length > 5) return;
875
+ if (
876
+ !chunkGroupChildren &&
877
+ array.every(({ chunkGroup }) => {
878
+ if (chunkGroup.chunks.length !== 1) return false;
879
+ const chunk = chunkGroup.chunks[0];
880
+ return (
881
+ chunk.files.size === 1 &&
882
+ (!chunkGroupAuxiliary || chunk.auxiliaryFiles.size === 0)
883
+ );
884
+ })
885
+ ) {
886
+ return;
887
+ }
888
+ }
889
+ object.entrypoints = factory.create(
890
+ `${type}.entrypoints`,
891
+ array,
892
+ context
893
+ );
894
+ },
895
+ chunkGroups: (object, compilation, context, options, factory) => {
896
+ const { type } = context;
897
+ const array = Array.from(
898
+ compilation.namedChunkGroups,
899
+ ([key, value]) => ({
900
+ name: key,
901
+ chunkGroup: value
902
+ })
903
+ );
904
+ object.namedChunkGroups = factory.create(
905
+ `${type}.namedChunkGroups`,
906
+ array,
907
+ context
908
+ );
909
+ },
910
+ errors: (object, compilation, context, options, factory) => {
911
+ const { type, cachedGetErrors } = context;
912
+ const rawErrors = cachedGetErrors(compilation);
913
+ const factorizedErrors = factory.create(
914
+ `${type}.errors`,
915
+ cachedGetErrors(compilation),
916
+ context
917
+ );
918
+ let filtered = 0;
919
+ if (options.errorDetails === "auto" && rawErrors.length >= 3) {
920
+ filtered = rawErrors
921
+ .map(
922
+ (e) =>
923
+ typeof e !== "string" && /** @type {WebpackError} */ (e).details
924
+ )
925
+ .filter(Boolean).length;
926
+ }
927
+ if (
928
+ options.errorDetails === true ||
929
+ !Number.isFinite(options.errorsSpace)
930
+ ) {
931
+ object.errors = factorizedErrors;
932
+ if (filtered) object.filteredErrorDetailsCount = filtered;
933
+ return;
934
+ }
935
+ const [errors, filteredBySpace] = errorsSpaceLimit(
936
+ factorizedErrors,
937
+ /** @type {number} */
938
+ (options.errorsSpace)
939
+ );
940
+ object.filteredErrorDetailsCount = filtered + filteredBySpace;
941
+ object.errors = errors;
942
+ },
943
+ errorsCount: (object, compilation, { cachedGetErrors }) => {
944
+ object.errorsCount = countWithChildren(compilation, (c) =>
945
+ cachedGetErrors(c)
946
+ );
947
+ },
948
+ warnings: (object, compilation, context, options, factory) => {
949
+ const { type, cachedGetWarnings } = context;
950
+ const rawWarnings = factory.create(
951
+ `${type}.warnings`,
952
+ cachedGetWarnings(compilation),
953
+ context
954
+ );
955
+ let filtered = 0;
956
+ if (options.errorDetails === "auto") {
957
+ filtered = cachedGetWarnings(compilation)
958
+ .map(
959
+ (e) =>
960
+ typeof e !== "string" && /** @type {WebpackError} */ (e).details
961
+ )
962
+ .filter(Boolean).length;
963
+ }
964
+ if (
965
+ options.errorDetails === true ||
966
+ !Number.isFinite(options.warningsSpace)
967
+ ) {
968
+ object.warnings = rawWarnings;
969
+ if (filtered) object.filteredWarningDetailsCount = filtered;
970
+ return;
971
+ }
972
+ const [warnings, filteredBySpace] = errorsSpaceLimit(
973
+ rawWarnings,
974
+ /** @type {number} */
975
+ (options.warningsSpace)
976
+ );
977
+ object.filteredWarningDetailsCount = filtered + filteredBySpace;
978
+ object.warnings = warnings;
979
+ },
980
+ warningsCount: (
981
+ object,
982
+ compilation,
983
+ context,
984
+ { warningsFilter },
985
+ factory
986
+ ) => {
987
+ const { type, cachedGetWarnings } = context;
988
+ object.warningsCount = countWithChildren(compilation, (c, childType) => {
989
+ if (
990
+ !warningsFilter &&
991
+ /** @type {KnownNormalizedStatsOptions["warningsFilter"]} */
992
+ (warningsFilter).length === 0
993
+ ) {
994
+ // Type is wrong, because we don't need the real value for counting
995
+ return /** @type {EXPECTED_ANY[]} */ (cachedGetWarnings(c));
996
+ }
997
+ return factory
998
+ .create(`${type}${childType}.warnings`, cachedGetWarnings(c), context)
999
+ .filter(
1000
+ /**
1001
+ * @param {StatsError} warning warning
1002
+ * @returns {boolean} result
1003
+ */
1004
+ (warning) => {
1005
+ const warningString = Object.keys(warning)
1006
+ .map(
1007
+ (key) =>
1008
+ `${warning[/** @type {keyof KnownStatsError} */ (key)]}`
1009
+ )
1010
+ .join("\n");
1011
+ return !warningsFilter.some((filter) =>
1012
+ filter(warning, warningString)
1013
+ );
1014
+ }
1015
+ );
1016
+ });
1017
+ },
1018
+ children: (object, compilation, context, options, factory) => {
1019
+ const { type } = context;
1020
+ object.children = factory.create(
1021
+ `${type}.children`,
1022
+ compilation.children,
1023
+ context
1024
+ );
1025
+ }
1026
+ },
1027
+ asset: {
1028
+ _: (object, asset, context, options, factory) => {
1029
+ const { compilation } = context;
1030
+ object.type = asset.type;
1031
+ object.name = asset.name;
1032
+ object.size = asset.source.size();
1033
+ object.emitted = compilation.emittedAssets.has(asset.name);
1034
+ object.comparedForEmit = compilation.comparedForEmitAssets.has(
1035
+ asset.name
1036
+ );
1037
+ const cached = !object.emitted && !object.comparedForEmit;
1038
+ object.cached = cached;
1039
+ object.info = asset.info;
1040
+ if (!cached || options.cachedAssets) {
1041
+ Object.assign(
1042
+ object,
1043
+ factory.create(`${context.type}$visible`, asset, context)
1044
+ );
1045
+ }
1046
+ }
1047
+ },
1048
+ asset$visible: {
1049
+ _: (
1050
+ object,
1051
+ asset,
1052
+ { compilationFileToChunks, compilationAuxiliaryFileToChunks }
1053
+ ) => {
1054
+ const chunks = compilationFileToChunks.get(asset.name) || [];
1055
+ const auxiliaryChunks =
1056
+ compilationAuxiliaryFileToChunks.get(asset.name) || [];
1057
+ object.chunkNames = uniqueOrderedArray(
1058
+ chunks,
1059
+ (c) => (c.name ? [c.name] : []),
1060
+ compareIds
1061
+ );
1062
+ object.chunkIdHints = uniqueOrderedArray(
1063
+ chunks,
1064
+ (c) => [...c.idNameHints],
1065
+ compareIds
1066
+ );
1067
+ object.auxiliaryChunkNames = uniqueOrderedArray(
1068
+ auxiliaryChunks,
1069
+ (c) => (c.name ? [c.name] : []),
1070
+ compareIds
1071
+ );
1072
+ object.auxiliaryChunkIdHints = uniqueOrderedArray(
1073
+ auxiliaryChunks,
1074
+ (c) => [...c.idNameHints],
1075
+ compareIds
1076
+ );
1077
+ object.filteredRelated = asset.related ? asset.related.length : undefined;
1078
+ },
1079
+ relatedAssets: (object, asset, context, options, factory) => {
1080
+ const { type } = context;
1081
+ object.related = factory.create(
1082
+ `${type.slice(0, -8)}.related`,
1083
+ asset.related || [],
1084
+ context
1085
+ );
1086
+ object.filteredRelated = asset.related
1087
+ ? asset.related.length -
1088
+ /** @type {StatsAsset[]} */ (object.related).length
1089
+ : undefined;
1090
+ },
1091
+ ids: (
1092
+ object,
1093
+ asset,
1094
+ { compilationFileToChunks, compilationAuxiliaryFileToChunks }
1095
+ ) => {
1096
+ const chunks = compilationFileToChunks.get(asset.name) || [];
1097
+ const auxiliaryChunks =
1098
+ compilationAuxiliaryFileToChunks.get(asset.name) || [];
1099
+ object.chunks = uniqueOrderedArray(
1100
+ chunks,
1101
+ (c) => /** @type {ChunkId[]} */ (c.ids),
1102
+ compareIds
1103
+ );
1104
+ object.auxiliaryChunks = uniqueOrderedArray(
1105
+ auxiliaryChunks,
1106
+ (c) => /** @type {ChunkId[]} */ (c.ids),
1107
+ compareIds
1108
+ );
1109
+ },
1110
+ performance: (object, asset) => {
1111
+ object.isOverSizeLimit = SizeLimitsPlugin.isOverSizeLimit(asset.source);
1112
+ }
1113
+ },
1114
+ chunkGroup: {
1115
+ _: (
1116
+ object,
1117
+ { name, chunkGroup },
1118
+ { compilation, compilation: { moduleGraph, chunkGraph } },
1119
+ { ids, chunkGroupAuxiliary, chunkGroupChildren, chunkGroupMaxAssets }
1120
+ ) => {
1121
+ const children =
1122
+ chunkGroupChildren &&
1123
+ chunkGroup.getChildrenByOrders(moduleGraph, chunkGraph);
1124
+ /**
1125
+ * @param {string} name Name
1126
+ * @returns {{ name: string, size: number }} Asset object
1127
+ */
1128
+ const toAsset = (name) => {
1129
+ const asset = compilation.getAsset(name);
1130
+ return {
1131
+ name,
1132
+ size: /** @type {number} */ (asset ? asset.info.size : -1)
1133
+ };
1134
+ };
1135
+ /** @type {(total: number, asset: { size: number }) => number} */
1136
+ const sizeReducer = (total, { size }) => total + size;
1137
+ const assets = uniqueArray(chunkGroup.chunks, (c) => c.files).map(
1138
+ toAsset
1139
+ );
1140
+ const auxiliaryAssets = uniqueOrderedArray(
1141
+ chunkGroup.chunks,
1142
+ (c) => c.auxiliaryFiles,
1143
+ compareIds
1144
+ ).map(toAsset);
1145
+ const assetsSize = assets.reduce(sizeReducer, 0);
1146
+ const auxiliaryAssetsSize = auxiliaryAssets.reduce(sizeReducer, 0);
1147
+ /** @type {KnownStatsChunkGroup} */
1148
+ const statsChunkGroup = {
1149
+ name,
1150
+ chunks: ids
1151
+ ? /** @type {ChunkId[]} */ (chunkGroup.chunks.map((c) => c.id))
1152
+ : undefined,
1153
+ assets: assets.length <= chunkGroupMaxAssets ? assets : undefined,
1154
+ filteredAssets:
1155
+ assets.length <= chunkGroupMaxAssets ? 0 : assets.length,
1156
+ assetsSize,
1157
+ auxiliaryAssets:
1158
+ chunkGroupAuxiliary && auxiliaryAssets.length <= chunkGroupMaxAssets
1159
+ ? auxiliaryAssets
1160
+ : undefined,
1161
+ filteredAuxiliaryAssets:
1162
+ chunkGroupAuxiliary && auxiliaryAssets.length <= chunkGroupMaxAssets
1163
+ ? 0
1164
+ : auxiliaryAssets.length,
1165
+ auxiliaryAssetsSize,
1166
+ children: children
1167
+ ? mapObject(children, (groups) =>
1168
+ groups.map((group) => {
1169
+ const assets = uniqueArray(group.chunks, (c) => c.files).map(
1170
+ toAsset
1171
+ );
1172
+ const auxiliaryAssets = uniqueOrderedArray(
1173
+ group.chunks,
1174
+ (c) => c.auxiliaryFiles,
1175
+ compareIds
1176
+ ).map(toAsset);
1177
+
1178
+ /** @type {KnownStatsChunkGroup} */
1179
+ const childStatsChunkGroup = {
1180
+ name: group.name,
1181
+ chunks: ids
1182
+ ? /** @type {ChunkId[]} */
1183
+ (group.chunks.map((c) => c.id))
1184
+ : undefined,
1185
+ assets:
1186
+ assets.length <= chunkGroupMaxAssets ? assets : undefined,
1187
+ filteredAssets:
1188
+ assets.length <= chunkGroupMaxAssets ? 0 : assets.length,
1189
+ auxiliaryAssets:
1190
+ chunkGroupAuxiliary &&
1191
+ auxiliaryAssets.length <= chunkGroupMaxAssets
1192
+ ? auxiliaryAssets
1193
+ : undefined,
1194
+ filteredAuxiliaryAssets:
1195
+ chunkGroupAuxiliary &&
1196
+ auxiliaryAssets.length <= chunkGroupMaxAssets
1197
+ ? 0
1198
+ : auxiliaryAssets.length
1199
+ };
1200
+
1201
+ return childStatsChunkGroup;
1202
+ })
1203
+ )
1204
+ : undefined,
1205
+ childAssets: children
1206
+ ? mapObject(children, (groups) => {
1207
+ /** @type {Set<string>} */
1208
+ const set = new Set();
1209
+ for (const group of groups) {
1210
+ for (const chunk of group.chunks) {
1211
+ for (const asset of chunk.files) {
1212
+ set.add(asset);
1213
+ }
1214
+ }
1215
+ }
1216
+ return [...set];
1217
+ })
1218
+ : undefined
1219
+ };
1220
+ Object.assign(object, statsChunkGroup);
1221
+ },
1222
+ performance: (object, { chunkGroup }) => {
1223
+ object.isOverSizeLimit = SizeLimitsPlugin.isOverSizeLimit(chunkGroup);
1224
+ }
1225
+ },
1226
+ module: {
1227
+ _: (object, module, context, options, factory) => {
1228
+ const { type } = context;
1229
+ const compilation = /** @type {Compilation} */ (context.compilation);
1230
+ const built = compilation.builtModules.has(module);
1231
+ const codeGenerated = compilation.codeGeneratedModules.has(module);
1232
+ const buildTimeExecuted =
1233
+ compilation.buildTimeExecutedModules.has(module);
1234
+ /** @type {{ [x: string]: number }} */
1235
+ const sizes = {};
1236
+ for (const sourceType of module.getSourceTypes()) {
1237
+ sizes[sourceType] = module.size(sourceType);
1238
+ }
1239
+ /** @type {KnownStatsModule} */
1240
+ const statsModule = {
1241
+ type: "module",
1242
+ moduleType: module.type,
1243
+ layer: module.layer,
1244
+ size: module.size(),
1245
+ sizes,
1246
+ built,
1247
+ codeGenerated,
1248
+ buildTimeExecuted,
1249
+ cached: !built && !codeGenerated
1250
+ };
1251
+ Object.assign(object, statsModule);
1252
+ if (built || codeGenerated || options.cachedModules) {
1253
+ Object.assign(
1254
+ object,
1255
+ factory.create(`${type}$visible`, module, context)
1256
+ );
1257
+ }
1258
+ }
1259
+ },
1260
+ module$visible: {
1261
+ _: (object, module, context, { requestShortener }, factory) => {
1262
+ const { type, rootModules } = context;
1263
+ const compilation = /** @type {Compilation} */ (context.compilation);
1264
+ const { moduleGraph } = compilation;
1265
+ /** @type {ModuleIssuerPath} */
1266
+ const path = [];
1267
+ const issuer = moduleGraph.getIssuer(module);
1268
+ let current = issuer;
1269
+ while (current) {
1270
+ path.push(current);
1271
+ current = moduleGraph.getIssuer(current);
1272
+ }
1273
+ path.reverse();
1274
+ const profile = moduleGraph.getProfile(module);
1275
+ const errors = module.getErrors();
1276
+ const errorsCount = errors !== undefined ? countIterable(errors) : 0;
1277
+ const warnings = module.getWarnings();
1278
+ const warningsCount =
1279
+ warnings !== undefined ? countIterable(warnings) : 0;
1280
+ /** @type {KnownStatsModule} */
1281
+ const statsModule = {
1282
+ identifier: module.identifier(),
1283
+ name: module.readableIdentifier(requestShortener),
1284
+ nameForCondition: module.nameForCondition(),
1285
+ index: /** @type {number} */ (moduleGraph.getPreOrderIndex(module)),
1286
+ preOrderIndex: /** @type {number} */ (
1287
+ moduleGraph.getPreOrderIndex(module)
1288
+ ),
1289
+ index2: /** @type {number} */ (moduleGraph.getPostOrderIndex(module)),
1290
+ postOrderIndex: /** @type {number} */ (
1291
+ moduleGraph.getPostOrderIndex(module)
1292
+ ),
1293
+ cacheable: /** @type {BuildInfo} */ (module.buildInfo).cacheable,
1294
+ optional: module.isOptional(moduleGraph),
1295
+ orphan:
1296
+ !type.endsWith("module.modules[].module$visible") &&
1297
+ compilation.chunkGraph.getNumberOfModuleChunks(module) === 0,
1298
+ dependent: rootModules ? !rootModules.has(module) : undefined,
1299
+ issuer: issuer && issuer.identifier(),
1300
+ issuerName: issuer && issuer.readableIdentifier(requestShortener),
1301
+ issuerPath:
1302
+ issuer &&
1303
+ /** @type {StatsModuleIssuer[] | undefined} */
1304
+ (factory.create(`${type.slice(0, -8)}.issuerPath`, path, context)),
1305
+ failed: errorsCount > 0,
1306
+ errors: errorsCount,
1307
+ warnings: warningsCount
1308
+ };
1309
+ Object.assign(object, statsModule);
1310
+ if (profile) {
1311
+ object.profile = factory.create(
1312
+ `${type.slice(0, -8)}.profile`,
1313
+ profile,
1314
+ context
1315
+ );
1316
+ }
1317
+ },
1318
+ ids: (object, module, { compilation: { chunkGraph, moduleGraph } }) => {
1319
+ object.id = /** @type {ModuleId} */ (chunkGraph.getModuleId(module));
1320
+ const issuer = moduleGraph.getIssuer(module);
1321
+ object.issuerId = issuer && chunkGraph.getModuleId(issuer);
1322
+ object.chunks =
1323
+ /** @type {ChunkId[]} */
1324
+ (
1325
+ Array.from(
1326
+ chunkGraph.getOrderedModuleChunksIterable(
1327
+ module,
1328
+ compareChunksById
1329
+ ),
1330
+ (chunk) => chunk.id
1331
+ )
1332
+ );
1333
+ },
1334
+ moduleAssets: (object, module) => {
1335
+ object.assets = /** @type {BuildInfo} */ (module.buildInfo).assets
1336
+ ? Object.keys(/** @type {BuildInfo} */ (module.buildInfo).assets)
1337
+ : [];
1338
+ },
1339
+ reasons: (object, module, context, options, factory) => {
1340
+ const {
1341
+ type,
1342
+ compilation: { moduleGraph }
1343
+ } = context;
1344
+ const groupsReasons = factory.create(
1345
+ `${type.slice(0, -8)}.reasons`,
1346
+ [...moduleGraph.getIncomingConnections(module)],
1347
+ context
1348
+ );
1349
+ const limited = spaceLimited(
1350
+ groupsReasons,
1351
+ /** @type {number} */
1352
+ (options.reasonsSpace)
1353
+ );
1354
+ object.reasons = limited.children;
1355
+ object.filteredReasons = limited.filteredChildren;
1356
+ },
1357
+ usedExports: (
1358
+ object,
1359
+ module,
1360
+ { runtime, compilation: { moduleGraph } }
1361
+ ) => {
1362
+ const usedExports = moduleGraph.getUsedExports(module, runtime);
1363
+ if (usedExports === null) {
1364
+ object.usedExports = null;
1365
+ } else if (typeof usedExports === "boolean") {
1366
+ object.usedExports = usedExports;
1367
+ } else {
1368
+ object.usedExports = [...usedExports];
1369
+ }
1370
+ },
1371
+ providedExports: (object, module, { compilation: { moduleGraph } }) => {
1372
+ const providedExports = moduleGraph.getProvidedExports(module);
1373
+ object.providedExports = Array.isArray(providedExports)
1374
+ ? providedExports
1375
+ : null;
1376
+ },
1377
+ optimizationBailout: (
1378
+ object,
1379
+ module,
1380
+ { compilation: { moduleGraph } },
1381
+ { requestShortener }
1382
+ ) => {
1383
+ object.optimizationBailout = moduleGraph
1384
+ .getOptimizationBailout(module)
1385
+ .map((item) => {
1386
+ if (typeof item === "function") return item(requestShortener);
1387
+ return item;
1388
+ });
1389
+ },
1390
+ depth: (object, module, { compilation: { moduleGraph } }) => {
1391
+ object.depth = moduleGraph.getDepth(module);
1392
+ },
1393
+ nestedModules: (object, module, context, options, factory) => {
1394
+ const { type } = context;
1395
+ const innerModules = /** @type {Module & { modules?: Module[] }} */ (
1396
+ module
1397
+ ).modules;
1398
+ if (Array.isArray(innerModules)) {
1399
+ const groupedModules = factory.create(
1400
+ `${type.slice(0, -8)}.modules`,
1401
+ innerModules,
1402
+ context
1403
+ );
1404
+ const limited = spaceLimited(
1405
+ groupedModules,
1406
+ options.nestedModulesSpace
1407
+ );
1408
+ object.modules = limited.children;
1409
+ object.filteredModules = limited.filteredChildren;
1410
+ }
1411
+ },
1412
+ source: (object, module) => {
1413
+ const originalSource = module.originalSource();
1414
+ if (originalSource) {
1415
+ object.source = originalSource.source();
1416
+ }
1417
+ }
1418
+ },
1419
+ profile: {
1420
+ _: (object, profile) => {
1421
+ /** @type {KnownStatsProfile} */
1422
+ const statsProfile = {
1423
+ total:
1424
+ profile.factory +
1425
+ profile.restoring +
1426
+ profile.integration +
1427
+ profile.building +
1428
+ profile.storing,
1429
+ resolving: profile.factory,
1430
+ restoring: profile.restoring,
1431
+ building: profile.building,
1432
+ integration: profile.integration,
1433
+ storing: profile.storing,
1434
+ additionalResolving: profile.additionalFactories,
1435
+ additionalIntegration: profile.additionalIntegration,
1436
+ // TODO remove this in webpack 6
1437
+ factory: profile.factory,
1438
+ // TODO remove this in webpack 6
1439
+ dependencies: profile.additionalFactories
1440
+ };
1441
+ Object.assign(object, statsProfile);
1442
+ }
1443
+ },
1444
+ moduleIssuer: {
1445
+ _: (object, module, context, { requestShortener }, factory) => {
1446
+ const { type } = context;
1447
+ const compilation = /** @type {Compilation} */ (context.compilation);
1448
+ const { moduleGraph } = compilation;
1449
+ const profile = moduleGraph.getProfile(module);
1450
+ /** @type {Partial<KnownStatsModuleIssuer>} */
1451
+ const statsModuleIssuer = {
1452
+ identifier: module.identifier(),
1453
+ name: module.readableIdentifier(requestShortener)
1454
+ };
1455
+ Object.assign(object, statsModuleIssuer);
1456
+ if (profile) {
1457
+ object.profile = factory.create(`${type}.profile`, profile, context);
1458
+ }
1459
+ },
1460
+ ids: (object, module, { compilation: { chunkGraph } }) => {
1461
+ object.id = /** @type {ModuleId} */ (chunkGraph.getModuleId(module));
1462
+ }
1463
+ },
1464
+ moduleReason: {
1465
+ _: (object, reason, { runtime }, { requestShortener }) => {
1466
+ const dep = reason.dependency;
1467
+ const moduleDep =
1468
+ dep && dep instanceof ModuleDependency ? dep : undefined;
1469
+ /** @type {KnownStatsModuleReason} */
1470
+ const statsModuleReason = {
1471
+ moduleIdentifier: reason.originModule
1472
+ ? reason.originModule.identifier()
1473
+ : null,
1474
+ module: reason.originModule
1475
+ ? reason.originModule.readableIdentifier(requestShortener)
1476
+ : null,
1477
+ moduleName: reason.originModule
1478
+ ? reason.originModule.readableIdentifier(requestShortener)
1479
+ : null,
1480
+ resolvedModuleIdentifier: reason.resolvedOriginModule
1481
+ ? reason.resolvedOriginModule.identifier()
1482
+ : null,
1483
+ resolvedModule: reason.resolvedOriginModule
1484
+ ? reason.resolvedOriginModule.readableIdentifier(requestShortener)
1485
+ : null,
1486
+ type: reason.dependency ? reason.dependency.type : null,
1487
+ active: reason.isActive(runtime),
1488
+ explanation: reason.explanation,
1489
+ userRequest: (moduleDep && moduleDep.userRequest) || null
1490
+ };
1491
+ Object.assign(object, statsModuleReason);
1492
+ if (reason.dependency) {
1493
+ const locInfo = formatLocation(reason.dependency.loc);
1494
+ if (locInfo) {
1495
+ object.loc = locInfo;
1496
+ }
1497
+ }
1498
+ },
1499
+ ids: (object, reason, { compilation: { chunkGraph } }) => {
1500
+ object.moduleId = reason.originModule
1501
+ ? chunkGraph.getModuleId(reason.originModule)
1502
+ : null;
1503
+ object.resolvedModuleId = reason.resolvedOriginModule
1504
+ ? chunkGraph.getModuleId(reason.resolvedOriginModule)
1505
+ : null;
1506
+ }
1507
+ },
1508
+ chunk: {
1509
+ _: (object, chunk, { makePathsRelative, compilation: { chunkGraph } }) => {
1510
+ const childIdByOrder = chunk.getChildIdsByOrders(chunkGraph);
1511
+
1512
+ /** @type {KnownStatsChunk} */
1513
+ const statsChunk = {
1514
+ rendered: chunk.rendered,
1515
+ initial: chunk.canBeInitial(),
1516
+ entry: chunk.hasRuntime(),
1517
+ recorded: AggressiveSplittingPlugin.wasChunkRecorded(chunk),
1518
+ reason: chunk.chunkReason,
1519
+ size: chunkGraph.getChunkModulesSize(chunk),
1520
+ sizes: chunkGraph.getChunkModulesSizes(chunk),
1521
+ names: chunk.name ? [chunk.name] : [],
1522
+ idHints: [...chunk.idNameHints],
1523
+ runtime:
1524
+ chunk.runtime === undefined
1525
+ ? undefined
1526
+ : typeof chunk.runtime === "string"
1527
+ ? [makePathsRelative(chunk.runtime)]
1528
+ : Array.from(chunk.runtime.sort(), makePathsRelative),
1529
+ files: [...chunk.files],
1530
+ auxiliaryFiles: [...chunk.auxiliaryFiles].sort(compareIds),
1531
+ hash: /** @type {string} */ (chunk.renderedHash),
1532
+ childrenByOrder: childIdByOrder
1533
+ };
1534
+ Object.assign(object, statsChunk);
1535
+ },
1536
+ ids: (object, chunk) => {
1537
+ object.id = /** @type {ChunkId} */ (chunk.id);
1538
+ },
1539
+ chunkRelations: (object, chunk, _context) => {
1540
+ /** @typedef {Set<ChunkId>} ChunkRelations */
1541
+ /** @type {ChunkRelations} */
1542
+ const parents = new Set();
1543
+ /** @type {ChunkRelations} */
1544
+ const children = new Set();
1545
+ /** @type {ChunkRelations} */
1546
+ const siblings = new Set();
1547
+
1548
+ for (const chunkGroup of chunk.groupsIterable) {
1549
+ for (const parentGroup of chunkGroup.parentsIterable) {
1550
+ for (const chunk of parentGroup.chunks) {
1551
+ parents.add(/** @type {ChunkId} */ (chunk.id));
1552
+ }
1553
+ }
1554
+ for (const childGroup of chunkGroup.childrenIterable) {
1555
+ for (const chunk of childGroup.chunks) {
1556
+ children.add(/** @type {ChunkId} */ (chunk.id));
1557
+ }
1558
+ }
1559
+ for (const sibling of chunkGroup.chunks) {
1560
+ if (sibling !== chunk) {
1561
+ siblings.add(/** @type {ChunkId} */ (sibling.id));
1562
+ }
1563
+ }
1564
+ }
1565
+ object.siblings = [...siblings].sort(compareIds);
1566
+ object.parents = [...parents].sort(compareIds);
1567
+ object.children = [...children].sort(compareIds);
1568
+ },
1569
+ chunkModules: (object, chunk, context, options, factory) => {
1570
+ const {
1571
+ type,
1572
+ compilation: { chunkGraph }
1573
+ } = context;
1574
+ const array = chunkGraph.getChunkModules(chunk);
1575
+ const groupedModules = factory.create(`${type}.modules`, array, {
1576
+ ...context,
1577
+ runtime: chunk.runtime,
1578
+ rootModules: new Set(chunkGraph.getChunkRootModules(chunk))
1579
+ });
1580
+ const limited = spaceLimited(groupedModules, options.chunkModulesSpace);
1581
+ object.modules = limited.children;
1582
+ object.filteredModules = limited.filteredChildren;
1583
+ },
1584
+ chunkOrigins: (object, chunk, context, options, factory) => {
1585
+ const {
1586
+ type,
1587
+ compilation: { chunkGraph }
1588
+ } = context;
1589
+ /** @type {Set<string>} */
1590
+ const originsKeySet = new Set();
1591
+ /** @type {OriginRecord[]} */
1592
+ const origins = [];
1593
+ for (const g of chunk.groupsIterable) {
1594
+ origins.push(...g.origins);
1595
+ }
1596
+ const array = origins.filter((origin) => {
1597
+ const key = [
1598
+ origin.module ? chunkGraph.getModuleId(origin.module) : undefined,
1599
+ formatLocation(origin.loc),
1600
+ origin.request
1601
+ ].join();
1602
+ if (originsKeySet.has(key)) return false;
1603
+ originsKeySet.add(key);
1604
+ return true;
1605
+ });
1606
+ object.origins = factory.create(`${type}.origins`, array, context);
1607
+ }
1608
+ },
1609
+ chunkOrigin: {
1610
+ _: (object, origin, context, { requestShortener }) => {
1611
+ /** @type {KnownStatsChunkOrigin} */
1612
+ const statsChunkOrigin = {
1613
+ module: origin.module ? origin.module.identifier() : "",
1614
+ moduleIdentifier: origin.module ? origin.module.identifier() : "",
1615
+ moduleName: origin.module
1616
+ ? origin.module.readableIdentifier(requestShortener)
1617
+ : "",
1618
+ loc: formatLocation(origin.loc),
1619
+ request: origin.request
1620
+ };
1621
+ Object.assign(object, statsChunkOrigin);
1622
+ },
1623
+ ids: (object, origin, { compilation: { chunkGraph } }) => {
1624
+ object.moduleId = origin.module
1625
+ ? /** @type {ModuleId} */ (chunkGraph.getModuleId(origin.module))
1626
+ : undefined;
1627
+ }
1628
+ },
1629
+ error: EXTRACT_ERROR,
1630
+ warning: EXTRACT_ERROR,
1631
+ cause: EXTRACT_ERROR,
1632
+ moduleTraceItem: {
1633
+ _: (object, { origin, module }, context, { requestShortener }, factory) => {
1634
+ const {
1635
+ type,
1636
+ compilation: { moduleGraph }
1637
+ } = context;
1638
+ object.originIdentifier = origin.identifier();
1639
+ object.originName = origin.readableIdentifier(requestShortener);
1640
+ object.moduleIdentifier = module.identifier();
1641
+ object.moduleName = module.readableIdentifier(requestShortener);
1642
+ const dependencies = [...moduleGraph.getIncomingConnections(module)]
1643
+ .filter((c) => c.resolvedOriginModule === origin && c.dependency)
1644
+ .map((c) => c.dependency);
1645
+ object.dependencies = factory.create(
1646
+ `${type}.dependencies`,
1647
+ /** @type {Dependency[]} */
1648
+ ([...new Set(dependencies)]),
1649
+ context
1650
+ );
1651
+ },
1652
+ ids: (object, { origin, module }, { compilation: { chunkGraph } }) => {
1653
+ object.originId =
1654
+ /** @type {ModuleId} */
1655
+ (chunkGraph.getModuleId(origin));
1656
+ object.moduleId =
1657
+ /** @type {ModuleId} */
1658
+ (chunkGraph.getModuleId(module));
1659
+ }
1660
+ },
1661
+ moduleTraceDependency: {
1662
+ _: (object, dependency) => {
1663
+ object.loc = formatLocation(dependency.loc);
1664
+ }
1665
+ }
1666
+ };
1667
+
1668
+ /** @type {Record<string, Record<string, (thing: ModuleGraphConnection, context: StatsFactoryContext, options: NormalizedStatsOptions, idx: number, i: number) => boolean | undefined>>} */
1669
+ const FILTER = {
1670
+ "module.reasons": {
1671
+ "!orphanModules": (reason, { compilation: { chunkGraph } }) => {
1672
+ if (
1673
+ reason.originModule &&
1674
+ chunkGraph.getNumberOfModuleChunks(reason.originModule) === 0
1675
+ ) {
1676
+ return false;
1677
+ }
1678
+ }
1679
+ }
1680
+ };
1681
+
1682
+ /** @type {Record<string, Record<string, (thing: KnownStatsError, context: StatsFactoryContext, options: NormalizedStatsOptions, idx: number, i: number) => boolean | undefined>>} */
1683
+ const FILTER_RESULTS = {
1684
+ "compilation.warnings": {
1685
+ warningsFilter: util.deprecate(
1686
+ (warning, context, { warningsFilter }) => {
1687
+ const warningString = Object.keys(warning)
1688
+ .map(
1689
+ (key) => `${warning[/** @type {keyof KnownStatsError} */ (key)]}`
1690
+ )
1691
+ .join("\n");
1692
+ return !warningsFilter.some((filter) => filter(warning, warningString));
1693
+ },
1694
+ "config.stats.warningsFilter is deprecated in favor of config.ignoreWarnings",
1695
+ "DEP_WEBPACK_STATS_WARNINGS_FILTER"
1696
+ )
1697
+ }
1698
+ };
1699
+
1700
+ /** @type {Record<string, (comparators: Comparator<Module>[], context: StatsFactoryContext) => void>} */
1701
+ const MODULES_SORTER = {
1702
+ _: (comparators, { compilation: { moduleGraph } }) => {
1703
+ comparators.push(
1704
+ compareSelect((m) => moduleGraph.getDepth(m), compareNumbers),
1705
+ compareSelect((m) => moduleGraph.getPreOrderIndex(m), compareNumbers),
1706
+ compareSelect((m) => m.identifier(), compareIds)
1707
+ );
1708
+ }
1709
+ };
1710
+
1711
+ /**
1712
+ * @type {{
1713
+ * "compilation.chunks": Record<string, (comparators: Comparator<Chunk>[], context: StatsFactoryContext, options: NormalizedStatsOptions) => void>,
1714
+ * "compilation.modules": Record<string, (comparators: Comparator<Module>[], context: StatsFactoryContext, options: NormalizedStatsOptions) => void>,
1715
+ * "chunk.rootModules": Record<string, (comparators: Comparator<Module>[], context: StatsFactoryContext, options: NormalizedStatsOptions) => void>,
1716
+ * "chunk.modules": Record<string, (comparators: Comparator<Module>[], context: StatsFactoryContext, options: NormalizedStatsOptions) => void>,
1717
+ * "module.modules": Record<string, (comparators: Comparator<Module>[], context: StatsFactoryContext, options: NormalizedStatsOptions) => void>,
1718
+ * "module.reasons": Record<string, (comparators: Comparator<ModuleGraphConnection>[], context: StatsFactoryContext, options: NormalizedStatsOptions) => void>,
1719
+ * "chunk.origins": Record<string, (comparators: Comparator<OriginRecord>[], context: StatsFactoryContext, options: NormalizedStatsOptions) => void>,
1720
+ * }}
1721
+ */
1722
+ const SORTERS = {
1723
+ "compilation.chunks": {
1724
+ _: (comparators) => {
1725
+ comparators.push(compareSelect((c) => c.id, compareIds));
1726
+ }
1727
+ },
1728
+ "compilation.modules": MODULES_SORTER,
1729
+ "chunk.rootModules": MODULES_SORTER,
1730
+ "chunk.modules": MODULES_SORTER,
1731
+ "module.modules": MODULES_SORTER,
1732
+ "module.reasons": {
1733
+ _: (comparators, _context) => {
1734
+ comparators.push(
1735
+ compareSelect((x) => x.originModule, compareModulesByIdentifier)
1736
+ );
1737
+ comparators.push(
1738
+ compareSelect((x) => x.resolvedOriginModule, compareModulesByIdentifier)
1739
+ );
1740
+ comparators.push(
1741
+ compareSelect(
1742
+ (x) => x.dependency,
1743
+ concatComparators(
1744
+ compareSelect(
1745
+ /**
1746
+ * @param {Dependency} x dependency
1747
+ * @returns {DependencyLocation} location
1748
+ */
1749
+ (x) => x.loc,
1750
+ compareLocations
1751
+ ),
1752
+ compareSelect((x) => x.type, compareIds)
1753
+ )
1754
+ )
1755
+ );
1756
+ }
1757
+ },
1758
+ "chunk.origins": {
1759
+ _: (comparators, { compilation: { chunkGraph } }) => {
1760
+ comparators.push(
1761
+ compareSelect(
1762
+ (origin) =>
1763
+ origin.module ? chunkGraph.getModuleId(origin.module) : undefined,
1764
+ compareIds
1765
+ ),
1766
+ compareSelect((origin) => formatLocation(origin.loc), compareIds),
1767
+ compareSelect((origin) => origin.request, compareIds)
1768
+ );
1769
+ }
1770
+ }
1771
+ };
1772
+
1773
+ /**
1774
+ * @template T
1775
+ * @typedef {T & { children?: Children<T>[] | undefined, filteredChildren?: number }} Children
1776
+ */
1777
+
1778
+ /**
1779
+ * @template T
1780
+ * @param {Children<T>} item item
1781
+ * @returns {number} item size
1782
+ */
1783
+ const getItemSize = (item) =>
1784
+ // Each item takes 1 line
1785
+ // + the size of the children
1786
+ // + 1 extra line when it has children and filteredChildren
1787
+ !item.children
1788
+ ? 1
1789
+ : item.filteredChildren
1790
+ ? 2 + getTotalSize(item.children)
1791
+ : 1 + getTotalSize(item.children);
1792
+
1793
+ /**
1794
+ * @template T
1795
+ * @param {Children<T>[]} children children
1796
+ * @returns {number} total size
1797
+ */
1798
+ const getTotalSize = (children) => {
1799
+ let size = 0;
1800
+ for (const child of children) {
1801
+ size += getItemSize(child);
1802
+ }
1803
+ return size;
1804
+ };
1805
+
1806
+ /**
1807
+ * @template T
1808
+ * @param {Children<T>[]} children children
1809
+ * @returns {number} total items
1810
+ */
1811
+ const getTotalItems = (children) => {
1812
+ let count = 0;
1813
+ for (const child of children) {
1814
+ if (!child.children && !child.filteredChildren) {
1815
+ count++;
1816
+ } else {
1817
+ if (child.children) count += getTotalItems(child.children);
1818
+ if (child.filteredChildren) count += child.filteredChildren;
1819
+ }
1820
+ }
1821
+ return count;
1822
+ };
1823
+
1824
+ /**
1825
+ * @template T
1826
+ * @param {Children<T>[]} children children
1827
+ * @returns {Children<T>[]} collapsed children
1828
+ */
1829
+ const collapse = (children) => {
1830
+ // After collapse each child must take exactly one line
1831
+ /** @type {Children<T>[]} */
1832
+ const newChildren = [];
1833
+ for (const child of children) {
1834
+ if (child.children) {
1835
+ let filteredChildren = child.filteredChildren || 0;
1836
+ filteredChildren += getTotalItems(child.children);
1837
+ newChildren.push({
1838
+ ...child,
1839
+ children: undefined,
1840
+ filteredChildren
1841
+ });
1842
+ } else {
1843
+ newChildren.push(child);
1844
+ }
1845
+ }
1846
+ return newChildren;
1847
+ };
1848
+
1849
+ /**
1850
+ * @template T
1851
+ * @param {Children<T>[]} itemsAndGroups item and groups
1852
+ * @param {number} max max
1853
+ * @param {boolean=} filteredChildrenLineReserved filtered children line reserved
1854
+ * @returns {Children<T>} result
1855
+ */
1856
+ const spaceLimited = (
1857
+ itemsAndGroups,
1858
+ max,
1859
+ filteredChildrenLineReserved = false
1860
+ ) => {
1861
+ if (max < 1) {
1862
+ return /** @type {Children<T>} */ ({
1863
+ children: undefined,
1864
+ filteredChildren: getTotalItems(itemsAndGroups)
1865
+ });
1866
+ }
1867
+ /** @type {Children<T>[] | undefined} */
1868
+ let children;
1869
+ /** @type {number | undefined} */
1870
+ let filteredChildren;
1871
+ // This are the groups, which take 1+ lines each
1872
+ /** @type {Children<T>[] | undefined} */
1873
+ const groups = [];
1874
+ // The sizes of the groups are stored in groupSizes
1875
+ /** @type {number[]} */
1876
+ const groupSizes = [];
1877
+ // This are the items, which take 1 line each
1878
+ /** @type {Children<T>[]} */
1879
+ const items = [];
1880
+ // The total of group sizes
1881
+ let groupsSize = 0;
1882
+
1883
+ for (const itemOrGroup of itemsAndGroups) {
1884
+ // is item
1885
+ if (!itemOrGroup.children && !itemOrGroup.filteredChildren) {
1886
+ items.push(itemOrGroup);
1887
+ } else {
1888
+ groups.push(itemOrGroup);
1889
+ const size = getItemSize(itemOrGroup);
1890
+ groupSizes.push(size);
1891
+ groupsSize += size;
1892
+ }
1893
+ }
1894
+
1895
+ if (groupsSize + items.length <= max) {
1896
+ // The total size in the current state fits into the max
1897
+ // keep all
1898
+ children = groups.length > 0 ? [...groups, ...items] : items;
1899
+ } else if (groups.length === 0) {
1900
+ // slice items to max
1901
+ // inner space marks that lines for filteredChildren already reserved
1902
+ const limit = max - (filteredChildrenLineReserved ? 0 : 1);
1903
+ filteredChildren = items.length - limit;
1904
+ items.length = limit;
1905
+ children = items;
1906
+ } else {
1907
+ // limit is the size when all groups are collapsed
1908
+ const limit =
1909
+ groups.length +
1910
+ (filteredChildrenLineReserved || items.length === 0 ? 0 : 1);
1911
+ if (limit < max) {
1912
+ // calculate how much we are over the size limit
1913
+ // this allows to approach the limit faster
1914
+ /** @type {number} */
1915
+ let oversize;
1916
+ // If each group would take 1 line the total would be below the maximum
1917
+ // collapse some groups, keep items
1918
+ while (
1919
+ (oversize =
1920
+ groupsSize +
1921
+ items.length +
1922
+ (filteredChildren && !filteredChildrenLineReserved ? 1 : 0) -
1923
+ max) > 0
1924
+ ) {
1925
+ // Find the maximum group and process only this one
1926
+ const maxGroupSize = Math.max(...groupSizes);
1927
+ if (maxGroupSize < items.length) {
1928
+ filteredChildren = items.length;
1929
+ items.length = 0;
1930
+ continue;
1931
+ }
1932
+ for (let i = 0; i < groups.length; i++) {
1933
+ if (groupSizes[i] === maxGroupSize) {
1934
+ const group = groups[i];
1935
+ // run this algorithm recursively and limit the size of the children to
1936
+ // current size - oversize / number of groups
1937
+ // So it should always end up being smaller
1938
+ const headerSize = group.filteredChildren ? 2 : 1;
1939
+ const limited = spaceLimited(
1940
+ /** @type {Children<T>[]} */ (group.children),
1941
+ maxGroupSize -
1942
+ // we should use ceil to always feet in max
1943
+ Math.ceil(oversize / groups.length) -
1944
+ // we substitute size of group head
1945
+ headerSize,
1946
+ headerSize === 2
1947
+ );
1948
+ groups[i] = {
1949
+ ...group,
1950
+ children: limited.children,
1951
+ filteredChildren: limited.filteredChildren
1952
+ ? (group.filteredChildren || 0) + limited.filteredChildren
1953
+ : group.filteredChildren
1954
+ };
1955
+ const newSize = getItemSize(groups[i]);
1956
+ groupsSize -= maxGroupSize - newSize;
1957
+ groupSizes[i] = newSize;
1958
+ break;
1959
+ }
1960
+ }
1961
+ }
1962
+ children = [...groups, ...items];
1963
+ } else if (limit === max) {
1964
+ // If we have only enough space to show one line per group and one line for the filtered items
1965
+ // collapse all groups and items
1966
+ children = collapse(groups);
1967
+ filteredChildren = items.length;
1968
+ } else {
1969
+ // If we have no space
1970
+ // collapse complete group
1971
+ filteredChildren = getTotalItems(itemsAndGroups);
1972
+ }
1973
+ }
1974
+
1975
+ return /** @type {Children<T>} */ ({ children, filteredChildren });
1976
+ };
1977
+
1978
+ /**
1979
+ * @param {StatsError[]} errors errors
1980
+ * @param {number} max max
1981
+ * @returns {[StatsError[], number]} error space limit
1982
+ */
1983
+ const errorsSpaceLimit = (errors, max) => {
1984
+ let filtered = 0;
1985
+ // Can not fit into limit
1986
+ // print only messages
1987
+ if (errors.length + 1 >= max) {
1988
+ return [
1989
+ errors.map((error) => {
1990
+ if (typeof error === "string" || !error.details) return error;
1991
+ filtered++;
1992
+ return { ...error, details: "" };
1993
+ }),
1994
+ filtered
1995
+ ];
1996
+ }
1997
+ let fullLength = errors.length;
1998
+ let result = errors;
1999
+
2000
+ let i = 0;
2001
+ for (; i < errors.length; i++) {
2002
+ const error = errors[i];
2003
+ if (typeof error !== "string" && error.details) {
2004
+ const splitted = error.details.split("\n");
2005
+ const len = splitted.length;
2006
+ fullLength += len;
2007
+ if (fullLength > max) {
2008
+ result = i > 0 ? errors.slice(0, i) : [];
2009
+ const overLimit = fullLength - max + 1;
2010
+ const error = errors[i++];
2011
+ result.push({
2012
+ ...error,
2013
+ details:
2014
+ /** @type {string} */
2015
+ (error.details).split("\n").slice(0, -overLimit).join("\n"),
2016
+ filteredDetails: overLimit
2017
+ });
2018
+ filtered = errors.length - i;
2019
+ for (; i < errors.length; i++) {
2020
+ const error = errors[i];
2021
+ if (typeof error === "string" || !error.details) result.push(error);
2022
+ result.push({ ...error, details: "" });
2023
+ }
2024
+ break;
2025
+ } else if (fullLength === max) {
2026
+ result = errors.slice(0, ++i);
2027
+ filtered = errors.length - i;
2028
+ for (; i < errors.length; i++) {
2029
+ const error = errors[i];
2030
+ if (typeof error === "string" || !error.details) result.push(error);
2031
+ result.push({ ...error, details: "" });
2032
+ }
2033
+ break;
2034
+ }
2035
+ }
2036
+ }
2037
+
2038
+ return [result, filtered];
2039
+ };
2040
+
2041
+ /**
2042
+ * @template {{ size: number }} T
2043
+ * @param {T[]} children children
2044
+ * @param {T[]} assets assets
2045
+ * @returns {{ size: number }} asset size
2046
+ */
2047
+ const assetGroup = (children, assets) => {
2048
+ let size = 0;
2049
+ for (const asset of children) {
2050
+ size += asset.size;
2051
+ }
2052
+ return { size };
2053
+ };
2054
+
2055
+ /** @typedef {{ size: number, sizes: Record<string, number> }} ModuleGroupBySizeResult */
2056
+
2057
+ /**
2058
+ * @template {ModuleGroupBySizeResult} T
2059
+ * @param {Children<T>[]} children children
2060
+ * @param {KnownStatsModule[]} modules modules
2061
+ * @returns {ModuleGroupBySizeResult} size and sizes
2062
+ */
2063
+ const moduleGroup = (children, modules) => {
2064
+ let size = 0;
2065
+ /** @type {Record<string, number>} */
2066
+ const sizes = {};
2067
+ for (const module of children) {
2068
+ size += module.size;
2069
+ for (const key of Object.keys(module.sizes)) {
2070
+ sizes[key] = (sizes[key] || 0) + module.sizes[key];
2071
+ }
2072
+ }
2073
+ return {
2074
+ size,
2075
+ sizes
2076
+ };
2077
+ };
2078
+
2079
+ /**
2080
+ * @template {{ active: boolean }} T
2081
+ * @param {Children<T>[]} children children
2082
+ * @param {KnownStatsModuleReason[]} reasons reasons
2083
+ * @returns {{ active: boolean }} reason group
2084
+ */
2085
+ const reasonGroup = (children, reasons) => {
2086
+ let active = false;
2087
+ for (const reason of children) {
2088
+ active = active || reason.active;
2089
+ }
2090
+ return {
2091
+ active
2092
+ };
2093
+ };
2094
+
2095
+ const GROUP_EXTENSION_REGEXP = /(\.[^.]+?)(?:\?|(?: \+ \d+ modules?)?$)/;
2096
+ const GROUP_PATH_REGEXP = /(.+)[/\\][^/\\]+?(?:\?|(?: \+ \d+ modules?)?$)/;
2097
+
2098
+ /** @typedef {{ type: string }} BaseGroup */
2099
+
2100
+ /**
2101
+ * @template T
2102
+ * @typedef {BaseGroup & { children: T[], size: number }} BaseGroupWithChildren
2103
+ */
2104
+
2105
+ /** @typedef {(name: string, asset: StatsAsset) => boolean} AssetFilterItemFn */
2106
+
2107
+ /**
2108
+ * @typedef {{
2109
+ * _: (groupConfigs: GroupConfig<KnownStatsAsset, BaseGroup & { filteredChildren: number, size: number } | BaseGroupWithChildren<KnownStatsAsset>>[], context: StatsFactoryContext, options: NormalizedStatsOptions) => void,
2110
+ * groupAssetsByInfo: (groupConfigs: GroupConfig<KnownStatsAsset, BaseGroupWithChildren<KnownStatsAsset>>[], context: StatsFactoryContext, options: NormalizedStatsOptions) => void,
2111
+ * groupAssetsByChunk: (groupConfigs: GroupConfig<KnownStatsAsset, BaseGroupWithChildren<KnownStatsAsset>>[], context: StatsFactoryContext, options: NormalizedStatsOptions) => void,
2112
+ * excludeAssets: (groupConfigs: GroupConfig<KnownStatsAsset, BaseGroup & { filteredChildren: number, size: number }>[], context: StatsFactoryContext, options: NormalizedStatsOptions) => void,
2113
+ * }} AssetsGroupers
2114
+ */
2115
+
2116
+ /** @type {AssetsGroupers} */
2117
+ const ASSETS_GROUPERS = {
2118
+ _: (groupConfigs, context, options) => {
2119
+ /**
2120
+ * @param {keyof KnownStatsAsset} name name
2121
+ * @param {boolean=} exclude need exclude?
2122
+ */
2123
+ const groupByFlag = (name, exclude) => {
2124
+ groupConfigs.push({
2125
+ getKeys: (asset) => (asset[name] ? ["1"] : undefined),
2126
+ getOptions: () => ({
2127
+ groupChildren: !exclude,
2128
+ force: exclude
2129
+ }),
2130
+ createGroup: (key, children, assets) =>
2131
+ exclude
2132
+ ? {
2133
+ type: "assets by status",
2134
+ [name]: Boolean(key),
2135
+ filteredChildren: assets.length,
2136
+ ...assetGroup(children, assets)
2137
+ }
2138
+ : {
2139
+ type: "assets by status",
2140
+ [name]: Boolean(key),
2141
+ children,
2142
+ ...assetGroup(children, assets)
2143
+ }
2144
+ });
2145
+ };
2146
+ const {
2147
+ groupAssetsByEmitStatus,
2148
+ groupAssetsByPath,
2149
+ groupAssetsByExtension
2150
+ } = options;
2151
+ if (groupAssetsByEmitStatus) {
2152
+ groupByFlag("emitted");
2153
+ groupByFlag("comparedForEmit");
2154
+ groupByFlag("isOverSizeLimit");
2155
+ }
2156
+ if (groupAssetsByEmitStatus || !options.cachedAssets) {
2157
+ groupByFlag("cached", !options.cachedAssets);
2158
+ }
2159
+ if (groupAssetsByPath || groupAssetsByExtension) {
2160
+ groupConfigs.push({
2161
+ getKeys: (asset) => {
2162
+ const extensionMatch =
2163
+ groupAssetsByExtension && GROUP_EXTENSION_REGEXP.exec(asset.name);
2164
+ const extension = extensionMatch ? extensionMatch[1] : "";
2165
+ const pathMatch =
2166
+ groupAssetsByPath && GROUP_PATH_REGEXP.exec(asset.name);
2167
+ const path = pathMatch ? pathMatch[1].split(/[/\\]/) : [];
2168
+ /** @type {string[]} */
2169
+ const keys = [];
2170
+ if (groupAssetsByPath) {
2171
+ keys.push(".");
2172
+ if (extension) {
2173
+ keys.push(
2174
+ path.length
2175
+ ? `${path.join("/")}/*${extension}`
2176
+ : `*${extension}`
2177
+ );
2178
+ }
2179
+ while (path.length > 0) {
2180
+ keys.push(`${path.join("/")}/`);
2181
+ path.pop();
2182
+ }
2183
+ } else if (extension) {
2184
+ keys.push(`*${extension}`);
2185
+ }
2186
+ return keys;
2187
+ },
2188
+ createGroup: (key, children, assets) => ({
2189
+ type: groupAssetsByPath ? "assets by path" : "assets by extension",
2190
+ name: key,
2191
+ children,
2192
+ ...assetGroup(children, assets)
2193
+ })
2194
+ });
2195
+ }
2196
+ },
2197
+ groupAssetsByInfo: (groupConfigs, _context, _options) => {
2198
+ /**
2199
+ * @param {string} name name
2200
+ */
2201
+ const groupByAssetInfoFlag = (name) => {
2202
+ groupConfigs.push({
2203
+ getKeys: (asset) =>
2204
+ asset.info && asset.info[name] ? ["1"] : undefined,
2205
+ createGroup: (key, children, assets) => ({
2206
+ type: "assets by info",
2207
+ info: {
2208
+ [name]: Boolean(key)
2209
+ },
2210
+ children,
2211
+ ...assetGroup(children, assets)
2212
+ })
2213
+ });
2214
+ };
2215
+ groupByAssetInfoFlag("immutable");
2216
+ groupByAssetInfoFlag("development");
2217
+ groupByAssetInfoFlag("hotModuleReplacement");
2218
+ },
2219
+ groupAssetsByChunk: (groupConfigs, _context, _options) => {
2220
+ /**
2221
+ * @param {keyof KnownStatsAsset} name name
2222
+ */
2223
+ const groupByNames = (name) => {
2224
+ groupConfigs.push({
2225
+ getKeys: (asset) => /** @type {string[]} */ (asset[name]),
2226
+ createGroup: (key, children, assets) => ({
2227
+ type: "assets by chunk",
2228
+ [name]: [key],
2229
+ children,
2230
+ ...assetGroup(children, assets)
2231
+ })
2232
+ });
2233
+ };
2234
+ groupByNames("chunkNames");
2235
+ groupByNames("auxiliaryChunkNames");
2236
+ groupByNames("chunkIdHints");
2237
+ groupByNames("auxiliaryChunkIdHints");
2238
+ },
2239
+ excludeAssets: (groupConfigs, context, { excludeAssets }) => {
2240
+ groupConfigs.push({
2241
+ getKeys: (asset) => {
2242
+ const ident = asset.name;
2243
+ const excluded = excludeAssets.some((fn) => fn(ident, asset));
2244
+ if (excluded) return ["excluded"];
2245
+ },
2246
+ getOptions: () => ({
2247
+ groupChildren: false,
2248
+ force: true
2249
+ }),
2250
+ createGroup: (key, children, assets) => ({
2251
+ type: "hidden assets",
2252
+ filteredChildren: assets.length,
2253
+ ...assetGroup(children, assets)
2254
+ })
2255
+ });
2256
+ }
2257
+ };
2258
+
2259
+ /**
2260
+ * @typedef {{
2261
+ * _: (groupConfigs: GroupConfig<KnownStatsModule, BaseGroup & { filteredChildren?: number, children?: KnownStatsModule[], size: number, sizes: Record<string, number> }>[], context: StatsFactoryContext, options: NormalizedStatsOptions) => void,
2262
+ * excludeModules: (groupConfigs: GroupConfig<KnownStatsModule, BaseGroup & { filteredChildren: number, size: number, sizes: Record<string, number> }>[], context: StatsFactoryContext, options: NormalizedStatsOptions) => void,
2263
+ * }} ModulesGroupers
2264
+ */
2265
+
2266
+ /** @typedef {(name: string, module: StatsModule, type: "module" | "chunk" | "root-of-chunk" | "nested") => boolean} ModuleFilterItemTypeFn */
2267
+
2268
+ /**
2269
+ * @type {(type: ExcludeModulesType) => ModulesGroupers}
2270
+ */
2271
+ const MODULES_GROUPERS = (type) => ({
2272
+ _: (groupConfigs, context, options) => {
2273
+ /**
2274
+ * @param {keyof KnownStatsModule} name name
2275
+ * @param {string} type type
2276
+ * @param {boolean=} exclude need exclude?
2277
+ */
2278
+ const groupByFlag = (name, type, exclude) => {
2279
+ groupConfigs.push({
2280
+ getKeys: (module) => (module[name] ? ["1"] : undefined),
2281
+ getOptions: () => ({
2282
+ groupChildren: !exclude,
2283
+ force: exclude
2284
+ }),
2285
+ createGroup: (key, children, modules) => ({
2286
+ type,
2287
+ [name]: Boolean(key),
2288
+ ...(exclude ? { filteredChildren: modules.length } : { children }),
2289
+ ...moduleGroup(
2290
+ /** @type {(KnownStatsModule & ModuleGroupBySizeResult)[]} */
2291
+ (children),
2292
+ modules
2293
+ )
2294
+ })
2295
+ });
2296
+ };
2297
+ const {
2298
+ groupModulesByCacheStatus,
2299
+ groupModulesByLayer,
2300
+ groupModulesByAttributes,
2301
+ groupModulesByType,
2302
+ groupModulesByPath,
2303
+ groupModulesByExtension
2304
+ } = options;
2305
+ if (groupModulesByAttributes) {
2306
+ groupByFlag("errors", "modules with errors");
2307
+ groupByFlag("warnings", "modules with warnings");
2308
+ groupByFlag("assets", "modules with assets");
2309
+ groupByFlag("optional", "optional modules");
2310
+ }
2311
+ if (groupModulesByCacheStatus) {
2312
+ groupByFlag("cacheable", "cacheable modules");
2313
+ groupByFlag("built", "built modules");
2314
+ groupByFlag("codeGenerated", "code generated modules");
2315
+ }
2316
+ if (groupModulesByCacheStatus || !options.cachedModules) {
2317
+ groupByFlag("cached", "cached modules", !options.cachedModules);
2318
+ }
2319
+ if (groupModulesByAttributes || !options.orphanModules) {
2320
+ groupByFlag("orphan", "orphan modules", !options.orphanModules);
2321
+ }
2322
+ if (groupModulesByAttributes || !options.dependentModules) {
2323
+ groupByFlag("dependent", "dependent modules", !options.dependentModules);
2324
+ }
2325
+ if (groupModulesByType || !options.runtimeModules) {
2326
+ groupConfigs.push({
2327
+ getKeys: (module) => {
2328
+ if (!module.moduleType) return;
2329
+ if (groupModulesByType) {
2330
+ return [module.moduleType.split("/", 1)[0]];
2331
+ } else if (module.moduleType === WEBPACK_MODULE_TYPE_RUNTIME) {
2332
+ return [WEBPACK_MODULE_TYPE_RUNTIME];
2333
+ }
2334
+ },
2335
+ getOptions: (key) => {
2336
+ const exclude =
2337
+ key === WEBPACK_MODULE_TYPE_RUNTIME && !options.runtimeModules;
2338
+ return {
2339
+ groupChildren: !exclude,
2340
+ force: exclude
2341
+ };
2342
+ },
2343
+ createGroup: (key, children, modules) => {
2344
+ const exclude =
2345
+ key === WEBPACK_MODULE_TYPE_RUNTIME && !options.runtimeModules;
2346
+ return {
2347
+ type: `${key} modules`,
2348
+ moduleType: key,
2349
+ ...(exclude ? { filteredChildren: modules.length } : { children }),
2350
+ ...moduleGroup(
2351
+ /** @type {(KnownStatsModule & ModuleGroupBySizeResult)[]} */
2352
+ (children),
2353
+ modules
2354
+ )
2355
+ };
2356
+ }
2357
+ });
2358
+ }
2359
+ if (groupModulesByLayer) {
2360
+ groupConfigs.push({
2361
+ getKeys: (module) => /** @type {string[]} */ ([module.layer]),
2362
+ createGroup: (key, children, modules) => ({
2363
+ type: "modules by layer",
2364
+ layer: key,
2365
+ children,
2366
+ ...moduleGroup(
2367
+ /** @type {(KnownStatsModule & ModuleGroupBySizeResult)[]} */
2368
+ (children),
2369
+ modules
2370
+ )
2371
+ })
2372
+ });
2373
+ }
2374
+ if (groupModulesByPath || groupModulesByExtension) {
2375
+ groupConfigs.push({
2376
+ getKeys: (module) => {
2377
+ if (!module.name) return;
2378
+ const resource = parseResource(
2379
+ /** @type {string} */ (module.name.split("!").pop())
2380
+ ).path;
2381
+ const dataUrl = /^data:[^,;]+/.exec(resource);
2382
+ if (dataUrl) return [dataUrl[0]];
2383
+ const extensionMatch =
2384
+ groupModulesByExtension && GROUP_EXTENSION_REGEXP.exec(resource);
2385
+ const extension = extensionMatch ? extensionMatch[1] : "";
2386
+ const pathMatch =
2387
+ groupModulesByPath && GROUP_PATH_REGEXP.exec(resource);
2388
+ const path = pathMatch ? pathMatch[1].split(/[/\\]/) : [];
2389
+ /** @type {string[]} */
2390
+ const keys = [];
2391
+ if (groupModulesByPath) {
2392
+ if (extension) {
2393
+ keys.push(
2394
+ path.length
2395
+ ? `${path.join("/")}/*${extension}`
2396
+ : `*${extension}`
2397
+ );
2398
+ }
2399
+ while (path.length > 0) {
2400
+ keys.push(`${path.join("/")}/`);
2401
+ path.pop();
2402
+ }
2403
+ } else if (extension) {
2404
+ keys.push(`*${extension}`);
2405
+ }
2406
+ return keys;
2407
+ },
2408
+ createGroup: (key, children, modules) => {
2409
+ const isDataUrl = key.startsWith("data:");
2410
+ return {
2411
+ type: isDataUrl
2412
+ ? "modules by mime type"
2413
+ : groupModulesByPath
2414
+ ? "modules by path"
2415
+ : "modules by extension",
2416
+ name: isDataUrl ? key.slice(/* 'data:'.length */ 5) : key,
2417
+ children,
2418
+ ...moduleGroup(
2419
+ /** @type {(KnownStatsModule & ModuleGroupBySizeResult)[]} */
2420
+ (children),
2421
+ modules
2422
+ )
2423
+ };
2424
+ }
2425
+ });
2426
+ }
2427
+ },
2428
+ excludeModules: (groupConfigs, context, { excludeModules }) => {
2429
+ groupConfigs.push({
2430
+ getKeys: (module) => {
2431
+ const name = module.name;
2432
+ if (name) {
2433
+ const excluded = excludeModules.some((fn) => fn(name, module, type));
2434
+ if (excluded) return ["1"];
2435
+ }
2436
+ },
2437
+ getOptions: () => ({
2438
+ groupChildren: false,
2439
+ force: true
2440
+ }),
2441
+ createGroup: (key, children, modules) => ({
2442
+ type: "hidden modules",
2443
+ filteredChildren: children.length,
2444
+ ...moduleGroup(
2445
+ /** @type {(KnownStatsModule & ModuleGroupBySizeResult)[]} */
2446
+ (children),
2447
+ modules
2448
+ )
2449
+ })
2450
+ });
2451
+ }
2452
+ });
2453
+
2454
+ /**
2455
+ * @typedef {{ groupReasonsByOrigin: (groupConfigs: GroupConfig<KnownStatsModuleReason, BaseGroup & { module: string, children: KnownStatsModuleReason[], active: boolean }>[], context: StatsFactoryContext, options: NormalizedStatsOptions) => void }} ModuleReasonsGroupers
2456
+ */
2457
+
2458
+ /** @type {ModuleReasonsGroupers} */
2459
+ const MODULE_REASONS_GROUPERS = {
2460
+ groupReasonsByOrigin: (groupConfigs) => {
2461
+ groupConfigs.push({
2462
+ getKeys: (reason) => /** @type {string[]} */ ([reason.module]),
2463
+ createGroup: (key, children, reasons) => ({
2464
+ type: "from origin",
2465
+ module: key,
2466
+ children,
2467
+ ...reasonGroup(children, reasons)
2468
+ })
2469
+ });
2470
+ }
2471
+ };
2472
+
2473
+ /**
2474
+ * @type {{
2475
+ * "compilation.assets": AssetsGroupers,
2476
+ * "asset.related": AssetsGroupers,
2477
+ * "compilation.modules": ModulesGroupers,
2478
+ * "chunk.modules": ModulesGroupers,
2479
+ * "chunk.rootModules": ModulesGroupers,
2480
+ * "module.modules": ModulesGroupers,
2481
+ * "module.reasons": ModuleReasonsGroupers,
2482
+ * }}
2483
+ */
2484
+ const RESULT_GROUPERS = {
2485
+ "compilation.assets": ASSETS_GROUPERS,
2486
+ "asset.related": ASSETS_GROUPERS,
2487
+ "compilation.modules": MODULES_GROUPERS("module"),
2488
+ "chunk.modules": MODULES_GROUPERS("chunk"),
2489
+ "chunk.rootModules": MODULES_GROUPERS("root-of-chunk"),
2490
+ "module.modules": MODULES_GROUPERS("nested"),
2491
+ "module.reasons": MODULE_REASONS_GROUPERS
2492
+ };
2493
+
2494
+ // remove a prefixed "!" that can be specified to reverse sort order
2495
+ /**
2496
+ * @param {string} field a field name
2497
+ * @returns {field} normalized field
2498
+ */
2499
+ const normalizeFieldKey = (field) => {
2500
+ if (field[0] === "!") {
2501
+ return field.slice(1);
2502
+ }
2503
+ return field;
2504
+ };
2505
+
2506
+ // if a field is prefixed by a "!" reverse sort order
2507
+ /**
2508
+ * @param {string} field a field name
2509
+ * @returns {boolean} result
2510
+ */
2511
+ const sortOrderRegular = (field) => {
2512
+ if (field[0] === "!") {
2513
+ return false;
2514
+ }
2515
+ return true;
2516
+ };
2517
+
2518
+ /**
2519
+ * @template T
2520
+ * @param {string | false} field field name
2521
+ * @returns {(a: T, b: T) => 0 | 1 | -1} comparators
2522
+ */
2523
+ const sortByField = (field) => {
2524
+ if (!field) {
2525
+ /**
2526
+ * @param {T} a first
2527
+ * @param {T} b second
2528
+ * @returns {-1 | 0 | 1} zero
2529
+ */
2530
+ const noSort = (a, b) => 0;
2531
+ return noSort;
2532
+ }
2533
+
2534
+ const fieldKey = normalizeFieldKey(field);
2535
+
2536
+ let sortFn = compareSelect((m) => m[fieldKey], compareIds);
2537
+
2538
+ // if a field is prefixed with a "!" the sort is reversed!
2539
+ const sortIsRegular = sortOrderRegular(field);
2540
+
2541
+ if (!sortIsRegular) {
2542
+ const oldSortFn = sortFn;
2543
+ sortFn = (a, b) => oldSortFn(b, a);
2544
+ }
2545
+
2546
+ return sortFn;
2547
+ };
2548
+
2549
+ /**
2550
+ * @typedef {{
2551
+ * assetsSort: (comparators: Comparator<Asset>[], context: StatsFactoryContext, options: NormalizedStatsOptions) => void,
2552
+ * _: (comparators: Comparator<Asset>[], context: StatsFactoryContext, options: NormalizedStatsOptions) => void,
2553
+ * }} AssetSorters
2554
+ */
2555
+
2556
+ /** @type {AssetSorters} */
2557
+ const ASSET_SORTERS = {
2558
+ assetsSort: (comparators, context, { assetsSort }) => {
2559
+ comparators.push(sortByField(assetsSort));
2560
+ },
2561
+ _: (comparators) => {
2562
+ comparators.push(compareSelect((a) => a.name, compareIds));
2563
+ }
2564
+ };
2565
+
2566
+ /**
2567
+ * @type {{
2568
+ * "compilation.chunks": { chunksSort: (comparators: Comparator<Chunk>[], context: StatsFactoryContext, options: NormalizedStatsOptions) => void },
2569
+ * "compilation.modules": { modulesSort: (comparators: Comparator<Module>[], context: StatsFactoryContext, options: NormalizedStatsOptions) => void },
2570
+ * "chunk.modules": { chunkModulesSort: (comparators: Comparator<Module>[], context: StatsFactoryContext, options: NormalizedStatsOptions) => void },
2571
+ * "module.modules": { nestedModulesSort: (comparators: Comparator<Module>[], context: StatsFactoryContext, options: NormalizedStatsOptions) => void },
2572
+ * "compilation.assets": AssetSorters,
2573
+ * "asset.related": AssetSorters,
2574
+ * }}
2575
+ */
2576
+ const RESULT_SORTERS = {
2577
+ "compilation.chunks": {
2578
+ chunksSort: (comparators, context, { chunksSort }) => {
2579
+ comparators.push(sortByField(chunksSort));
2580
+ }
2581
+ },
2582
+ "compilation.modules": {
2583
+ modulesSort: (comparators, context, { modulesSort }) => {
2584
+ comparators.push(sortByField(modulesSort));
2585
+ }
2586
+ },
2587
+ "chunk.modules": {
2588
+ chunkModulesSort: (comparators, context, { chunkModulesSort }) => {
2589
+ comparators.push(sortByField(chunkModulesSort));
2590
+ }
2591
+ },
2592
+ "module.modules": {
2593
+ nestedModulesSort: (comparators, context, { nestedModulesSort }) => {
2594
+ comparators.push(sortByField(nestedModulesSort));
2595
+ }
2596
+ },
2597
+ "compilation.assets": ASSET_SORTERS,
2598
+ "asset.related": ASSET_SORTERS
2599
+ };
2600
+
2601
+ /**
2602
+ * @template T
2603
+ * @typedef {T extends Record<string, Record<string, infer F>> ? F : never} ExtractFunction
2604
+ */
2605
+
2606
+ /**
2607
+ * @template {Record<string, Record<string, EXPECTED_ANY>>} T
2608
+ * @param {T} config the config see above
2609
+ * @param {NormalizedStatsOptions} options stats options
2610
+ * @param {(hookFor: keyof T, fn: ExtractFunction<T>) => void} fn handler function called for every active line in config
2611
+ * @returns {void}
2612
+ */
2613
+ const iterateConfig = (config, options, fn) => {
2614
+ for (const hookFor of Object.keys(config)) {
2615
+ const subConfig = config[hookFor];
2616
+ for (const option of Object.keys(subConfig)) {
2617
+ if (option !== "_") {
2618
+ if (option.startsWith("!")) {
2619
+ if (options[option.slice(1)]) continue;
2620
+ } else {
2621
+ const value = options[option];
2622
+ if (
2623
+ value === false ||
2624
+ value === undefined ||
2625
+ (Array.isArray(value) && value.length === 0)
2626
+ ) {
2627
+ continue;
2628
+ }
2629
+ }
2630
+ }
2631
+ fn(hookFor, subConfig[option]);
2632
+ }
2633
+ }
2634
+ };
2635
+
2636
+ /** @type {Record<string, string>} */
2637
+ const ITEM_NAMES = {
2638
+ "compilation.children[]": "compilation",
2639
+ "compilation.modules[]": "module",
2640
+ "compilation.entrypoints[]": "chunkGroup",
2641
+ "compilation.namedChunkGroups[]": "chunkGroup",
2642
+ "compilation.errors[]": "error",
2643
+ "compilation.warnings[]": "warning",
2644
+ "error.errors[]": "error",
2645
+ "warning.errors[]": "error",
2646
+ "chunk.modules[]": "module",
2647
+ "chunk.rootModules[]": "module",
2648
+ "chunk.origins[]": "chunkOrigin",
2649
+ "compilation.chunks[]": "chunk",
2650
+ "compilation.assets[]": "asset",
2651
+ "asset.related[]": "asset",
2652
+ "module.issuerPath[]": "moduleIssuer",
2653
+ "module.reasons[]": "moduleReason",
2654
+ "module.modules[]": "module",
2655
+ "module.children[]": "module",
2656
+ "moduleTrace[]": "moduleTraceItem",
2657
+ "moduleTraceItem.dependencies[]": "moduleTraceDependency"
2658
+ };
2659
+
2660
+ /**
2661
+ * @template T
2662
+ * @typedef {{ name: T }} NamedObject
2663
+ */
2664
+
2665
+ /**
2666
+ * @template {{ name: string }} T
2667
+ * @param {T[]} items items to be merged
2668
+ * @returns {NamedObject<T>} an object
2669
+ */
2670
+ const mergeToObject = (items) => {
2671
+ const obj = Object.create(null);
2672
+ for (const item of items) {
2673
+ obj[item.name] = item;
2674
+ }
2675
+ return obj;
2676
+ };
2677
+
2678
+ /**
2679
+ * @template {{ name: string }} T
2680
+ * @type {Record<string, (items: T[]) => NamedObject<T>>}
2681
+ */
2682
+ const MERGER = {
2683
+ "compilation.entrypoints": mergeToObject,
2684
+ "compilation.namedChunkGroups": mergeToObject
2685
+ };
2686
+
2687
+ const PLUGIN_NAME = "DefaultStatsFactoryPlugin";
2688
+
2689
+ class DefaultStatsFactoryPlugin {
2690
+ /**
2691
+ * Apply the plugin
2692
+ * @param {Compiler} compiler the compiler instance
2693
+ * @returns {void}
2694
+ */
2695
+ apply(compiler) {
2696
+ compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
2697
+ compilation.hooks.statsFactory.tap(
2698
+ PLUGIN_NAME,
2699
+ /**
2700
+ * @param {StatsFactory} stats stats factory
2701
+ * @param {NormalizedStatsOptions} options stats options
2702
+ */
2703
+ (stats, options) => {
2704
+ iterateConfig(SIMPLE_EXTRACTORS, options, (hookFor, fn) => {
2705
+ stats.hooks.extract
2706
+ .for(hookFor)
2707
+ .tap(PLUGIN_NAME, (obj, data, ctx) =>
2708
+ fn(obj, data, ctx, options, stats)
2709
+ );
2710
+ });
2711
+ iterateConfig(FILTER, options, (hookFor, fn) => {
2712
+ stats.hooks.filter
2713
+ .for(hookFor)
2714
+ .tap(PLUGIN_NAME, (item, ctx, idx, i) =>
2715
+ fn(item, ctx, options, idx, i)
2716
+ );
2717
+ });
2718
+ iterateConfig(FILTER_RESULTS, options, (hookFor, fn) => {
2719
+ stats.hooks.filterResults
2720
+ .for(hookFor)
2721
+ .tap(PLUGIN_NAME, (item, ctx, idx, i) =>
2722
+ fn(item, ctx, options, idx, i)
2723
+ );
2724
+ });
2725
+ iterateConfig(SORTERS, options, (hookFor, fn) => {
2726
+ stats.hooks.sort
2727
+ .for(hookFor)
2728
+ .tap(PLUGIN_NAME, (comparators, ctx) =>
2729
+ fn(comparators, ctx, options)
2730
+ );
2731
+ });
2732
+ iterateConfig(RESULT_SORTERS, options, (hookFor, fn) => {
2733
+ stats.hooks.sortResults
2734
+ .for(hookFor)
2735
+ .tap(PLUGIN_NAME, (comparators, ctx) =>
2736
+ fn(comparators, ctx, options)
2737
+ );
2738
+ });
2739
+ iterateConfig(RESULT_GROUPERS, options, (hookFor, fn) => {
2740
+ stats.hooks.groupResults
2741
+ .for(hookFor)
2742
+ .tap(PLUGIN_NAME, (groupConfigs, ctx) =>
2743
+ fn(groupConfigs, ctx, options)
2744
+ );
2745
+ });
2746
+ for (const key of Object.keys(ITEM_NAMES)) {
2747
+ const itemName = ITEM_NAMES[key];
2748
+ stats.hooks.getItemName.for(key).tap(PLUGIN_NAME, () => itemName);
2749
+ }
2750
+ for (const key of Object.keys(MERGER)) {
2751
+ const merger = MERGER[key];
2752
+ stats.hooks.merge.for(key).tap(PLUGIN_NAME, merger);
2753
+ }
2754
+ if (options.children) {
2755
+ if (Array.isArray(options.children)) {
2756
+ stats.hooks.getItemFactory
2757
+ .for("compilation.children[].compilation")
2758
+ .tap(
2759
+ PLUGIN_NAME,
2760
+ /**
2761
+ * @param {Compilation} comp compilation
2762
+ * @param {StatsFactoryContext} options options
2763
+ * @returns {StatsFactory | undefined} stats factory
2764
+ */
2765
+ (comp, { _index: idx }) => {
2766
+ const children =
2767
+ /** @type {StatsValue[]} */
2768
+ (options.children);
2769
+ if (idx < children.length) {
2770
+ return compilation.createStatsFactory(
2771
+ compilation.createStatsOptions(children[idx])
2772
+ );
2773
+ }
2774
+ }
2775
+ );
2776
+ } else if (options.children !== true) {
2777
+ const childFactory = compilation.createStatsFactory(
2778
+ compilation.createStatsOptions(options.children)
2779
+ );
2780
+ stats.hooks.getItemFactory
2781
+ .for("compilation.children[].compilation")
2782
+ .tap(PLUGIN_NAME, () => childFactory);
2783
+ }
2784
+ }
2785
+ }
2786
+ );
2787
+ });
2788
+ }
2789
+ }
2790
+
2791
+ module.exports = DefaultStatsFactoryPlugin;