webpack 5.101.3 → 5.102.0
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.
- package/README.md +21 -26
- package/lib/APIPlugin.js +30 -36
- package/lib/AsyncDependenciesBlock.js +1 -4
- package/lib/BannerPlugin.js +0 -1
- package/lib/Cache.js +7 -6
- package/lib/CacheFacade.js +0 -1
- package/lib/Chunk.js +49 -31
- package/lib/ChunkGraph.js +35 -25
- package/lib/ChunkGroup.js +8 -10
- package/lib/ChunkTemplate.js +1 -1
- package/lib/CleanPlugin.js +3 -3
- package/lib/CodeGenerationResults.js +2 -1
- package/lib/CompatibilityPlugin.js +29 -12
- package/lib/Compilation.js +204 -185
- package/lib/Compiler.js +36 -35
- package/lib/ConcatenationScope.js +6 -1
- package/lib/ConditionalInitFragment.js +1 -1
- package/lib/ConstPlugin.js +6 -5
- package/lib/ContextExclusionPlugin.js +0 -1
- package/lib/ContextModule.js +22 -20
- package/lib/ContextModuleFactory.js +30 -11
- package/lib/ContextReplacementPlugin.js +38 -15
- package/lib/DefinePlugin.js +4 -8
- package/lib/DelegatedModule.js +7 -11
- package/lib/DependenciesBlock.js +0 -2
- package/lib/Dependency.js +9 -11
- package/lib/DependencyTemplates.js +1 -3
- package/lib/DllModule.js +1 -7
- package/lib/DllReferencePlugin.js +2 -4
- package/lib/DynamicEntryPlugin.js +0 -2
- package/lib/EntryOptionPlugin.js +0 -5
- package/lib/EnvironmentNotSupportAsyncWarning.js +0 -3
- package/lib/EvalDevToolModulePlugin.js +4 -3
- package/lib/EvalSourceMapDevToolPlugin.js +3 -4
- package/lib/ExportsInfo.js +50 -49
- package/lib/ExternalModule.js +84 -52
- package/lib/ExternalModuleFactoryPlugin.js +27 -7
- package/lib/ExternalsPlugin.js +24 -17
- package/lib/FileSystemInfo.js +96 -78
- package/lib/FlagDependencyUsagePlugin.js +3 -4
- package/lib/Generator.js +2 -13
- package/lib/GraphHelpers.js +0 -3
- package/lib/HookWebpackError.js +0 -2
- package/lib/HotModuleReplacementPlugin.js +22 -24
- package/lib/HotUpdateChunk.js +0 -3
- package/lib/IgnorePlugin.js +5 -2
- package/lib/InitFragment.js +41 -29
- package/lib/InvalidDependenciesModuleWarning.js +0 -1
- package/lib/LibManifestPlugin.js +4 -6
- package/lib/LoaderOptionsPlugin.js +1 -10
- package/lib/MainTemplate.js +8 -19
- package/lib/Module.js +32 -20
- package/lib/ModuleFactory.js +1 -1
- package/lib/ModuleFilenameHelpers.js +41 -24
- package/lib/ModuleGraph.js +30 -16
- package/lib/ModuleInfoHeaderPlugin.js +0 -1
- package/lib/ModuleTemplate.js +0 -2
- package/lib/ModuleTypeConstants.js +11 -1
- package/lib/MultiCompiler.js +23 -15
- package/lib/MultiWatching.js +6 -10
- package/lib/NodeStuffPlugin.js +2 -10
- package/lib/NormalModule.js +145 -88
- package/lib/NormalModuleFactory.js +59 -40
- package/lib/OptionsApply.js +1 -1
- package/lib/Parser.js +1 -1
- package/lib/ProgressPlugin.js +6 -10
- package/lib/ProvidePlugin.js +5 -7
- package/lib/RawModule.js +1 -6
- package/lib/RecordIdsPlugin.js +10 -6
- package/lib/ResolverFactory.js +0 -2
- package/lib/RuntimeGlobals.js +5 -0
- package/lib/RuntimeModule.js +1 -3
- package/lib/RuntimePlugin.js +26 -22
- package/lib/RuntimeTemplate.js +12 -11
- package/lib/SourceMapDevToolModuleOptionsPlugin.js +2 -2
- package/lib/SourceMapDevToolPlugin.js +6 -11
- package/lib/Stats.js +0 -1
- package/lib/Template.js +6 -11
- package/lib/TemplatedPathPlugin.js +2 -1
- package/lib/WatchIgnorePlugin.js +2 -3
- package/lib/Watching.js +15 -15
- package/lib/WebpackIsIncludedPlugin.js +0 -2
- package/lib/WebpackOptionsApply.js +74 -107
- package/lib/asset/AssetBytesGenerator.js +166 -0
- package/lib/asset/AssetBytesParser.js +37 -0
- package/lib/asset/AssetGenerator.js +20 -34
- package/lib/asset/AssetModulesPlugin.js +34 -16
- package/lib/asset/AssetParser.js +7 -3
- package/lib/asset/AssetSourceGenerator.js +1 -1
- package/lib/asset/RawDataUrlModule.js +3 -2
- package/lib/async-modules/AsyncModuleHelpers.js +6 -4
- package/lib/buildChunkGraph.js +0 -1
- package/lib/cache/MemoryCachePlugin.js +0 -2
- package/lib/cache/MemoryWithGcCachePlugin.js +0 -2
- package/lib/cache/PackFileCacheStrategy.js +14 -1
- package/lib/cache/ResolverCachePlugin.js +9 -15
- package/lib/config/defaults.js +155 -21
- package/lib/config/normalization.js +18 -3
- package/lib/container/ContainerEntryDependency.js +0 -1
- package/lib/container/ContainerEntryModule.js +3 -7
- package/lib/container/ContainerPlugin.js +1 -2
- package/lib/container/ContainerReferencePlugin.js +0 -1
- package/lib/container/FallbackDependency.js +2 -1
- package/lib/container/FallbackModule.js +6 -7
- package/lib/container/ModuleFederationPlugin.js +0 -1
- package/lib/container/RemoteModule.js +8 -8
- package/lib/container/RemoteRuntimeModule.js +2 -2
- package/lib/css/CssGenerator.js +3 -6
- package/lib/css/CssLoadingRuntimeModule.js +6 -9
- package/lib/css/CssModulesPlugin.js +11 -13
- package/lib/css/CssParser.js +3 -3
- package/lib/css/walkCssTokens.js +1 -1
- package/lib/debug/ProfilingPlugin.js +35 -8
- package/lib/dependencies/AMDDefineDependencyParserPlugin.js +12 -17
- package/lib/dependencies/AMDPlugin.js +2 -2
- package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +1 -2
- package/lib/dependencies/CachedConstDependency.js +0 -4
- package/lib/dependencies/CommonJsExportRequireDependency.js +20 -14
- package/lib/dependencies/CommonJsExportsDependency.js +2 -1
- package/lib/dependencies/CommonJsExportsParserPlugin.js +20 -5
- package/lib/dependencies/CommonJsFullRequireDependency.js +6 -4
- package/lib/dependencies/CommonJsImportsParserPlugin.js +16 -7
- package/lib/dependencies/CommonJsRequireContextDependency.js +1 -1
- package/lib/dependencies/CommonJsSelfReferenceDependency.js +4 -4
- package/lib/dependencies/ConstDependency.js +2 -2
- package/lib/dependencies/ContextDependency.js +9 -4
- package/lib/dependencies/ContextDependencyHelpers.js +2 -2
- package/lib/dependencies/ContextDependencyTemplateAsId.js +9 -9
- package/lib/dependencies/ContextDependencyTemplateAsRequireCall.js +9 -9
- package/lib/dependencies/ContextElementDependency.js +22 -11
- package/lib/dependencies/CssIcssImportDependency.js +0 -2
- package/lib/dependencies/CssIcssSymbolDependency.js +2 -2
- package/lib/dependencies/CssImportDependency.js +0 -8
- package/lib/dependencies/CssLocalIdentifierDependency.js +3 -4
- package/lib/dependencies/CssSelfLocalIdentifierDependency.js +2 -2
- package/lib/dependencies/CssUrlDependency.js +0 -6
- package/lib/dependencies/ExportsInfoDependency.js +7 -9
- package/lib/dependencies/ExternalModuleDependency.js +0 -3
- package/lib/dependencies/ExternalModuleInitFragment.js +1 -1
- package/lib/dependencies/HarmonyAcceptDependency.js +1 -1
- package/lib/dependencies/HarmonyAcceptImportDependency.js +0 -4
- package/lib/dependencies/HarmonyCompatibilityDependency.js +0 -1
- package/lib/dependencies/HarmonyDetectionParserPlugin.js +0 -14
- package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +3 -3
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +4 -1
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +29 -35
- package/lib/dependencies/HarmonyImportDependency.js +30 -14
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +20 -23
- package/lib/dependencies/HarmonyImportSideEffectDependency.js +0 -4
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +46 -31
- package/lib/dependencies/HarmonyModulesPlugin.js +3 -3
- package/lib/dependencies/ImportDependency.js +18 -6
- package/lib/dependencies/ImportEagerDependency.js +2 -3
- package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +8 -5
- package/lib/dependencies/ImportMetaContextPlugin.js +0 -1
- package/lib/dependencies/ImportMetaPlugin.js +2 -1
- package/lib/dependencies/ImportParserPlugin.js +288 -45
- package/lib/dependencies/ImportWeakDependency.js +2 -3
- package/lib/dependencies/JsonExportsDependency.js +0 -1
- package/lib/dependencies/LoaderDependency.js +0 -3
- package/lib/dependencies/LoaderImportDependency.js +0 -3
- package/lib/dependencies/LoaderPlugin.js +11 -5
- package/lib/dependencies/ModuleDecoratorDependency.js +2 -4
- package/lib/dependencies/ModuleDependency.js +3 -9
- package/lib/dependencies/NullDependency.js +2 -0
- package/lib/dependencies/ProvidedDependency.js +6 -8
- package/lib/dependencies/PureExpressionDependency.js +0 -1
- package/lib/dependencies/RequireEnsureDependenciesBlock.js +0 -1
- package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +1 -2
- package/lib/dependencies/RequireIncludeDependency.js +2 -2
- package/lib/dependencies/RequireResolveDependency.js +2 -2
- package/lib/dependencies/RuntimeRequirementsDependency.js +2 -3
- package/lib/dependencies/StaticExportsDependency.js +3 -5
- package/lib/dependencies/URLDependency.js +2 -7
- package/lib/dependencies/URLPlugin.js +1 -2
- package/lib/dependencies/WebAssemblyExportImportedDependency.js +2 -2
- package/lib/dependencies/WebAssemblyImportDependency.js +2 -2
- package/lib/dependencies/WebpackIsIncludedDependency.js +2 -3
- package/lib/dependencies/WorkerDependency.js +2 -3
- package/lib/dependencies/WorkerPlugin.js +3 -9
- package/lib/dependencies/processExportInfo.js +2 -3
- package/lib/esm/ModuleChunkFormatPlugin.js +0 -3
- package/lib/esm/ModuleChunkLoadingPlugin.js +2 -1
- package/lib/esm/ModuleChunkLoadingRuntimeModule.js +7 -7
- package/lib/hmr/LazyCompilationPlugin.js +6 -4
- package/lib/hmr/lazyCompilationBackend.js +13 -10
- package/lib/ids/DeterministicChunkIdsPlugin.js +0 -1
- package/lib/ids/NamedChunkIdsPlugin.js +1 -6
- package/lib/ids/NamedModuleIdsPlugin.js +1 -5
- package/lib/ids/NaturalChunkIdsPlugin.js +0 -1
- package/lib/ids/NaturalModuleIdsPlugin.js +0 -1
- package/lib/ids/OccurrenceChunkIdsPlugin.js +0 -1
- package/lib/ids/OccurrenceModuleIdsPlugin.js +0 -1
- package/lib/ids/SyncModuleIdsPlugin.js +4 -3
- package/lib/index.js +8 -7
- package/lib/javascript/ArrayPushCallbackChunkFormatPlugin.js +4 -1
- package/lib/javascript/BasicEvaluatedExpression.js +13 -6
- package/lib/javascript/ChunkFormatHelpers.js +1 -1
- package/lib/javascript/CommonJsChunkFormatPlugin.js +0 -1
- package/lib/javascript/JavascriptGenerator.js +2 -3
- package/lib/javascript/JavascriptModulesPlugin.js +44 -21
- package/lib/javascript/JavascriptParser.js +119 -54
- package/lib/javascript/JavascriptParserHelpers.js +2 -2
- package/lib/javascript/StartupHelpers.js +2 -4
- package/lib/json/JsonData.js +1 -1
- package/lib/json/JsonGenerator.js +4 -5
- package/lib/json/JsonModulesPlugin.js +0 -3
- package/lib/json/JsonParser.js +4 -2
- package/lib/library/AbstractLibraryPlugin.js +2 -2
- package/lib/library/AmdLibraryPlugin.js +0 -1
- package/lib/library/AssignLibraryPlugin.js +23 -12
- package/lib/library/EnableLibraryPlugin.js +7 -11
- package/lib/library/ExportPropertyLibraryPlugin.js +8 -20
- package/lib/library/JsonpLibraryPlugin.js +5 -2
- package/lib/library/ModuleLibraryPlugin.js +88 -43
- package/lib/library/SystemLibraryPlugin.js +0 -1
- package/lib/library/UmdLibraryPlugin.js +12 -18
- package/lib/logging/Logger.js +12 -10
- package/lib/logging/createConsoleLogger.js +15 -14
- package/lib/logging/truncateArgs.js +1 -1
- package/lib/node/CommonJsChunkLoadingPlugin.js +2 -1
- package/lib/node/NodeWatchFileSystem.js +4 -4
- package/lib/node/ReadFileChunkLoadingRuntimeModule.js +2 -2
- package/lib/node/RequireChunkLoadingRuntimeModule.js +5 -2
- package/lib/node/nodeConsole.js +2 -2
- package/lib/optimize/AggressiveSplittingPlugin.js +2 -0
- package/lib/optimize/ConcatenatedModule.js +142 -100
- package/lib/optimize/InnerGraph.js +17 -11
- package/lib/optimize/InnerGraphPlugin.js +0 -3
- package/lib/optimize/ModuleConcatenationPlugin.js +3 -4
- package/lib/optimize/RuntimeChunkPlugin.js +0 -1
- package/lib/optimize/SideEffectsFlagPlugin.js +3 -10
- package/lib/optimize/SplitChunksPlugin.js +46 -40
- package/lib/performance/SizeLimitsPlugin.js +2 -1
- package/lib/prefetch/ChunkPrefetchFunctionRuntimeModule.js +5 -7
- package/lib/prefetch/ChunkPrefetchPreloadPlugin.js +0 -2
- package/lib/prefetch/ChunkPrefetchStartupRuntimeModule.js +0 -1
- package/lib/prefetch/ChunkPrefetchTriggerRuntimeModule.js +2 -2
- package/lib/prefetch/ChunkPreloadTriggerRuntimeModule.js +2 -2
- package/lib/rules/BasicMatcherRulePlugin.js +0 -2
- package/lib/rules/ObjectMatcherRulePlugin.js +0 -1
- package/lib/rules/RuleSetCompiler.js +8 -6
- package/lib/runtime/BaseUriRuntimeModule.js +2 -2
- package/lib/runtime/CompatRuntimeModule.js +0 -1
- package/lib/runtime/GetChunkFilenameRuntimeModule.js +8 -9
- package/lib/runtime/LoadScriptRuntimeModule.js +0 -2
- package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +1 -1
- package/lib/runtime/PublicPathRuntimeModule.js +2 -2
- package/lib/runtime/StartupEntrypointRuntimeModule.js +0 -1
- package/lib/runtime/SystemContextRuntimeModule.js +0 -2
- package/lib/runtime/ToBinaryRuntimeModule.js +64 -0
- package/lib/schemes/DataUriPlugin.js +2 -28
- package/lib/schemes/FileUriPlugin.js +5 -2
- package/lib/schemes/HttpUriPlugin.js +4 -2
- package/lib/schemes/VirtualUrlPlugin.js +11 -11
- package/lib/serialization/NullPrototypeObjectSerializer.js +5 -3
- package/lib/serialization/ObjectMiddleware.js +30 -19
- package/lib/serialization/SerializerMiddleware.js +1 -3
- package/lib/serialization/types.js +1 -1
- package/lib/sharing/ConsumeSharedModule.js +3 -5
- package/lib/sharing/ConsumeSharedPlugin.js +2 -4
- package/lib/sharing/ConsumeSharedRuntimeModule.js +9 -6
- package/lib/sharing/ProvideSharedModule.js +3 -7
- package/lib/sharing/SharePlugin.js +0 -2
- package/lib/sharing/ShareRuntimeModule.js +4 -1
- package/lib/sharing/resolveMatchedConfigs.js +14 -6
- package/lib/sharing/utils.js +0 -6
- package/lib/stats/DefaultStatsFactoryPlugin.js +178 -94
- package/lib/stats/DefaultStatsPresetPlugin.js +15 -9
- package/lib/stats/DefaultStatsPrinterPlugin.js +77 -113
- package/lib/stats/StatsFactory.js +14 -11
- package/lib/url/URLParserPlugin.js +2 -4
- package/lib/util/ArrayHelpers.js +4 -4
- package/lib/util/AsyncQueue.js +1 -0
- package/lib/util/LazySet.js +2 -2
- package/lib/util/StackedCacheMap.js +0 -2
- package/lib/util/TupleSet.js +9 -4
- package/lib/util/URLAbsoluteSpecifier.js +0 -1
- package/lib/util/WeakTupleMap.js +1 -1
- package/lib/util/chainedImports.js +3 -1
- package/lib/util/cleverMerge.js +15 -18
- package/lib/util/comparators.js +2 -4
- package/lib/util/compileBooleanMatcher.js +11 -9
- package/lib/util/concatenate.js +1 -2
- package/lib/util/create-schema-validation.js +0 -1
- package/lib/util/dataURL.js +39 -0
- package/lib/util/deprecation.js +29 -31
- package/lib/util/deterministicGrouping.js +34 -30
- package/lib/util/extractSourceMap.js +319 -0
- package/lib/util/findGraphRoots.js +15 -5
- package/lib/util/fs.js +29 -8
- package/lib/util/semver.js +9 -8
- package/lib/util/smartGrouping.js +41 -26
- package/lib/util/traverseDestructuringAssignmentProperties.js +45 -0
- package/lib/wasm/EnableWasmLoadingPlugin.js +3 -2
- package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +5 -1
- package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +2 -13
- package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +2 -9
- package/lib/wasm-async/AsyncWebAssemblyParser.js +2 -1
- package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +6 -4
- package/lib/wasm-sync/WebAssemblyGenerator.js +1 -3
- package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +1 -4
- package/lib/wasm-sync/WebAssemblyModulesPlugin.js +2 -7
- package/lib/wasm-sync/WebAssemblyParser.js +1 -4
- package/lib/web/JsonpChunkLoadingPlugin.js +2 -1
- package/lib/web/JsonpChunkLoadingRuntimeModule.js +1 -1
- package/lib/web/JsonpTemplatePlugin.js +0 -1
- package/lib/webpack.js +21 -8
- package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +2 -1
- package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +1 -1
- package/package.json +12 -12
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +77 -93
- package/schemas/plugins/BannerPlugin.check.js +1 -1
- package/schemas/plugins/BannerPlugin.json +4 -0
- package/schemas/plugins/IgnorePlugin.json +1 -1
- package/schemas/plugins/ProgressPlugin.json +1 -1
- package/schemas/plugins/SourceMapDevToolPlugin.check.js +1 -1
- package/schemas/plugins/SourceMapDevToolPlugin.json +5 -1
- package/schemas/plugins/schemes/VirtualUrlPlugin.json +3 -3
- package/types.d.ts +1129 -530
- package/SECURITY.md +0 -9
package/lib/sharing/utils.js
CHANGED
|
@@ -151,7 +151,6 @@ const extractCommithashByDomain = {
|
|
|
151
151
|
|
|
152
152
|
/**
|
|
153
153
|
* extract commit hash from parsed url
|
|
154
|
-
* @inner
|
|
155
154
|
* @param {URL} urlParsed parsed url
|
|
156
155
|
* @returns {string} commithash
|
|
157
156
|
*/
|
|
@@ -181,7 +180,6 @@ function getCommithash(urlParsed) {
|
|
|
181
180
|
|
|
182
181
|
/**
|
|
183
182
|
* make url right for URL parse
|
|
184
|
-
* @inner
|
|
185
183
|
* @param {string} gitUrl git url
|
|
186
184
|
* @returns {string} fixed url
|
|
187
185
|
*/
|
|
@@ -193,7 +191,6 @@ function correctUrl(gitUrl) {
|
|
|
193
191
|
|
|
194
192
|
/**
|
|
195
193
|
* make url protocol right for URL parse
|
|
196
|
-
* @inner
|
|
197
194
|
* @param {string} gitUrl git url
|
|
198
195
|
* @returns {string} fixed url
|
|
199
196
|
*/
|
|
@@ -213,7 +210,6 @@ function correctProtocol(gitUrl) {
|
|
|
213
210
|
|
|
214
211
|
/**
|
|
215
212
|
* extract git dep version from hash
|
|
216
|
-
* @inner
|
|
217
213
|
* @param {string} hash hash
|
|
218
214
|
* @returns {string} git dep version
|
|
219
215
|
*/
|
|
@@ -225,7 +221,6 @@ function getVersionFromHash(hash) {
|
|
|
225
221
|
|
|
226
222
|
/**
|
|
227
223
|
* if string can be decoded
|
|
228
|
-
* @inner
|
|
229
224
|
* @param {string} str str to be checked
|
|
230
225
|
* @returns {boolean} if can be decoded
|
|
231
226
|
*/
|
|
@@ -241,7 +236,6 @@ function canBeDecoded(str) {
|
|
|
241
236
|
|
|
242
237
|
/**
|
|
243
238
|
* get right dep version from git url
|
|
244
|
-
* @inner
|
|
245
239
|
* @param {string} gitUrl git url
|
|
246
240
|
* @returns {string} dep version
|
|
247
241
|
*/
|
|
@@ -25,6 +25,9 @@ const {
|
|
|
25
25
|
const { makePathsRelative, parseResource } = require("../util/identifier");
|
|
26
26
|
|
|
27
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 */
|
|
28
31
|
/** @typedef {import("../Chunk")} Chunk */
|
|
29
32
|
/** @typedef {import("../Chunk").ChunkId} ChunkId */
|
|
30
33
|
/** @typedef {import("../Chunk").ChunkName} ChunkName */
|
|
@@ -41,15 +44,12 @@ const { makePathsRelative, parseResource } = require("../util/identifier");
|
|
|
41
44
|
/** @typedef {import("../Dependency")} Dependency */
|
|
42
45
|
/** @typedef {import("../Dependency").DependencyLocation} DependencyLocation */
|
|
43
46
|
/** @typedef {import("../Module")} Module */
|
|
47
|
+
/** @typedef {import("../Module").NameForCondition} NameForCondition */
|
|
44
48
|
/** @typedef {import("../Module").BuildInfo} BuildInfo */
|
|
45
49
|
/** @typedef {import("../ModuleGraphConnection")} ModuleGraphConnection */
|
|
46
50
|
/** @typedef {import("../ModuleProfile")} ModuleProfile */
|
|
47
|
-
/** @typedef {import("../RequestShortener")} RequestShortener */
|
|
48
|
-
/** @typedef {import("../TemplatedPathPlugin").TemplatePath} TemplatePath */
|
|
49
51
|
/** @typedef {import("../WebpackError")} WebpackError */
|
|
50
|
-
/** @typedef {import("../
|
|
51
|
-
/** @typedef {import("./StatsFactory")} StatsFactory */
|
|
52
|
-
/** @typedef {import("./StatsFactory").StatsFactoryContext} StatsFactoryContext */
|
|
52
|
+
/** @typedef {import("../ExportsInfo").ExportInfoName} ExportInfoName */
|
|
53
53
|
|
|
54
54
|
/**
|
|
55
55
|
* @template T
|
|
@@ -57,8 +57,8 @@ const { makePathsRelative, parseResource } = require("../util/identifier");
|
|
|
57
57
|
*/
|
|
58
58
|
|
|
59
59
|
/**
|
|
60
|
-
* @template
|
|
61
|
-
* @typedef {import("../util/smartGrouping").GroupConfig<
|
|
60
|
+
* @template I, G
|
|
61
|
+
* @typedef {import("../util/smartGrouping").GroupConfig<I, G>} GroupConfig
|
|
62
62
|
*/
|
|
63
63
|
|
|
64
64
|
/** @typedef {KnownStatsCompilation & Record<string, EXPECTED_ANY>} StatsCompilation */
|
|
@@ -111,9 +111,7 @@ const { makePathsRelative, parseResource } = require("../util/identifier");
|
|
|
111
111
|
*/
|
|
112
112
|
|
|
113
113
|
/** @typedef {KnownStatsAsset & Record<string, EXPECTED_ANY>} StatsAsset */
|
|
114
|
-
/** @typedef {
|
|
115
|
-
/** @typedef {ChunkName} KnownStatsAssetChunkName */
|
|
116
|
-
/** @typedef {string} KnownStatsAssetChunkIdHint */
|
|
114
|
+
/** @typedef {string[]} ChunkIdHints */
|
|
117
115
|
/**
|
|
118
116
|
* @typedef {object} KnownStatsAsset
|
|
119
117
|
* @property {string} type
|
|
@@ -124,12 +122,12 @@ const { makePathsRelative, parseResource } = require("../util/identifier");
|
|
|
124
122
|
* @property {boolean} comparedForEmit
|
|
125
123
|
* @property {boolean} cached
|
|
126
124
|
* @property {StatsAsset[]=} related
|
|
127
|
-
* @property {
|
|
128
|
-
* @property {
|
|
129
|
-
* @property {
|
|
130
|
-
* @property {
|
|
131
|
-
* @property {
|
|
132
|
-
* @property {
|
|
125
|
+
* @property {ChunkId[]=} chunks
|
|
126
|
+
* @property {ChunkName[]=} chunkNames
|
|
127
|
+
* @property {ChunkIdHints=} chunkIdHints
|
|
128
|
+
* @property {ChunkId[]=} auxiliaryChunks
|
|
129
|
+
* @property {ChunkName[]=} auxiliaryChunkNames
|
|
130
|
+
* @property {ChunkIdHints=} auxiliaryChunkIdHints
|
|
133
131
|
* @property {number=} filteredRelated
|
|
134
132
|
* @property {boolean=} isOverSizeLimit
|
|
135
133
|
*/
|
|
@@ -137,16 +135,16 @@ const { makePathsRelative, parseResource } = require("../util/identifier");
|
|
|
137
135
|
/** @typedef {KnownStatsChunkGroup & Record<string, EXPECTED_ANY>} StatsChunkGroup */
|
|
138
136
|
/**
|
|
139
137
|
* @typedef {object} KnownStatsChunkGroup
|
|
140
|
-
* @property {
|
|
141
|
-
* @property {
|
|
138
|
+
* @property {ChunkName=} name
|
|
139
|
+
* @property {ChunkId[]=} chunks
|
|
142
140
|
* @property {({ name: string, size?: number })[]=} assets
|
|
143
141
|
* @property {number=} filteredAssets
|
|
144
142
|
* @property {number=} assetsSize
|
|
145
143
|
* @property {({ name: string, size?: number })[]=} auxiliaryAssets
|
|
146
144
|
* @property {number=} filteredAuxiliaryAssets
|
|
147
145
|
* @property {number=} auxiliaryAssetsSize
|
|
148
|
-
* @property {
|
|
149
|
-
* @property {
|
|
146
|
+
* @property {Record<string, StatsChunkGroup[]>=} children
|
|
147
|
+
* @property {Record<string, string[]>=} childAssets
|
|
150
148
|
* @property {boolean=} isOverSizeLimit
|
|
151
149
|
*/
|
|
152
150
|
|
|
@@ -159,13 +157,13 @@ const { makePathsRelative, parseResource } = require("../util/identifier");
|
|
|
159
157
|
* @property {(string | null)=} layer
|
|
160
158
|
* @property {string=} identifier
|
|
161
159
|
* @property {string=} name
|
|
162
|
-
* @property {
|
|
160
|
+
* @property {NameForCondition | null=} nameForCondition
|
|
163
161
|
* @property {number=} index
|
|
164
162
|
* @property {number=} preOrderIndex
|
|
165
163
|
* @property {number=} index2
|
|
166
164
|
* @property {number=} postOrderIndex
|
|
167
165
|
* @property {number=} size
|
|
168
|
-
* @property {
|
|
166
|
+
* @property {Record<string, number>=} sizes
|
|
169
167
|
* @property {boolean=} cacheable
|
|
170
168
|
* @property {boolean=} built
|
|
171
169
|
* @property {boolean=} codeGenerated
|
|
@@ -173,10 +171,10 @@ const { makePathsRelative, parseResource } = require("../util/identifier");
|
|
|
173
171
|
* @property {boolean=} cached
|
|
174
172
|
* @property {boolean=} optional
|
|
175
173
|
* @property {boolean=} orphan
|
|
176
|
-
* @property {
|
|
177
|
-
* @property {
|
|
178
|
-
* @property {
|
|
179
|
-
* @property {
|
|
174
|
+
* @property {ModuleId=} id
|
|
175
|
+
* @property {ModuleId | null=} issuerId
|
|
176
|
+
* @property {ChunkId[]=} chunks
|
|
177
|
+
* @property {string[]=} assets
|
|
180
178
|
* @property {boolean=} dependent
|
|
181
179
|
* @property {(string | null)=} issuer
|
|
182
180
|
* @property {(string | null)=} issuerName
|
|
@@ -186,8 +184,8 @@ const { makePathsRelative, parseResource } = require("../util/identifier");
|
|
|
186
184
|
* @property {number=} warnings
|
|
187
185
|
* @property {StatsProfile=} profile
|
|
188
186
|
* @property {StatsModuleReason[]=} reasons
|
|
189
|
-
* @property {
|
|
190
|
-
* @property {
|
|
187
|
+
* @property {boolean | null | ExportInfoName[]=} usedExports
|
|
188
|
+
* @property {ExportInfoName[] | null=} providedExports
|
|
191
189
|
* @property {string[]=} optimizationBailout
|
|
192
190
|
* @property {(number | null)=} depth
|
|
193
191
|
* @property {StatsModule[]=} modules
|
|
@@ -215,7 +213,7 @@ const { makePathsRelative, parseResource } = require("../util/identifier");
|
|
|
215
213
|
* @typedef {object} KnownStatsModuleIssuer
|
|
216
214
|
* @property {string} identifier
|
|
217
215
|
* @property {string} name
|
|
218
|
-
* @property {
|
|
216
|
+
* @property {ModuleId=} id
|
|
219
217
|
* @property {StatsProfile} profile
|
|
220
218
|
*/
|
|
221
219
|
|
|
@@ -232,8 +230,8 @@ const { makePathsRelative, parseResource } = require("../util/identifier");
|
|
|
232
230
|
* @property {string | null} explanation
|
|
233
231
|
* @property {string | null} userRequest
|
|
234
232
|
* @property {(string | null)=} loc
|
|
235
|
-
* @property {
|
|
236
|
-
* @property {
|
|
233
|
+
* @property {ModuleId | null=} moduleId
|
|
234
|
+
* @property {ModuleId | null=} resolvedModuleId
|
|
237
235
|
*/
|
|
238
236
|
|
|
239
237
|
/** @typedef {KnownStatsChunk & Record<string, EXPECTED_ANY>} StatsChunk */
|
|
@@ -253,10 +251,10 @@ const { makePathsRelative, parseResource } = require("../util/identifier");
|
|
|
253
251
|
* @property {string[]} auxiliaryFiles
|
|
254
252
|
* @property {string} hash
|
|
255
253
|
* @property {Record<string, ChunkId[]>} childrenByOrder
|
|
256
|
-
* @property {
|
|
257
|
-
* @property {
|
|
258
|
-
* @property {
|
|
259
|
-
* @property {
|
|
254
|
+
* @property {ChunkId=} id
|
|
255
|
+
* @property {ChunkId[]=} siblings
|
|
256
|
+
* @property {ChunkId[]=} parents
|
|
257
|
+
* @property {ChunkId[]=} children
|
|
260
258
|
* @property {StatsModule[]=} modules
|
|
261
259
|
* @property {number=} filteredModules
|
|
262
260
|
* @property {StatsChunkOrigin[]=} origins
|
|
@@ -270,7 +268,7 @@ const { makePathsRelative, parseResource } = require("../util/identifier");
|
|
|
270
268
|
* @property {string} moduleName
|
|
271
269
|
* @property {string} loc
|
|
272
270
|
* @property {string} request
|
|
273
|
-
* @property {
|
|
271
|
+
* @property {ModuleId=} moduleId
|
|
274
272
|
*/
|
|
275
273
|
|
|
276
274
|
/** @typedef {KnownStatsModuleTraceItem & Record<string, EXPECTED_ANY>} StatsModuleTraceItem */
|
|
@@ -281,8 +279,8 @@ const { makePathsRelative, parseResource } = require("../util/identifier");
|
|
|
281
279
|
* @property {string=} moduleIdentifier
|
|
282
280
|
* @property {string=} moduleName
|
|
283
281
|
* @property {StatsModuleTraceDependency[]=} dependencies
|
|
284
|
-
* @property {
|
|
285
|
-
* @property {
|
|
282
|
+
* @property {ModuleId=} originId
|
|
283
|
+
* @property {ModuleId=} moduleId
|
|
286
284
|
*/
|
|
287
285
|
|
|
288
286
|
/** @typedef {KnownStatsModuleTraceDependency & Record<string, EXPECTED_ANY>} StatsModuleTraceDependency */
|
|
@@ -303,7 +301,7 @@ const { makePathsRelative, parseResource } = require("../util/identifier");
|
|
|
303
301
|
* @property {string=} moduleName
|
|
304
302
|
* @property {string=} loc
|
|
305
303
|
* @property {ChunkId=} chunkId
|
|
306
|
-
* @property {
|
|
304
|
+
* @property {ModuleId=} moduleId
|
|
307
305
|
* @property {StatsModuleTraceItem[]=} moduleTrace
|
|
308
306
|
* @property {string=} details
|
|
309
307
|
* @property {string=} stack
|
|
@@ -555,6 +553,7 @@ const SIMPLE_EXTRACTORS = {
|
|
|
555
553
|
);
|
|
556
554
|
}
|
|
557
555
|
if (!context.cachedGetErrors) {
|
|
556
|
+
/** @type {WeakMap<Compilation, Error[]>} */
|
|
558
557
|
const map = new WeakMap();
|
|
559
558
|
context.cachedGetErrors = (compilation) =>
|
|
560
559
|
map.get(compilation) ||
|
|
@@ -564,6 +563,7 @@ const SIMPLE_EXTRACTORS = {
|
|
|
564
563
|
);
|
|
565
564
|
}
|
|
566
565
|
if (!context.cachedGetWarnings) {
|
|
566
|
+
/** @type {WeakMap<Compilation, Error[]>} */
|
|
567
567
|
const map = new WeakMap();
|
|
568
568
|
context.cachedGetWarnings = (compilation) =>
|
|
569
569
|
map.get(compilation) ||
|
|
@@ -740,14 +740,11 @@ const SIMPLE_EXTRACTORS = {
|
|
|
740
740
|
},
|
|
741
741
|
publicPath: (object, compilation) => {
|
|
742
742
|
object.publicPath = compilation.getPath(
|
|
743
|
-
|
|
744
|
-
(compilation.outputOptions.publicPath)
|
|
743
|
+
compilation.outputOptions.publicPath
|
|
745
744
|
);
|
|
746
745
|
},
|
|
747
746
|
outputPath: (object, compilation) => {
|
|
748
|
-
object.outputPath =
|
|
749
|
-
compilation.outputOptions.path
|
|
750
|
-
);
|
|
747
|
+
object.outputPath = compilation.outputOptions.path;
|
|
751
748
|
},
|
|
752
749
|
assets: (object, compilation, context, options, factory) => {
|
|
753
750
|
const { type } = context;
|
|
@@ -808,7 +805,10 @@ const SIMPLE_EXTRACTORS = {
|
|
|
808
805
|
}
|
|
809
806
|
|
|
810
807
|
object.assetsByChunkName = {};
|
|
811
|
-
for (const [file, chunks] of
|
|
808
|
+
for (const [file, chunks] of [
|
|
809
|
+
...compilationFileToChunks,
|
|
810
|
+
...compilationAuxiliaryFileToChunks
|
|
811
|
+
]) {
|
|
812
812
|
for (const chunk of chunks) {
|
|
813
813
|
const name = chunk.name;
|
|
814
814
|
if (!name) continue;
|
|
@@ -913,7 +913,10 @@ const SIMPLE_EXTRACTORS = {
|
|
|
913
913
|
let filtered = 0;
|
|
914
914
|
if (options.errorDetails === "auto" && rawErrors.length >= 3) {
|
|
915
915
|
filtered = rawErrors
|
|
916
|
-
.map(
|
|
916
|
+
.map(
|
|
917
|
+
(e) =>
|
|
918
|
+
typeof e !== "string" && /** @type {WebpackError} */ (e).details
|
|
919
|
+
)
|
|
917
920
|
.filter(Boolean).length;
|
|
918
921
|
}
|
|
919
922
|
if (
|
|
@@ -947,7 +950,10 @@ const SIMPLE_EXTRACTORS = {
|
|
|
947
950
|
let filtered = 0;
|
|
948
951
|
if (options.errorDetails === "auto") {
|
|
949
952
|
filtered = cachedGetWarnings(compilation)
|
|
950
|
-
.map(
|
|
953
|
+
.map(
|
|
954
|
+
(e) =>
|
|
955
|
+
typeof e !== "string" && /** @type {WebpackError} */ (e).details
|
|
956
|
+
)
|
|
951
957
|
.filter(Boolean).length;
|
|
952
958
|
}
|
|
953
959
|
if (
|
|
@@ -1526,11 +1532,12 @@ const SIMPLE_EXTRACTORS = {
|
|
|
1526
1532
|
object.id = /** @type {ChunkId} */ (chunk.id);
|
|
1527
1533
|
},
|
|
1528
1534
|
chunkRelations: (object, chunk, _context) => {
|
|
1529
|
-
/** @
|
|
1535
|
+
/** @typedef {Set<ChunkId>} ChunkRelations */
|
|
1536
|
+
/** @type {ChunkRelations} */
|
|
1530
1537
|
const parents = new Set();
|
|
1531
|
-
/** @type {
|
|
1538
|
+
/** @type {ChunkRelations} */
|
|
1532
1539
|
const children = new Set();
|
|
1533
|
-
/** @type {
|
|
1540
|
+
/** @type {ChunkRelations} */
|
|
1534
1541
|
const siblings = new Set();
|
|
1535
1542
|
|
|
1536
1543
|
for (const chunkGroup of chunk.groupsIterable) {
|
|
@@ -1696,7 +1703,17 @@ const MODULES_SORTER = {
|
|
|
1696
1703
|
}
|
|
1697
1704
|
};
|
|
1698
1705
|
|
|
1699
|
-
/**
|
|
1706
|
+
/**
|
|
1707
|
+
* @type {{
|
|
1708
|
+
* "compilation.chunks": Record<string, (comparators: Comparator<Chunk>[], context: StatsFactoryContext, options: NormalizedStatsOptions) => void>,
|
|
1709
|
+
* "compilation.modules": Record<string, (comparators: Comparator<Module>[], context: StatsFactoryContext, options: NormalizedStatsOptions) => void>,
|
|
1710
|
+
* "chunk.rootModules": Record<string, (comparators: Comparator<Module>[], context: StatsFactoryContext, options: NormalizedStatsOptions) => void>,
|
|
1711
|
+
* "chunk.modules": Record<string, (comparators: Comparator<Module>[], context: StatsFactoryContext, options: NormalizedStatsOptions) => void>,
|
|
1712
|
+
* "module.modules": Record<string, (comparators: Comparator<Module>[], context: StatsFactoryContext, options: NormalizedStatsOptions) => void>,
|
|
1713
|
+
* "module.reasons": Record<string, (comparators: Comparator<ModuleGraphConnection>[], context: StatsFactoryContext, options: NormalizedStatsOptions) => void>,
|
|
1714
|
+
* "chunk.origins": Record<string, (comparators: Comparator<OriginRecord>[], context: StatsFactoryContext, options: NormalizedStatsOptions) => void>,
|
|
1715
|
+
* }}
|
|
1716
|
+
*/
|
|
1700
1717
|
const SORTERS = {
|
|
1701
1718
|
"compilation.chunks": {
|
|
1702
1719
|
_: (comparators) => {
|
|
@@ -2015,8 +2032,7 @@ const errorsSpaceLimit = (errors, max) => {
|
|
|
2015
2032
|
|
|
2016
2033
|
/**
|
|
2017
2034
|
* @template {{ size: number }} T
|
|
2018
|
-
* @
|
|
2019
|
-
* @param {(R | T)[]} children children
|
|
2035
|
+
* @param {T[]} children children
|
|
2020
2036
|
* @param {T[]} assets assets
|
|
2021
2037
|
* @returns {{ size: number }} asset size
|
|
2022
2038
|
*/
|
|
@@ -2028,11 +2044,13 @@ const assetGroup = (children, assets) => {
|
|
|
2028
2044
|
return { size };
|
|
2029
2045
|
};
|
|
2030
2046
|
|
|
2047
|
+
/** @typedef {{ size: number, sizes: Record<string, number> }} ModuleGroupBySizeResult */
|
|
2048
|
+
|
|
2031
2049
|
/**
|
|
2032
|
-
* @template {
|
|
2050
|
+
* @template {ModuleGroupBySizeResult} T
|
|
2033
2051
|
* @param {Children<T>[]} children children
|
|
2034
2052
|
* @param {KnownStatsModule[]} modules modules
|
|
2035
|
-
* @returns {
|
|
2053
|
+
* @returns {ModuleGroupBySizeResult} size and sizes
|
|
2036
2054
|
*/
|
|
2037
2055
|
const moduleGroup = (children, modules) => {
|
|
2038
2056
|
let size = 0;
|
|
@@ -2069,7 +2087,21 @@ const reasonGroup = (children, reasons) => {
|
|
|
2069
2087
|
const GROUP_EXTENSION_REGEXP = /(\.[^.]+?)(?:\?|(?: \+ \d+ modules?)?$)/;
|
|
2070
2088
|
const GROUP_PATH_REGEXP = /(.+)[/\\][^/\\]+?(?:\?|(?: \+ \d+ modules?)?$)/;
|
|
2071
2089
|
|
|
2072
|
-
/** @typedef {
|
|
2090
|
+
/** @typedef {{ type: string }} BaseGroup */
|
|
2091
|
+
|
|
2092
|
+
/**
|
|
2093
|
+
* @template T
|
|
2094
|
+
* @typedef {BaseGroup & { children: T[], size: number }} BaseGroupWithChildren
|
|
2095
|
+
*/
|
|
2096
|
+
|
|
2097
|
+
/**
|
|
2098
|
+
* @typedef {{
|
|
2099
|
+
* _: (groupConfigs: GroupConfig<KnownStatsAsset, BaseGroup & { filteredChildren: number, size: number } | BaseGroupWithChildren<KnownStatsAsset>>[], context: StatsFactoryContext, options: NormalizedStatsOptions) => void,
|
|
2100
|
+
* groupAssetsByInfo: (groupConfigs: GroupConfig<KnownStatsAsset, BaseGroupWithChildren<KnownStatsAsset>>[], context: StatsFactoryContext, options: NormalizedStatsOptions) => void,
|
|
2101
|
+
* groupAssetsByChunk: (groupConfigs: GroupConfig<KnownStatsAsset, BaseGroupWithChildren<KnownStatsAsset>>[], context: StatsFactoryContext, options: NormalizedStatsOptions) => void,
|
|
2102
|
+
* excludeAssets: (groupConfigs: GroupConfig<KnownStatsAsset, BaseGroup & { filteredChildren: number, size: number }>[], context: StatsFactoryContext, options: NormalizedStatsOptions) => void,
|
|
2103
|
+
* }} AssetsGroupers
|
|
2104
|
+
*/
|
|
2073
2105
|
|
|
2074
2106
|
/** @type {AssetsGroupers} */
|
|
2075
2107
|
const ASSETS_GROUPERS = {
|
|
@@ -2214,9 +2246,16 @@ const ASSETS_GROUPERS = {
|
|
|
2214
2246
|
}
|
|
2215
2247
|
};
|
|
2216
2248
|
|
|
2217
|
-
/**
|
|
2249
|
+
/**
|
|
2250
|
+
* @typedef {{
|
|
2251
|
+
* _: (groupConfigs: GroupConfig<KnownStatsModule, BaseGroup & { filteredChildren?: number, children?: KnownStatsModule[], size: number, sizes: Record<string, number> }>[], context: StatsFactoryContext, options: NormalizedStatsOptions) => void,
|
|
2252
|
+
* excludeModules: (groupConfigs: GroupConfig<KnownStatsModule, BaseGroup & { filteredChildren: number, size: number, sizes: Record<string, number> }>[], context: StatsFactoryContext, options: NormalizedStatsOptions) => void,
|
|
2253
|
+
* }} ModulesGroupers
|
|
2254
|
+
*/
|
|
2218
2255
|
|
|
2219
|
-
/**
|
|
2256
|
+
/**
|
|
2257
|
+
* @type {(type: ExcludeModulesType) => ModulesGroupers}
|
|
2258
|
+
*/
|
|
2220
2259
|
const MODULES_GROUPERS = (type) => ({
|
|
2221
2260
|
_: (groupConfigs, context, options) => {
|
|
2222
2261
|
/**
|
|
@@ -2235,7 +2274,11 @@ const MODULES_GROUPERS = (type) => ({
|
|
|
2235
2274
|
type,
|
|
2236
2275
|
[name]: Boolean(key),
|
|
2237
2276
|
...(exclude ? { filteredChildren: modules.length } : { children }),
|
|
2238
|
-
...moduleGroup(
|
|
2277
|
+
...moduleGroup(
|
|
2278
|
+
/** @type {(KnownStatsModule & ModuleGroupBySizeResult)[]} */
|
|
2279
|
+
(children),
|
|
2280
|
+
modules
|
|
2281
|
+
)
|
|
2239
2282
|
})
|
|
2240
2283
|
});
|
|
2241
2284
|
};
|
|
@@ -2292,7 +2335,11 @@ const MODULES_GROUPERS = (type) => ({
|
|
|
2292
2335
|
type: `${key} modules`,
|
|
2293
2336
|
moduleType: key,
|
|
2294
2337
|
...(exclude ? { filteredChildren: modules.length } : { children }),
|
|
2295
|
-
...moduleGroup(
|
|
2338
|
+
...moduleGroup(
|
|
2339
|
+
/** @type {(KnownStatsModule & ModuleGroupBySizeResult)[]} */
|
|
2340
|
+
(children),
|
|
2341
|
+
modules
|
|
2342
|
+
)
|
|
2296
2343
|
};
|
|
2297
2344
|
}
|
|
2298
2345
|
});
|
|
@@ -2304,7 +2351,11 @@ const MODULES_GROUPERS = (type) => ({
|
|
|
2304
2351
|
type: "modules by layer",
|
|
2305
2352
|
layer: key,
|
|
2306
2353
|
children,
|
|
2307
|
-
...moduleGroup(
|
|
2354
|
+
...moduleGroup(
|
|
2355
|
+
/** @type {(KnownStatsModule & ModuleGroupBySizeResult)[]} */
|
|
2356
|
+
(children),
|
|
2357
|
+
modules
|
|
2358
|
+
)
|
|
2308
2359
|
})
|
|
2309
2360
|
});
|
|
2310
2361
|
}
|
|
@@ -2351,7 +2402,11 @@ const MODULES_GROUPERS = (type) => ({
|
|
|
2351
2402
|
: "modules by extension",
|
|
2352
2403
|
name: isDataUrl ? key.slice(/* 'data:'.length */ 5) : key,
|
|
2353
2404
|
children,
|
|
2354
|
-
...moduleGroup(
|
|
2405
|
+
...moduleGroup(
|
|
2406
|
+
/** @type {(KnownStatsModule & ModuleGroupBySizeResult)[]} */
|
|
2407
|
+
(children),
|
|
2408
|
+
modules
|
|
2409
|
+
)
|
|
2355
2410
|
};
|
|
2356
2411
|
}
|
|
2357
2412
|
});
|
|
@@ -2373,13 +2428,21 @@ const MODULES_GROUPERS = (type) => ({
|
|
|
2373
2428
|
createGroup: (key, children, modules) => ({
|
|
2374
2429
|
type: "hidden modules",
|
|
2375
2430
|
filteredChildren: children.length,
|
|
2376
|
-
...moduleGroup(
|
|
2431
|
+
...moduleGroup(
|
|
2432
|
+
/** @type {(KnownStatsModule & ModuleGroupBySizeResult)[]} */
|
|
2433
|
+
(children),
|
|
2434
|
+
modules
|
|
2435
|
+
)
|
|
2377
2436
|
})
|
|
2378
2437
|
});
|
|
2379
2438
|
}
|
|
2380
2439
|
});
|
|
2381
2440
|
|
|
2382
|
-
/**
|
|
2441
|
+
/**
|
|
2442
|
+
* @typedef {{
|
|
2443
|
+
* groupReasonsByOrigin: (groupConfigs: GroupConfig<KnownStatsModuleReason, BaseGroup & { module: string, children: KnownStatsModuleReason[], active: boolean }>[], context: StatsFactoryContext, options: NormalizedStatsOptions) => void
|
|
2444
|
+
* }} ModuleReasonsGroupers
|
|
2445
|
+
*/
|
|
2383
2446
|
|
|
2384
2447
|
/** @type {ModuleReasonsGroupers} */
|
|
2385
2448
|
const MODULE_REASONS_GROUPERS = {
|
|
@@ -2396,7 +2459,17 @@ const MODULE_REASONS_GROUPERS = {
|
|
|
2396
2459
|
}
|
|
2397
2460
|
};
|
|
2398
2461
|
|
|
2399
|
-
/**
|
|
2462
|
+
/**
|
|
2463
|
+
* @type {{
|
|
2464
|
+
* "compilation.assets": AssetsGroupers,
|
|
2465
|
+
* "asset.related": AssetsGroupers,
|
|
2466
|
+
* "compilation.modules": ModulesGroupers,
|
|
2467
|
+
* "chunk.modules": ModulesGroupers,
|
|
2468
|
+
* "chunk.rootModules": ModulesGroupers,
|
|
2469
|
+
* "module.modules": ModulesGroupers,
|
|
2470
|
+
* "module.reasons": ModuleReasonsGroupers,
|
|
2471
|
+
* }}
|
|
2472
|
+
*/
|
|
2400
2473
|
const RESULT_GROUPERS = {
|
|
2401
2474
|
"compilation.assets": ASSETS_GROUPERS,
|
|
2402
2475
|
"asset.related": ASSETS_GROUPERS,
|
|
@@ -2462,7 +2535,14 @@ const sortByField = (field) => {
|
|
|
2462
2535
|
return sortFn;
|
|
2463
2536
|
};
|
|
2464
2537
|
|
|
2465
|
-
/**
|
|
2538
|
+
/**
|
|
2539
|
+
* @typedef {{
|
|
2540
|
+
* assetsSort: (comparators: Comparator<Asset>[], context: StatsFactoryContext, options: NormalizedStatsOptions) => void,
|
|
2541
|
+
* _: (comparators: Comparator<Asset>[], context: StatsFactoryContext, options: NormalizedStatsOptions) => void
|
|
2542
|
+
* }} AssetSorters
|
|
2543
|
+
*/
|
|
2544
|
+
|
|
2545
|
+
/** @type {AssetSorters} */
|
|
2466
2546
|
const ASSET_SORTERS = {
|
|
2467
2547
|
assetsSort: (comparators, context, { assetsSort }) => {
|
|
2468
2548
|
comparators.push(sortByField(assetsSort));
|
|
@@ -2472,7 +2552,16 @@ const ASSET_SORTERS = {
|
|
|
2472
2552
|
}
|
|
2473
2553
|
};
|
|
2474
2554
|
|
|
2475
|
-
/**
|
|
2555
|
+
/**
|
|
2556
|
+
* @type {{
|
|
2557
|
+
* "compilation.chunks": { chunksSort: (comparators: Comparator<Chunk>[], context: StatsFactoryContext, options: NormalizedStatsOptions) => void },
|
|
2558
|
+
* "compilation.modules": { modulesSort: (comparators: Comparator<Module>[], context: StatsFactoryContext, options: NormalizedStatsOptions) => void },
|
|
2559
|
+
* "chunk.modules": { chunkModulesSort: (comparators: Comparator<Module>[], context: StatsFactoryContext, options: NormalizedStatsOptions) => void },
|
|
2560
|
+
* "module.modules": { nestedModulesSort: (comparators: Comparator<Module>[], context: StatsFactoryContext, options: NormalizedStatsOptions) => void },
|
|
2561
|
+
* "compilation.assets": AssetSorters,
|
|
2562
|
+
* "asset.related": AssetSorters,
|
|
2563
|
+
* }}
|
|
2564
|
+
*/
|
|
2476
2565
|
const RESULT_SORTERS = {
|
|
2477
2566
|
"compilation.chunks": {
|
|
2478
2567
|
chunksSort: (comparators, context, { chunksSort }) => {
|
|
@@ -2500,9 +2589,14 @@ const RESULT_SORTERS = {
|
|
|
2500
2589
|
|
|
2501
2590
|
/**
|
|
2502
2591
|
* @template T
|
|
2503
|
-
* @
|
|
2592
|
+
* @typedef {T extends Record<string, Record<string, infer F>> ? F : never} ExtractFunction
|
|
2593
|
+
*/
|
|
2594
|
+
|
|
2595
|
+
/**
|
|
2596
|
+
* @template {Record<string, Record<string, EXPECTED_ANY>>} T
|
|
2597
|
+
* @param {T} config the config see above
|
|
2504
2598
|
* @param {NormalizedStatsOptions} options stats options
|
|
2505
|
-
* @param {(hookFor:
|
|
2599
|
+
* @param {(hookFor: keyof T, fn: ExtractFunction<T>) => void} fn handler function called for every active line in config
|
|
2506
2600
|
* @returns {void}
|
|
2507
2601
|
*/
|
|
2508
2602
|
const iterateConfig = (config, options, fn) => {
|
|
@@ -2596,18 +2690,13 @@ class DefaultStatsFactoryPlugin {
|
|
|
2596
2690
|
* @param {NormalizedStatsOptions} options stats options
|
|
2597
2691
|
*/
|
|
2598
2692
|
(stats, options) => {
|
|
2599
|
-
iterateConfig(
|
|
2600
|
-
|
|
2601
|
-
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
.tap(PLUGIN_NAME, (obj, data, ctx) =>
|
|
2607
|
-
fn(obj, data, ctx, options, stats)
|
|
2608
|
-
);
|
|
2609
|
-
}
|
|
2610
|
-
);
|
|
2693
|
+
iterateConfig(SIMPLE_EXTRACTORS, options, (hookFor, fn) => {
|
|
2694
|
+
stats.hooks.extract
|
|
2695
|
+
.for(hookFor)
|
|
2696
|
+
.tap(PLUGIN_NAME, (obj, data, ctx) =>
|
|
2697
|
+
fn(obj, data, ctx, options, stats)
|
|
2698
|
+
);
|
|
2699
|
+
});
|
|
2611
2700
|
iterateConfig(FILTER, options, (hookFor, fn) => {
|
|
2612
2701
|
stats.hooks.filter
|
|
2613
2702
|
.for(hookFor)
|
|
@@ -2636,18 +2725,13 @@ class DefaultStatsFactoryPlugin {
|
|
|
2636
2725
|
fn(comparators, ctx, options)
|
|
2637
2726
|
);
|
|
2638
2727
|
});
|
|
2639
|
-
iterateConfig(
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
.tap(PLUGIN_NAME, (groupConfigs, ctx) =>
|
|
2647
|
-
fn(groupConfigs, ctx, options)
|
|
2648
|
-
);
|
|
2649
|
-
}
|
|
2650
|
-
);
|
|
2728
|
+
iterateConfig(RESULT_GROUPERS, options, (hookFor, fn) => {
|
|
2729
|
+
stats.hooks.groupResults
|
|
2730
|
+
.for(hookFor)
|
|
2731
|
+
.tap(PLUGIN_NAME, (groupConfigs, ctx) =>
|
|
2732
|
+
fn(groupConfigs, ctx, options)
|
|
2733
|
+
);
|
|
2734
|
+
});
|
|
2651
2735
|
for (const key of Object.keys(ITEM_NAMES)) {
|
|
2652
2736
|
const itemName = ITEM_NAMES[key];
|
|
2653
2737
|
stats.hooks.getItemName.for(key).tap(PLUGIN_NAME, () => itemName);
|
|
@@ -2669,7 +2753,7 @@ class DefaultStatsFactoryPlugin {
|
|
|
2669
2753
|
*/
|
|
2670
2754
|
(comp, { _index: idx }) => {
|
|
2671
2755
|
const children =
|
|
2672
|
-
/** @type {
|
|
2756
|
+
/** @type {StatsValue[]} */
|
|
2673
2757
|
(options.children);
|
|
2674
2758
|
if (idx < children.length) {
|
|
2675
2759
|
return compilation.createStatsFactory(
|
|
@@ -284,10 +284,15 @@ const DEFAULTS = {
|
|
|
284
284
|
colors: () => false
|
|
285
285
|
};
|
|
286
286
|
|
|
287
|
+
/**
|
|
288
|
+
* @template T
|
|
289
|
+
* @typedef {(value: T, ...args: EXPECTED_ANY[]) => boolean} NormalizeFunction
|
|
290
|
+
*/
|
|
291
|
+
|
|
287
292
|
/**
|
|
288
293
|
* @template {string} T
|
|
289
|
-
* @param {string | ({ test: (value: T) => boolean }) |
|
|
290
|
-
* @returns {
|
|
294
|
+
* @param {string | ({ test: (value: T) => boolean }) | NormalizeFunction<T> | boolean} item item to normalize
|
|
295
|
+
* @returns {NormalizeFunction<T>} normalize fn
|
|
291
296
|
*/
|
|
292
297
|
const normalizeFilter = (item) => {
|
|
293
298
|
if (typeof item === "string") {
|
|
@@ -303,12 +308,19 @@ const normalizeFilter = (item) => {
|
|
|
303
308
|
return () => item;
|
|
304
309
|
}
|
|
305
310
|
|
|
306
|
-
return /** @type {
|
|
311
|
+
return /** @type {NormalizeFunction<T>} */ (item);
|
|
307
312
|
};
|
|
308
313
|
|
|
309
314
|
/** @typedef {keyof (KnownNormalizedStatsOptions | StatsOptions)} NormalizerKeys */
|
|
310
315
|
/** @typedef {{ [Key in NormalizerKeys]?: (value: StatsOptions[Key]) => KnownNormalizedStatsOptions[Key] }} Normalizers */
|
|
311
316
|
|
|
317
|
+
/**
|
|
318
|
+
* @callback WarningFilterFn
|
|
319
|
+
* @param {StatsError} warning warning
|
|
320
|
+
* @param {string} warningString warning string
|
|
321
|
+
* @returns {boolean} result
|
|
322
|
+
*/
|
|
323
|
+
|
|
312
324
|
/** @type {Normalizers} */
|
|
313
325
|
const NORMALIZER = {
|
|
314
326
|
excludeModules: (value) => {
|
|
@@ -329,12 +341,6 @@ const NORMALIZER = {
|
|
|
329
341
|
if (!Array.isArray(value)) {
|
|
330
342
|
value = value ? [value] : [];
|
|
331
343
|
}
|
|
332
|
-
/**
|
|
333
|
-
* @callback WarningFilterFn
|
|
334
|
-
* @param {StatsError} warning warning
|
|
335
|
-
* @param {string} warningString warning string
|
|
336
|
-
* @returns {boolean} result
|
|
337
|
-
*/
|
|
338
344
|
return value.map(
|
|
339
345
|
/**
|
|
340
346
|
* @param {StatsOptions["warningsFilter"]} filter a warning filter
|