webpack 5.93.0 → 5.94.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 +8 -5
- package/bin/webpack.js +6 -7
- package/hot/log.js +1 -2
- package/hot/only-dev-server.js +1 -1
- package/hot/poll.js +1 -1
- package/hot/signal.js +1 -1
- package/lib/APIPlugin.js +4 -3
- package/lib/AbstractMethodError.js +10 -5
- package/lib/AutomaticPrefetchPlugin.js +1 -1
- package/lib/BannerPlugin.js +12 -6
- package/lib/Cache.js +8 -10
- package/lib/CacheFacade.js +3 -3
- package/lib/CaseSensitiveModulesWarning.js +5 -7
- package/lib/Chunk.js +14 -11
- package/lib/ChunkGraph.js +58 -36
- package/lib/ChunkGroup.js +2 -3
- package/lib/ChunkTemplate.js +43 -0
- package/lib/CleanPlugin.js +10 -11
- package/lib/CodeGenerationResults.js +6 -5
- package/lib/CommentCompilationWarning.js +0 -1
- package/lib/Compilation.js +223 -191
- package/lib/Compiler.js +81 -82
- package/lib/ConcatenationScope.js +3 -6
- package/lib/ConditionalInitFragment.js +6 -7
- package/lib/ConstPlugin.js +7 -15
- package/lib/ContextExclusionPlugin.js +3 -3
- package/lib/ContextModule.js +33 -20
- package/lib/ContextModuleFactory.js +89 -44
- package/lib/ContextReplacementPlugin.js +10 -9
- package/lib/DefinePlugin.js +75 -68
- package/lib/DelegatedModule.js +7 -3
- package/lib/DelegatedModuleFactoryPlugin.js +36 -22
- package/lib/DelegatedPlugin.js +4 -0
- package/lib/DependenciesBlock.js +0 -1
- package/lib/Dependency.js +10 -14
- package/lib/DllEntryPlugin.js +4 -2
- package/lib/DllModuleFactory.js +1 -0
- package/lib/DllPlugin.js +9 -7
- package/lib/DllReferencePlugin.js +30 -15
- package/lib/EntryPlugin.js +1 -3
- package/lib/EnvironmentPlugin.js +5 -2
- package/lib/ErrorHelpers.js +11 -12
- package/lib/EvalDevToolModulePlugin.js +10 -12
- package/lib/EvalSourceMapDevToolPlugin.js +15 -13
- package/lib/ExportsInfo.js +185 -120
- package/lib/ExternalModule.js +104 -64
- package/lib/ExternalModuleFactoryPlugin.js +23 -10
- package/lib/FileSystemInfo.js +791 -422
- package/lib/FlagAllModulesAsUsedPlugin.js +1 -1
- package/lib/FlagDependencyExportsPlugin.js +12 -11
- package/lib/FlagDependencyUsagePlugin.js +1 -1
- package/lib/Generator.js +2 -5
- package/lib/GraphHelpers.js +3 -2
- package/lib/HookWebpackError.js +8 -10
- package/lib/HotModuleReplacementPlugin.js +78 -64
- package/lib/IgnoreErrorModuleFactory.js +3 -3
- package/lib/IgnorePlugin.js +1 -3
- package/lib/IgnoreWarningsPlugin.js +6 -9
- package/lib/InitFragment.js +2 -3
- package/lib/LibManifestPlugin.js +4 -3
- package/lib/MainTemplate.js +72 -19
- package/lib/Module.js +25 -9
- package/lib/ModuleBuildError.js +4 -11
- package/lib/ModuleDependencyError.js +5 -5
- package/lib/ModuleDependencyWarning.js +5 -5
- package/lib/ModuleError.js +1 -5
- package/lib/ModuleFilenameHelpers.js +29 -46
- package/lib/ModuleGraph.js +7 -6
- package/lib/ModuleGraphConnection.js +6 -6
- package/lib/ModuleInfoHeaderPlugin.js +82 -30
- package/lib/ModuleParseError.js +8 -9
- package/lib/ModuleRestoreError.js +1 -1
- package/lib/ModuleStoreError.js +1 -1
- package/lib/ModuleTemplate.js +33 -1
- package/lib/ModuleTypeConstants.js +21 -22
- package/lib/ModuleWarning.js +1 -5
- package/lib/MultiCompiler.js +24 -26
- package/lib/MultiStats.js +73 -31
- package/lib/MultiWatching.js +1 -1
- package/lib/NormalModule.js +126 -69
- package/lib/NormalModuleFactory.js +53 -49
- package/lib/OptimizationStages.js +3 -3
- package/lib/ProgressPlugin.js +9 -9
- package/lib/ProvidePlugin.js +4 -4
- package/lib/RuntimeGlobals.js +71 -70
- package/lib/RuntimeModule.js +1 -1
- package/lib/RuntimePlugin.js +24 -12
- package/lib/RuntimeTemplate.js +40 -44
- package/lib/SizeFormatHelpers.js +2 -4
- package/lib/SourceMapDevToolPlugin.js +42 -34
- package/lib/Stats.js +5 -11
- package/lib/Template.js +18 -24
- package/lib/TemplatedPathPlugin.js +12 -10
- package/lib/WarnDeprecatedOptionPlugin.js +0 -1
- package/lib/WatchIgnorePlugin.js +26 -9
- package/lib/Watching.js +10 -5
- package/lib/WebpackOptionsApply.js +84 -62
- package/lib/asset/AssetGenerator.js +107 -42
- package/lib/asset/AssetModulesPlugin.js +29 -23
- package/lib/asset/AssetSourceGenerator.js +2 -7
- package/lib/async-modules/AwaitDependenciesInitFragment.js +6 -7
- package/lib/buildChunkGraph.js +14 -19
- package/lib/cache/IdleFileCachePlugin.js +4 -4
- package/lib/cache/MemoryWithGcCachePlugin.js +5 -5
- package/lib/cache/PackFileCacheStrategy.js +51 -50
- package/lib/cache/ResolverCachePlugin.js +6 -6
- package/lib/cache/mergeEtags.js +16 -21
- package/lib/cli.js +148 -104
- package/lib/config/browserslistTargetHandler.js +16 -13
- package/lib/config/defaults.js +31 -28
- package/lib/config/normalization.js +335 -344
- package/lib/config/target.js +42 -52
- package/lib/container/ContainerEntryModule.js +2 -2
- package/lib/container/ContainerPlugin.js +1 -1
- package/lib/container/RemoteRuntimeModule.js +11 -8
- package/lib/container/options.js +18 -4
- package/lib/css/CssExportsGenerator.js +26 -24
- package/lib/css/CssGenerator.js +9 -4
- package/lib/css/CssLoadingRuntimeModule.js +10 -10
- package/lib/css/CssModulesPlugin.js +127 -47
- package/lib/css/CssParser.js +20 -18
- package/lib/css/walkCssTokens.js +80 -95
- package/lib/debug/ProfilingPlugin.js +19 -20
- package/lib/dependencies/AMDDefineDependency.js +1 -1
- package/lib/dependencies/AMDDefineDependencyParserPlugin.js +83 -47
- package/lib/dependencies/AMDRequireArrayDependency.js +9 -10
- package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +22 -16
- package/lib/dependencies/AMDRuntimeModules.js +2 -2
- package/lib/dependencies/CommonJsDependencyHelpers.js +6 -2
- package/lib/dependencies/CommonJsExportRequireDependency.js +37 -41
- package/lib/dependencies/CommonJsExportsDependency.js +0 -1
- package/lib/dependencies/CommonJsExportsParserPlugin.js +19 -23
- package/lib/dependencies/CommonJsFullRequireDependency.js +1 -1
- package/lib/dependencies/CommonJsImportsParserPlugin.js +52 -61
- package/lib/dependencies/CommonJsSelfReferenceDependency.js +6 -8
- package/lib/dependencies/ConstDependency.js +1 -1
- package/lib/dependencies/ContextDependency.js +1 -1
- package/lib/dependencies/ContextDependencyHelpers.js +31 -34
- package/lib/dependencies/ContextElementDependency.js +2 -2
- package/lib/dependencies/CriticalDependencyWarning.js +1 -1
- package/lib/dependencies/CssExportDependency.js +7 -7
- package/lib/dependencies/CssImportDependency.js +0 -2
- package/lib/dependencies/CssLocalIdentifierDependency.js +3 -3
- package/lib/dependencies/CssSelfLocalIdentifierDependency.js +2 -1
- package/lib/dependencies/CssUrlDependency.js +4 -5
- package/lib/dependencies/DynamicExports.js +5 -5
- package/lib/dependencies/ExportsInfoDependency.js +1 -2
- package/lib/dependencies/HarmonyAcceptImportDependency.js +1 -1
- package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +4 -5
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +27 -16
- package/lib/dependencies/HarmonyExportExpressionDependency.js +1 -1
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +107 -64
- package/lib/dependencies/HarmonyExports.js +2 -2
- package/lib/dependencies/HarmonyImportDependency.js +2 -4
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +19 -4
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +40 -15
- package/lib/dependencies/ImportDependency.js +1 -1
- package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +5 -5
- package/lib/dependencies/ImportMetaPlugin.js +11 -13
- package/lib/dependencies/ImportParserPlugin.js +39 -44
- package/lib/dependencies/JsonExportsDependency.js +22 -18
- package/lib/dependencies/LoaderPlugin.js +47 -36
- package/lib/dependencies/LocalModule.js +1 -1
- package/lib/dependencies/LocalModulesHelpers.js +4 -4
- package/lib/dependencies/ModuleDecoratorDependency.js +1 -1
- package/lib/dependencies/ProvidedDependency.js +1 -1
- package/lib/dependencies/PureExpressionDependency.js +6 -6
- package/lib/dependencies/RequireContextDependencyParserPlugin.js +1 -1
- package/lib/dependencies/RuntimeRequirementsDependency.js +1 -1
- package/lib/dependencies/SystemPlugin.js +1 -1
- package/lib/dependencies/URLDependency.js +3 -3
- package/lib/dependencies/URLPlugin.js +66 -12
- package/lib/dependencies/WorkerPlugin.js +25 -24
- package/lib/dependencies/processExportInfo.js +3 -1
- package/lib/electron/ElectronTargetPlugin.js +1 -0
- package/lib/esm/ModuleChunkFormatPlugin.js +3 -3
- package/lib/esm/ModuleChunkLoadingRuntimeModule.js +7 -3
- package/lib/formatLocation.js +1 -2
- package/lib/hmr/HotModuleReplacement.runtime.js +4 -5
- package/lib/hmr/HotModuleReplacementRuntimeModule.js +1 -0
- package/lib/hmr/JavascriptHotModuleReplacement.runtime.js +9 -12
- package/lib/hmr/LazyCompilationPlugin.js +27 -12
- package/lib/hmr/lazyCompilationBackend.js +64 -40
- package/lib/ids/ChunkModuleIdRangePlugin.js +1 -3
- package/lib/ids/DeterministicChunkIdsPlugin.js +2 -4
- package/lib/ids/DeterministicModuleIdsPlugin.js +1 -1
- package/lib/ids/HashedModuleIdsPlugin.js +5 -1
- package/lib/ids/IdHelpers.js +29 -39
- package/lib/ids/SyncModuleIdsPlugin.js +7 -2
- package/lib/index.js +1 -5
- package/lib/javascript/ArrayPushCallbackChunkFormatPlugin.js +5 -4
- package/lib/javascript/BasicEvaluatedExpression.js +4 -19
- package/lib/javascript/ChunkHelpers.js +1 -1
- package/lib/javascript/CommonJsChunkFormatPlugin.js +3 -2
- package/lib/javascript/EnableChunkLoadingPlugin.js +7 -6
- package/lib/javascript/JavascriptGenerator.js +23 -7
- package/lib/javascript/JavascriptModulesPlugin.js +91 -69
- package/lib/javascript/JavascriptParser.js +179 -200
- package/lib/javascript/JavascriptParserHelpers.js +20 -21
- package/lib/javascript/StartupHelpers.js +41 -13
- package/lib/json/JsonGenerator.js +7 -13
- package/lib/json/JsonModulesPlugin.js +1 -4
- package/lib/json/JsonParser.js +5 -3
- package/lib/library/AmdLibraryPlugin.js +12 -16
- package/lib/library/AssignLibraryPlugin.js +8 -10
- package/lib/library/EnableLibraryPlugin.js +15 -14
- package/lib/library/JsonpLibraryPlugin.js +2 -1
- package/lib/library/ModernModuleLibraryPlugin.js +8 -6
- package/lib/library/ModuleLibraryPlugin.js +2 -1
- package/lib/library/SystemLibraryPlugin.js +2 -1
- package/lib/library/UmdLibraryPlugin.js +66 -92
- package/lib/logging/Logger.js +32 -4
- package/lib/logging/createConsoleLogger.js +12 -13
- package/lib/logging/runtime.js +7 -8
- package/lib/logging/truncateArgs.js +5 -8
- package/lib/node/NodeWatchFileSystem.js +3 -18
- package/lib/node/ReadFileChunkLoadingRuntimeModule.js +2 -2
- package/lib/node/ReadFileCompileAsyncWasmPlugin.js +1 -0
- package/lib/node/RequireChunkLoadingRuntimeModule.js +2 -2
- package/lib/node/nodeConsole.js +22 -22
- package/lib/optimize/AggressiveMergingPlugin.js +2 -4
- package/lib/optimize/AggressiveSplittingPlugin.js +16 -19
- package/lib/optimize/ConcatenatedModule.js +80 -48
- package/lib/optimize/EnsureChunkConditionsPlugin.js +1 -1
- package/lib/optimize/FlagIncludedChunksPlugin.js +3 -3
- package/lib/optimize/InnerGraph.js +17 -17
- package/lib/optimize/InnerGraphPlugin.js +8 -7
- package/lib/optimize/LimitChunkCountPlugin.js +2 -3
- package/lib/optimize/MangleExportsPlugin.js +1 -0
- package/lib/optimize/MinMaxSizeWarning.js +1 -1
- package/lib/optimize/ModuleConcatenationPlugin.js +54 -78
- package/lib/optimize/RealContentHashPlugin.js +7 -10
- package/lib/optimize/RemoveParentModulesPlugin.js +3 -3
- package/lib/optimize/SideEffectsFlagPlugin.js +6 -2
- package/lib/optimize/SplitChunksPlugin.js +34 -30
- package/lib/performance/SizeLimitsPlugin.js +2 -2
- package/lib/prefetch/ChunkPrefetchTriggerRuntimeModule.js +1 -1
- package/lib/prefetch/ChunkPreloadTriggerRuntimeModule.js +1 -1
- package/lib/rules/BasicEffectRulePlugin.js +3 -1
- package/lib/rules/BasicMatcherRulePlugin.js +3 -1
- package/lib/rules/ObjectMatcherRulePlugin.js +4 -1
- package/lib/rules/RuleSetCompiler.js +41 -22
- package/lib/rules/UseEffectRulePlugin.js +36 -32
- package/lib/runtime/AsyncModuleRuntimeModule.js +1 -1
- package/lib/runtime/AutoPublicPathRuntimeModule.js +8 -3
- package/lib/runtime/CreateFakeNamespaceObjectRuntimeModule.js +2 -2
- package/lib/runtime/DefinePropertyGettersRuntimeModule.js +1 -1
- package/lib/runtime/EnsureChunkRuntimeModule.js +10 -11
- package/lib/runtime/GetChunkFilenameRuntimeModule.js +11 -17
- package/lib/runtime/LoadScriptRuntimeModule.js +17 -18
- package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +1 -3
- package/lib/schemes/DataUriPlugin.js +1 -1
- package/lib/schemes/HttpUriPlugin.js +241 -126
- package/lib/serialization/BinaryMiddleware.js +44 -28
- package/lib/serialization/DateObjectSerializer.js +1 -0
- package/lib/serialization/ErrorObjectSerializer.js +2 -0
- package/lib/serialization/FileMiddleware.js +154 -106
- package/lib/serialization/MapObjectSerializer.js +2 -1
- package/lib/serialization/NullPrototypeObjectSerializer.js +3 -2
- package/lib/serialization/ObjectMiddleware.js +52 -56
- package/lib/serialization/PlainObjectSerializer.js +32 -6
- package/lib/serialization/RegExpObjectSerializer.js +1 -0
- package/lib/serialization/Serializer.js +4 -5
- package/lib/serialization/SerializerMiddleware.js +6 -6
- package/lib/serialization/SetObjectSerializer.js +2 -1
- package/lib/sharing/ConsumeSharedPlugin.js +116 -97
- package/lib/sharing/ConsumeSharedRuntimeModule.js +4 -4
- package/lib/sharing/ProvideForSharedDependency.js +0 -1
- package/lib/sharing/ProvideSharedPlugin.js +2 -2
- package/lib/sharing/resolveMatchedConfigs.js +2 -1
- package/lib/sharing/utils.js +15 -27
- package/lib/stats/DefaultStatsFactoryPlugin.js +424 -281
- package/lib/stats/DefaultStatsPresetPlugin.js +73 -18
- package/lib/stats/DefaultStatsPrinterPlugin.js +370 -101
- package/lib/stats/StatsFactory.js +127 -56
- package/lib/stats/StatsPrinter.js +75 -44
- package/lib/util/ArrayHelpers.js +8 -4
- package/lib/util/ArrayQueue.js +1 -1
- package/lib/util/AsyncQueue.js +31 -12
- package/lib/util/IterableHelpers.js +3 -4
- package/lib/util/LazyBucketSortedSet.js +60 -44
- package/lib/util/LazySet.js +1 -0
- package/lib/util/MapHelpers.js +1 -3
- package/lib/util/ParallelismFactorCalculator.js +1 -1
- package/lib/util/Queue.js +1 -1
- package/lib/util/Semaphore.js +4 -7
- package/lib/util/SetHelpers.js +5 -5
- package/lib/util/SortableSet.js +4 -3
- package/lib/util/StackedCacheMap.js +4 -6
- package/lib/util/StackedMap.js +1 -3
- package/lib/util/StringXor.js +0 -5
- package/lib/util/TupleQueue.js +1 -1
- package/lib/util/TupleSet.js +15 -5
- package/lib/util/URLAbsoluteSpecifier.js +7 -7
- package/lib/util/WeakTupleMap.js +19 -21
- package/lib/util/binarySearchBounds.js +5 -12
- package/lib/util/chainedImports.js +1 -1
- package/lib/util/cleverMerge.js +21 -19
- package/lib/util/comparators.js +57 -52
- package/lib/util/compileBooleanMatcher.js +3 -6
- package/lib/util/conventions.js +8 -11
- package/lib/util/createHash.js +9 -6
- package/lib/util/deprecation.js +22 -12
- package/lib/util/deterministicGrouping.js +19 -26
- package/lib/util/findGraphRoots.js +2 -2
- package/lib/util/fs.js +31 -31
- package/lib/util/hash/md4.js +2 -2
- package/lib/util/hash/wasm-hash.js +7 -7
- package/lib/util/hash/xxhash64.js +2 -2
- package/lib/util/identifier.js +81 -59
- package/lib/util/memoize.js +8 -10
- package/lib/util/mergeScope.js +6 -9
- package/lib/util/nonNumericOnlyHash.js +2 -2
- package/lib/util/numberHash.js +1 -6
- package/lib/util/objectToMap.js +0 -1
- package/lib/util/propertyAccess.js +2 -5
- package/lib/util/propertyName.js +1 -3
- package/lib/util/registerExternalSerializer.js +1 -1
- package/lib/util/runtime.js +103 -113
- package/lib/util/semver.js +29 -27
- package/lib/util/serialization.js +16 -1
- package/lib/util/smartGrouping.js +5 -5
- package/lib/util/source.js +1 -1
- package/lib/wasm/EnableWasmLoadingPlugin.js +5 -4
- package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +3 -3
- package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +5 -6
- package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +3 -3
- package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +20 -19
- package/lib/wasm-sync/WebAssemblyGenerator.js +14 -29
- package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +1 -1
- package/lib/wasm-sync/WebAssemblyUtils.js +2 -2
- package/lib/web/JsonpChunkLoadingRuntimeModule.js +2 -3
- package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +3 -1
- package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +1 -1
- package/package.json +15 -14
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +1 -0
- package/schemas/plugins/container/ContainerReferencePlugin.check.js +1 -1
- package/schemas/plugins/container/ContainerReferencePlugin.json +1 -0
- package/schemas/plugins/container/ExternalsType.check.js +1 -1
- package/schemas/plugins/container/ModuleFederationPlugin.check.js +1 -1
- package/schemas/plugins/container/ModuleFederationPlugin.json +1 -0
- package/types.d.ts +667 -347
@@ -6,7 +6,10 @@
|
|
6
6
|
"use strict";
|
7
7
|
|
8
8
|
/** @typedef {import("../Compiler")} Compiler */
|
9
|
+
/** @typedef {import("./DefaultStatsFactoryPlugin").KnownStatsChunkGroup} KnownStatsChunkGroup */
|
9
10
|
/** @typedef {import("./StatsPrinter")} StatsPrinter */
|
11
|
+
/** @typedef {import("./StatsPrinter").KnownStatsPrinterColorFn} KnownStatsPrinterColorFn */
|
12
|
+
/** @typedef {import("./StatsPrinter").KnownStatsPrinterFormaters} KnownStatsPrinterFormaters */
|
10
13
|
/** @typedef {import("./StatsPrinter").StatsPrinterContext} StatsPrinterContext */
|
11
14
|
|
12
15
|
const DATA_URI_CONTENT_LENGTH = 16;
|
@@ -22,9 +25,8 @@ const plural = (n, singular, plural) => (n === 1 ? singular : plural);
|
|
22
25
|
|
23
26
|
/**
|
24
27
|
* @param {Record<string, number>} sizes sizes by source type
|
25
|
-
* @param {
|
26
|
-
* @
|
27
|
-
* @returns {string} text
|
28
|
+
* @param {StatsPrinterContext} options options
|
29
|
+
* @returns {string | undefined} text
|
28
30
|
*/
|
29
31
|
const printSizes = (sizes, { formatSize = n => `${n}` }) => {
|
30
32
|
const keys = Object.keys(sizes);
|
@@ -56,7 +58,9 @@ const getResourceName = resource => {
|
|
56
58
|
* @returns {[string,string]} prefix and module name
|
57
59
|
*/
|
58
60
|
const getModuleName = name => {
|
59
|
-
const [, prefix, resource] =
|
61
|
+
const [, prefix, resource] =
|
62
|
+
/** @type {[any, string, string]} */
|
63
|
+
(/** @type {unknown} */ (/^(.*!)?([^!]*)$/.exec(name)));
|
60
64
|
|
61
65
|
if (resource.length > MAX_MODULE_IDENTIFIER_LENGTH) {
|
62
66
|
const truncatedResource = `${resource.slice(
|
@@ -86,22 +90,29 @@ const mapLines = (str, fn) => str.split("\n").map(fn).join("\n");
|
|
86
90
|
*/
|
87
91
|
const twoDigit = n => (n >= 10 ? `${n}` : `0${n}`);
|
88
92
|
|
89
|
-
|
90
|
-
|
91
|
-
}
|
93
|
+
/**
|
94
|
+
* @param {string | number} id an id
|
95
|
+
* @returns {boolean | string} is i
|
96
|
+
*/
|
97
|
+
const isValidId = id => typeof id === "number" || id;
|
92
98
|
|
93
99
|
/**
|
94
100
|
* @template T
|
95
|
-
* @param {Array<T>} list of items
|
101
|
+
* @param {Array<T> | undefined} list of items
|
96
102
|
* @param {number} count number of items to show
|
97
103
|
* @returns {string} string representation of list
|
98
104
|
*/
|
99
|
-
const moreCount = (list, count) =>
|
100
|
-
|
101
|
-
|
105
|
+
const moreCount = (list, count) =>
|
106
|
+
list && list.length > 0 ? `+ ${count}` : `${count}`;
|
107
|
+
|
108
|
+
/**
|
109
|
+
* @template T
|
110
|
+
* @template {keyof T} K
|
111
|
+
* @typedef {{ [P in K]-?: T[P] }} WithRequired
|
112
|
+
*/
|
102
113
|
|
103
|
-
/** @type {Record<string, (thing: any, context: StatsPrinterContext, printer: StatsPrinter) => string |
|
104
|
-
const
|
114
|
+
/** @type {Record<string, (thing: any, context: Required<KnownStatsPrinterColorFn> & Required<KnownStatsPrinterFormaters> & WithRequired<StatsPrinterContext, "type" | "compilation">, printer: StatsPrinter) => string | undefined>} */
|
115
|
+
const COMPILATION_SIMPLE_PRINTERS = {
|
105
116
|
"compilation.summary!": (
|
106
117
|
_,
|
107
118
|
{
|
@@ -125,14 +136,16 @@ const SIMPLE_PRINTERS = {
|
|
125
136
|
) => {
|
126
137
|
const root = type === "compilation.summary!";
|
127
138
|
const warningsMessage =
|
128
|
-
warningsCount > 0
|
139
|
+
/** @type {number} */ (warningsCount) > 0
|
129
140
|
? yellow(
|
130
|
-
`${warningsCount} ${plural(warningsCount, "warning", "warnings")}`
|
141
|
+
`${warningsCount} ${plural(/** @type {number} */ (warningsCount), "warning", "warnings")}`
|
131
142
|
)
|
132
143
|
: "";
|
133
144
|
const errorsMessage =
|
134
|
-
errorsCount > 0
|
135
|
-
? red(
|
145
|
+
/** @type {number} */ (errorsCount) > 0
|
146
|
+
? red(
|
147
|
+
`${errorsCount} ${plural(/** @type {number} */ (errorsCount), "error", "errors")}`
|
148
|
+
)
|
136
149
|
: "";
|
137
150
|
const timeMessage = root && time ? ` in ${formatTime(time)}` : "";
|
138
151
|
const hashMessage = hash ? ` (${hash})` : "";
|
@@ -161,7 +174,7 @@ const SIMPLE_PRINTERS = {
|
|
161
174
|
} else if (errorsCount === 0 && warningsCount === 0) {
|
162
175
|
statusMessage = `compiled ${green("successfully")}`;
|
163
176
|
} else {
|
164
|
-
statusMessage =
|
177
|
+
statusMessage = "compiled";
|
165
178
|
}
|
166
179
|
if (
|
167
180
|
builtAtMessage ||
|
@@ -258,11 +271,12 @@ const SIMPLE_PRINTERS = {
|
|
258
271
|
"compilation.warningsInChildren!": (_, { yellow, compilation }) => {
|
259
272
|
if (
|
260
273
|
!compilation.children &&
|
261
|
-
compilation.warningsCount > 0 &&
|
274
|
+
/** @type {number} */ (compilation.warningsCount) > 0 &&
|
262
275
|
compilation.warnings
|
263
276
|
) {
|
264
277
|
const childWarnings =
|
265
|
-
compilation.warningsCount -
|
278
|
+
/** @type {number} */ (compilation.warningsCount) -
|
279
|
+
compilation.warnings.length;
|
266
280
|
if (childWarnings > 0) {
|
267
281
|
return yellow(
|
268
282
|
`${childWarnings} ${plural(
|
@@ -281,10 +295,12 @@ const SIMPLE_PRINTERS = {
|
|
281
295
|
"compilation.errorsInChildren!": (_, { red, compilation }) => {
|
282
296
|
if (
|
283
297
|
!compilation.children &&
|
284
|
-
compilation.errorsCount > 0 &&
|
298
|
+
/** @type {number} */ (compilation.errorsCount) > 0 &&
|
285
299
|
compilation.errors
|
286
300
|
) {
|
287
|
-
const childErrors =
|
301
|
+
const childErrors =
|
302
|
+
/** @type {number} */ (compilation.errorsCount) -
|
303
|
+
compilation.errors.length;
|
288
304
|
if (childErrors > 0) {
|
289
305
|
return red(
|
290
306
|
`${childErrors} ${plural(
|
@@ -299,15 +315,16 @@ const SIMPLE_PRINTERS = {
|
|
299
315
|
);
|
300
316
|
}
|
301
317
|
}
|
302
|
-
}
|
318
|
+
}
|
319
|
+
};
|
303
320
|
|
321
|
+
/** @type {Record<string, (thing: any, context: Required<KnownStatsPrinterColorFn> & Required<KnownStatsPrinterFormaters> & WithRequired<StatsPrinterContext, "type" | "compilation" | "asset">, printer: StatsPrinter) => string | undefined>} */
|
322
|
+
const ASSET_SIMPLE_PRINTERS = {
|
304
323
|
"asset.type": type => type,
|
305
324
|
"asset.name": (name, { formatFilename, asset: { isOverSizeLimit } }) =>
|
306
325
|
formatFilename(name, isOverSizeLimit),
|
307
|
-
"asset.size": (
|
308
|
-
size,
|
309
|
-
{ asset: { isOverSizeLimit }, yellow, green, formatSize }
|
310
|
-
) => (isOverSizeLimit ? yellow(formatSize(size)) : formatSize(size)),
|
326
|
+
"asset.size": (size, { asset: { isOverSizeLimit }, yellow, formatSize }) =>
|
327
|
+
isOverSizeLimit ? yellow(formatSize(size)) : formatSize(size),
|
311
328
|
"asset.emitted": (emitted, { green, formatFlag }) =>
|
312
329
|
emitted ? green(formatFlag("emitted")) : undefined,
|
313
330
|
"asset.comparedForEmit": (comparedForEmit, { yellow, formatFlag }) =>
|
@@ -356,8 +373,11 @@ const SIMPLE_PRINTERS = {
|
|
356
373
|
assetChunk: (id, { formatChunkId }) => formatChunkId(id),
|
357
374
|
|
358
375
|
assetChunkName: name => name,
|
359
|
-
assetChunkIdHint: name => name
|
376
|
+
assetChunkIdHint: name => name
|
377
|
+
};
|
360
378
|
|
379
|
+
/** @type {Record<string, (thing: any, context: Required<KnownStatsPrinterColorFn> & Required<KnownStatsPrinterFormaters> & WithRequired<StatsPrinterContext, "type" | "compilation" | "module">, printer: StatsPrinter) => string | undefined>} */
|
380
|
+
const MODULE_SIMPLE_PRINTERS = {
|
361
381
|
"module.type": type => (type !== "module" ? type : undefined),
|
362
382
|
"module.id": (id, { formatModuleId }) =>
|
363
383
|
isValidId(id) ? formatModuleId(id) : undefined,
|
@@ -433,11 +453,11 @@ const SIMPLE_PRINTERS = {
|
|
433
453
|
providedExportsCount === usedExports.length
|
434
454
|
) {
|
435
455
|
return cyan(formatFlag("all exports used"));
|
436
|
-
} else {
|
437
|
-
return cyan(
|
438
|
-
formatFlag(`only some exports used: ${usedExports.join(", ")}`)
|
439
|
-
);
|
440
456
|
}
|
457
|
+
|
458
|
+
return cyan(
|
459
|
+
formatFlag(`only some exports used: ${usedExports.join(", ")}`)
|
460
|
+
);
|
441
461
|
}
|
442
462
|
}
|
443
463
|
},
|
@@ -470,11 +490,17 @@ const SIMPLE_PRINTERS = {
|
|
470
490
|
"modules"
|
471
491
|
)}`
|
472
492
|
: undefined,
|
473
|
-
"module.separator!": () => "\n"
|
493
|
+
"module.separator!": () => "\n"
|
494
|
+
};
|
474
495
|
|
496
|
+
/** @type {Record<string, (thing: any, context: Required<KnownStatsPrinterColorFn> & Required<KnownStatsPrinterFormaters> & WithRequired<StatsPrinterContext, "type" | "compilation" | "moduleIssuer">, printer: StatsPrinter) => string | undefined>} */
|
497
|
+
const MODULE_ISSUER_PRINTERS = {
|
475
498
|
"moduleIssuer.id": (id, { formatModuleId }) => formatModuleId(id),
|
476
|
-
"moduleIssuer.profile.total": (value, { formatTime }) => formatTime(value)
|
499
|
+
"moduleIssuer.profile.total": (value, { formatTime }) => formatTime(value)
|
500
|
+
};
|
477
501
|
|
502
|
+
/** @type {Record<string, (thing: any, context: Required<KnownStatsPrinterColorFn> & Required<KnownStatsPrinterFormaters> & WithRequired<StatsPrinterContext, "type" | "compilation" | "moduleReason">, printer: StatsPrinter) => string | undefined>} */
|
503
|
+
const MODULE_REASON_PRINTERS = {
|
478
504
|
"moduleReason.type": type => type,
|
479
505
|
"moduleReason.userRequest": (userRequest, { cyan }) =>
|
480
506
|
cyan(getResourceName(userRequest)),
|
@@ -496,8 +522,11 @@ const SIMPLE_PRINTERS = {
|
|
496
522
|
"reason",
|
497
523
|
"reasons"
|
498
524
|
)}`
|
499
|
-
: undefined
|
525
|
+
: undefined
|
526
|
+
};
|
500
527
|
|
528
|
+
/** @type {Record<string, (thing: any, context: Required<KnownStatsPrinterColorFn> & Required<KnownStatsPrinterFormaters> & WithRequired<StatsPrinterContext, "type" | "compilation" | "profile">, printer: StatsPrinter) => string | undefined>} */
|
529
|
+
const MODULE_PROFILE_PRINTERS = {
|
501
530
|
"module.profile.total": (value, { formatTime }) => formatTime(value),
|
502
531
|
"module.profile.resolving": (value, { formatTime }) =>
|
503
532
|
`resolving: ${formatTime(value)}`,
|
@@ -512,8 +541,11 @@ const SIMPLE_PRINTERS = {
|
|
512
541
|
"module.profile.additionalResolving": (value, { formatTime }) =>
|
513
542
|
value ? `additional resolving: ${formatTime(value)}` : undefined,
|
514
543
|
"module.profile.additionalIntegration": (value, { formatTime }) =>
|
515
|
-
value ? `additional integration: ${formatTime(value)}` : undefined
|
544
|
+
value ? `additional integration: ${formatTime(value)}` : undefined
|
545
|
+
};
|
516
546
|
|
547
|
+
/** @type {Record<string, (thing: any, context: Required<KnownStatsPrinterColorFn> & Required<KnownStatsPrinterFormaters> & WithRequired<StatsPrinterContext, "type" | "compilation" | "chunkGroupKind" | "chunkGroup">, printer: StatsPrinter) => string | undefined>} */
|
548
|
+
const CHUNK_GROUP_PRINTERS = {
|
517
549
|
"chunkGroup.kind!": (_, { chunkGroupKind }) => chunkGroupKind,
|
518
550
|
"chunkGroup.separator!": () => "\n",
|
519
551
|
"chunkGroup.name": (name, { bold }) => bold(name),
|
@@ -541,10 +573,11 @@ const SIMPLE_PRINTERS = {
|
|
541
573
|
"chunkGroup.is!": () => "=",
|
542
574
|
"chunkGroupAsset.name": (asset, { green }) => green(asset),
|
543
575
|
"chunkGroupAsset.size": (size, { formatSize, chunkGroup }) =>
|
544
|
-
chunkGroup.assets
|
576
|
+
chunkGroup.assets &&
|
577
|
+
(chunkGroup.assets.length > 1 ||
|
545
578
|
(chunkGroup.auxiliaryAssets && chunkGroup.auxiliaryAssets.length > 0)
|
546
579
|
? formatSize(size)
|
547
|
-
: undefined,
|
580
|
+
: undefined),
|
548
581
|
"chunkGroup.children": (children, context, printer) =>
|
549
582
|
Array.isArray(children)
|
550
583
|
? undefined
|
@@ -560,8 +593,11 @@ const SIMPLE_PRINTERS = {
|
|
560
593
|
"chunkGroupChild.assets[]": (file, { formatFilename }) =>
|
561
594
|
formatFilename(file),
|
562
595
|
"chunkGroupChild.chunks[]": (id, { formatChunkId }) => formatChunkId(id),
|
563
|
-
"chunkGroupChild.name": name => (name ? `(name: ${name})` : undefined)
|
596
|
+
"chunkGroupChild.name": name => (name ? `(name: ${name})` : undefined)
|
597
|
+
};
|
564
598
|
|
599
|
+
/** @type {Record<string, (thing: any, context: Required<KnownStatsPrinterColorFn> & Required<KnownStatsPrinterFormaters> & WithRequired<StatsPrinterContext, "type" | "compilation" | "chunk">, printer: StatsPrinter) => string | undefined>} */
|
600
|
+
const CHUNK_PRINTERS = {
|
565
601
|
"chunk.id": (id, { formatChunkId }) => formatChunkId(id),
|
566
602
|
"chunk.files[]": (file, { formatFilename }) => formatFilename(file),
|
567
603
|
"chunk.names[]": name => name,
|
@@ -611,8 +647,11 @@ const SIMPLE_PRINTERS = {
|
|
611
647
|
"chunkOrigin.moduleId": (moduleId, { formatModuleId }) =>
|
612
648
|
isValidId(moduleId) ? formatModuleId(moduleId) : undefined,
|
613
649
|
"chunkOrigin.moduleName": (moduleName, { bold }) => bold(moduleName),
|
614
|
-
"chunkOrigin.loc": loc => loc
|
650
|
+
"chunkOrigin.loc": loc => loc
|
651
|
+
};
|
615
652
|
|
653
|
+
/** @type {Record<string, (thing: any, context: Required<KnownStatsPrinterColorFn> & Required<KnownStatsPrinterFormaters> & WithRequired<StatsPrinterContext, "type" | "compilation" | "error">, printer: StatsPrinter) => string | undefined>} */
|
654
|
+
const ERROR_PRINTERS = {
|
616
655
|
"error.compilerPath": (compilerPath, { bold }) =>
|
617
656
|
compilerPath ? bold(`(${compilerPath})`) : undefined,
|
618
657
|
"error.chunkId": (chunkId, { formatChunkId }) =>
|
@@ -622,21 +661,23 @@ const SIMPLE_PRINTERS = {
|
|
622
661
|
"error.chunkInitial": (chunkInitial, { formatFlag }) =>
|
623
662
|
chunkInitial ? formatFlag("initial") : undefined,
|
624
663
|
"error.file": (file, { bold }) => bold(file),
|
625
|
-
"error.moduleName": (moduleName, { bold }) =>
|
626
|
-
|
664
|
+
"error.moduleName": (moduleName, { bold }) =>
|
665
|
+
moduleName.includes("!")
|
627
666
|
? `${bold(moduleName.replace(/^(\s|\S)*!/, ""))} (${moduleName})`
|
628
|
-
: `${bold(moduleName)}
|
629
|
-
},
|
667
|
+
: `${bold(moduleName)}`,
|
630
668
|
"error.loc": (loc, { green }) => green(loc),
|
631
669
|
"error.message": (message, { bold, formatError }) =>
|
632
|
-
message.includes("\
|
670
|
+
message.includes("\u001B[") ? message : bold(formatError(message)),
|
633
671
|
"error.details": (details, { formatError }) => formatError(details),
|
634
672
|
"error.filteredDetails": filteredDetails =>
|
635
673
|
filteredDetails ? `+ ${filteredDetails} hidden lines` : undefined,
|
636
674
|
"error.stack": stack => stack,
|
637
675
|
"error.moduleTrace": moduleTrace => undefined,
|
638
|
-
"error.separator!": () => "\n"
|
676
|
+
"error.separator!": () => "\n"
|
677
|
+
};
|
639
678
|
|
679
|
+
/** @type {Record<string, (thing: any, context: Required<KnownStatsPrinterColorFn> & Required<KnownStatsPrinterFormaters> & WithRequired<StatsPrinterContext, "type" | "compilation" | "logging">, printer: StatsPrinter) => string | undefined>} */
|
680
|
+
const LOG_ENTRY_PRINTERS = {
|
640
681
|
"loggingEntry(error).loggingEntry.message": (message, { red }) =>
|
641
682
|
mapLines(message, x => `<e> ${red(x)}`),
|
642
683
|
"loggingEntry(warn).loggingEntry.message": (message, { yellow }) =>
|
@@ -666,20 +707,26 @@ const SIMPLE_PRINTERS = {
|
|
666
707
|
"loggingEntry.trace[]": trace =>
|
667
708
|
trace ? mapLines(trace, x => `| ${x}`) : undefined,
|
668
709
|
|
669
|
-
"moduleTraceItem.originName": originName => originName,
|
670
|
-
|
671
710
|
loggingGroup: loggingGroup =>
|
672
711
|
loggingGroup.entries.length === 0 ? "" : undefined,
|
673
712
|
"loggingGroup.debug": (flag, { red }) => (flag ? red("DEBUG") : undefined),
|
674
713
|
"loggingGroup.name": (name, { bold }) => bold(`LOG from ${name}`),
|
675
714
|
"loggingGroup.separator!": () => "\n",
|
676
715
|
"loggingGroup.filteredEntries": filteredEntries =>
|
677
|
-
filteredEntries > 0 ? `+ ${filteredEntries} hidden lines` : undefined
|
716
|
+
filteredEntries > 0 ? `+ ${filteredEntries} hidden lines` : undefined
|
717
|
+
};
|
718
|
+
|
719
|
+
/** @type {Record<string, (thing: any, context: Required<KnownStatsPrinterColorFn> & Required<KnownStatsPrinterFormaters> & WithRequired<StatsPrinterContext, "type" | "compilation" | "moduleTraceItem">, printer: StatsPrinter) => string | undefined>} */
|
720
|
+
const MODULE_TRACE_ITEM_PRINTERS = {
|
721
|
+
"moduleTraceItem.originName": originName => originName
|
722
|
+
};
|
678
723
|
|
724
|
+
/** @type {Record<string, (thing: any, context: Required<KnownStatsPrinterColorFn> & Required<KnownStatsPrinterFormaters> & WithRequired<StatsPrinterContext, "type" | "compilation" | "moduleTraceDependency">, printer: StatsPrinter) => string | undefined>} */
|
725
|
+
const MODULE_TRACE_DEPENDENCY_PRINTERS = {
|
679
726
|
"moduleTraceDependency.loc": loc => loc
|
680
727
|
};
|
681
728
|
|
682
|
-
/** @type {Record<string, string |
|
729
|
+
/** @type {Record<string, string | function(any): string>} */
|
683
730
|
const ITEM_NAMES = {
|
684
731
|
"compilation.assets[]": "asset",
|
685
732
|
"compilation.modules[]": "module",
|
@@ -908,19 +955,27 @@ const PREFERRED_ORDERS = {
|
|
908
955
|
loggingEntry: ["message", "trace", "children"]
|
909
956
|
};
|
910
957
|
|
958
|
+
/** @typedef {(items: string[]) => string | undefined} SimpleItemsJoiner */
|
959
|
+
|
960
|
+
/** @type {SimpleItemsJoiner} */
|
911
961
|
const itemsJoinOneLine = items => items.filter(Boolean).join(" ");
|
962
|
+
/** @type {SimpleItemsJoiner} */
|
912
963
|
const itemsJoinOneLineBrackets = items =>
|
913
964
|
items.length > 0 ? `(${items.filter(Boolean).join(" ")})` : undefined;
|
965
|
+
/** @type {SimpleItemsJoiner} */
|
914
966
|
const itemsJoinMoreSpacing = items => items.filter(Boolean).join("\n\n");
|
967
|
+
/** @type {SimpleItemsJoiner} */
|
915
968
|
const itemsJoinComma = items => items.filter(Boolean).join(", ");
|
969
|
+
/** @type {SimpleItemsJoiner} */
|
916
970
|
const itemsJoinCommaBrackets = items =>
|
917
971
|
items.length > 0 ? `(${items.filter(Boolean).join(", ")})` : undefined;
|
972
|
+
/** @type {function(string): SimpleItemsJoiner} */
|
918
973
|
const itemsJoinCommaBracketsWithName = name => items =>
|
919
974
|
items.length > 0
|
920
975
|
? `(${name}: ${items.filter(Boolean).join(", ")})`
|
921
976
|
: undefined;
|
922
977
|
|
923
|
-
/** @type {Record<string,
|
978
|
+
/** @type {Record<string, SimpleItemsJoiner>} */
|
924
979
|
const SIMPLE_ITEMS_JOINER = {
|
925
980
|
"chunk.parents": itemsJoinOneLine,
|
926
981
|
"chunk.siblings": itemsJoinOneLine,
|
@@ -952,18 +1007,27 @@ const SIMPLE_ITEMS_JOINER = {
|
|
952
1007
|
"compilation.errors": itemsJoinMoreSpacing,
|
953
1008
|
"compilation.warnings": itemsJoinMoreSpacing,
|
954
1009
|
"compilation.logging": itemsJoinMoreSpacing,
|
955
|
-
"compilation.children": items =>
|
1010
|
+
"compilation.children": items =>
|
1011
|
+
indent(/** @type {string} */ (itemsJoinMoreSpacing(items)), " "),
|
956
1012
|
"moduleTraceItem.dependencies": itemsJoinOneLine,
|
957
1013
|
"loggingEntry.children": items =>
|
958
1014
|
indent(items.filter(Boolean).join("\n"), " ", false)
|
959
1015
|
};
|
960
1016
|
|
1017
|
+
/**
|
1018
|
+
* @param {Item[]} items items
|
1019
|
+
* @returns {string} result
|
1020
|
+
*/
|
961
1021
|
const joinOneLine = items =>
|
962
1022
|
items
|
963
1023
|
.map(item => item.content)
|
964
1024
|
.filter(Boolean)
|
965
1025
|
.join(" ");
|
966
1026
|
|
1027
|
+
/**
|
1028
|
+
* @param {Item[]} items items
|
1029
|
+
* @returns {string} result
|
1030
|
+
*/
|
967
1031
|
const joinInBrackets = items => {
|
968
1032
|
const res = [];
|
969
1033
|
let mode = 0;
|
@@ -1006,13 +1070,24 @@ const joinInBrackets = items => {
|
|
1006
1070
|
return res.join("");
|
1007
1071
|
};
|
1008
1072
|
|
1073
|
+
/**
|
1074
|
+
* @param {string} str a string
|
1075
|
+
* @param {string} prefix prefix
|
1076
|
+
* @param {boolean=} noPrefixInFirstLine need prefix in the first line?
|
1077
|
+
* @returns {string} result
|
1078
|
+
*/
|
1009
1079
|
const indent = (str, prefix, noPrefixInFirstLine) => {
|
1010
|
-
const rem = str.replace(/\n([^\n])/g,
|
1080
|
+
const rem = str.replace(/\n([^\n])/g, `\n${prefix}$1`);
|
1011
1081
|
if (noPrefixInFirstLine) return rem;
|
1012
1082
|
const ind = str[0] === "\n" ? "" : prefix;
|
1013
1083
|
return ind + rem;
|
1014
1084
|
};
|
1015
1085
|
|
1086
|
+
/**
|
1087
|
+
* @param {(false | Item)[]} items items
|
1088
|
+
* @param {string} indenter indenter
|
1089
|
+
* @returns {string} result
|
1090
|
+
*/
|
1016
1091
|
const joinExplicitNewLine = (items, indenter) => {
|
1017
1092
|
let firstInLine = true;
|
1018
1093
|
let first = true;
|
@@ -1027,22 +1102,34 @@ const joinExplicitNewLine = (items, indenter) => {
|
|
1027
1102
|
first = false;
|
1028
1103
|
const noJoiner = firstInLine || content.startsWith("\n");
|
1029
1104
|
firstInLine = content.endsWith("\n");
|
1030
|
-
return noJoiner ? content :
|
1105
|
+
return noJoiner ? content : ` ${content}`;
|
1031
1106
|
})
|
1032
1107
|
.filter(Boolean)
|
1033
1108
|
.join("")
|
1034
1109
|
.trim();
|
1035
1110
|
};
|
1036
1111
|
|
1112
|
+
/**
|
1113
|
+
* @param {boolean} error is an error
|
1114
|
+
* @returns {SimpleElementJoiner} joiner
|
1115
|
+
*/
|
1037
1116
|
const joinError =
|
1038
1117
|
error =>
|
1118
|
+
/**
|
1119
|
+
* @param {Item[]} items items
|
1120
|
+
* @param {Required<StatsPrinterContext>} ctx context
|
1121
|
+
* @returns {string} result
|
1122
|
+
*/
|
1039
1123
|
(items, { red, yellow }) =>
|
1040
1124
|
`${error ? red("ERROR") : yellow("WARNING")} in ${joinExplicitNewLine(
|
1041
1125
|
items,
|
1042
1126
|
""
|
1043
1127
|
)}`;
|
1044
1128
|
|
1045
|
-
/** @
|
1129
|
+
/** @typedef {{ element: string, content: string }} Item */
|
1130
|
+
/** @typedef {(items: Item[], context: Required<StatsPrinterContext>) => string} SimpleElementJoiner */
|
1131
|
+
|
1132
|
+
/** @type {Record<string, SimpleElementJoiner>} */
|
1046
1133
|
const SIMPLE_ELEMENT_JOINERS = {
|
1047
1134
|
compilation: items => {
|
1048
1135
|
const result = [];
|
@@ -1119,23 +1206,20 @@ const SIMPLE_ELEMENT_JOINERS = {
|
|
1119
1206
|
},
|
1120
1207
|
chunk: items => {
|
1121
1208
|
let hasEntry = false;
|
1122
|
-
return (
|
1123
|
-
|
1124
|
-
|
1125
|
-
|
1126
|
-
|
1127
|
-
|
1128
|
-
|
1129
|
-
|
1130
|
-
|
1131
|
-
|
1132
|
-
|
1133
|
-
|
1134
|
-
|
1135
|
-
|
1136
|
-
" "
|
1137
|
-
)
|
1138
|
-
);
|
1209
|
+
return `chunk ${joinExplicitNewLine(
|
1210
|
+
items.filter(item => {
|
1211
|
+
switch (item.element) {
|
1212
|
+
case "entry":
|
1213
|
+
if (item.content) hasEntry = true;
|
1214
|
+
break;
|
1215
|
+
case "initial":
|
1216
|
+
if (hasEntry) return false;
|
1217
|
+
break;
|
1218
|
+
}
|
1219
|
+
return true;
|
1220
|
+
}),
|
1221
|
+
" "
|
1222
|
+
)}`;
|
1139
1223
|
},
|
1140
1224
|
"chunk.childrenByOrder[]": items => `(${joinOneLine(items)})`,
|
1141
1225
|
chunkGroup: items => joinExplicitNewLine(items, " "),
|
@@ -1196,23 +1280,27 @@ const SIMPLE_ELEMENT_JOINERS = {
|
|
1196
1280
|
},
|
1197
1281
|
"module.profile": joinInBrackets,
|
1198
1282
|
moduleIssuer: joinOneLine,
|
1199
|
-
chunkOrigin: items =>
|
1283
|
+
chunkOrigin: items => `> ${joinOneLine(items)}`,
|
1200
1284
|
"errors[].error": joinError(true),
|
1201
1285
|
"warnings[].error": joinError(false),
|
1202
1286
|
loggingGroup: items => joinExplicitNewLine(items, "").trimEnd(),
|
1203
|
-
moduleTraceItem: items =>
|
1287
|
+
moduleTraceItem: items => ` @ ${joinOneLine(items)}`,
|
1204
1288
|
moduleTraceDependency: joinOneLine
|
1205
1289
|
};
|
1206
1290
|
|
1291
|
+
/** @typedef {"bold" | "yellow" | "red" | "green" | "cyan" | "magenta"} ColorNames */
|
1292
|
+
|
1293
|
+
/** @type {Record<ColorNames, string>} */
|
1207
1294
|
const AVAILABLE_COLORS = {
|
1208
|
-
bold: "\
|
1209
|
-
yellow: "\
|
1210
|
-
red: "\
|
1211
|
-
green: "\
|
1212
|
-
cyan: "\
|
1213
|
-
magenta: "\
|
1295
|
+
bold: "\u001B[1m",
|
1296
|
+
yellow: "\u001B[1m\u001B[33m",
|
1297
|
+
red: "\u001B[1m\u001B[31m",
|
1298
|
+
green: "\u001B[1m\u001B[32m",
|
1299
|
+
cyan: "\u001B[1m\u001B[36m",
|
1300
|
+
magenta: "\u001B[1m\u001B[35m"
|
1214
1301
|
};
|
1215
1302
|
|
1303
|
+
/** @type {Record<string, function(any, Required<KnownStatsPrinterColorFn> & StatsPrinterContext, ...any): string>} */
|
1216
1304
|
const AVAILABLE_FORMATS = {
|
1217
1305
|
formatChunkId: (id, { yellow }, direction) => {
|
1218
1306
|
switch (direction) {
|
@@ -1256,13 +1344,12 @@ const AVAILABLE_FORMATS = {
|
|
1256
1344
|
else if (time < times[2]) return bold(`${time}${unit}`);
|
1257
1345
|
else if (time < times[1]) return green(`${time}${unit}`);
|
1258
1346
|
else if (time < times[0]) return yellow(`${time}${unit}`);
|
1259
|
-
|
1260
|
-
} else {
|
1261
|
-
return `${boldQuantity ? bold(time) : time}${unit}`;
|
1347
|
+
return red(`${time}${unit}`);
|
1262
1348
|
}
|
1349
|
+
return `${boldQuantity ? bold(time) : time}${unit}`;
|
1263
1350
|
},
|
1264
1351
|
formatError: (message, { green, yellow, red }) => {
|
1265
|
-
if (message.includes("\
|
1352
|
+
if (message.includes("\u001B[")) return message;
|
1266
1353
|
const highlights = [
|
1267
1354
|
{ regExp: /(Did you mean .+)/g, format: green },
|
1268
1355
|
{
|
@@ -1290,23 +1377,36 @@ const AVAILABLE_FORMATS = {
|
|
1290
1377
|
}
|
1291
1378
|
];
|
1292
1379
|
for (const { regExp, format } of highlights) {
|
1293
|
-
message = message.replace(
|
1294
|
-
|
1295
|
-
|
1380
|
+
message = message.replace(
|
1381
|
+
regExp,
|
1382
|
+
/**
|
1383
|
+
* @param {string} match match
|
1384
|
+
* @param {string} content content
|
1385
|
+
* @returns {string} result
|
1386
|
+
*/
|
1387
|
+
(match, content) => match.replace(content, format(content))
|
1388
|
+
);
|
1296
1389
|
}
|
1297
1390
|
return message;
|
1298
1391
|
}
|
1299
1392
|
};
|
1300
1393
|
|
1394
|
+
/** @typedef {function(string): string} ResultModifierFn */
|
1395
|
+
/** @type {Record<string, ResultModifierFn>} */
|
1301
1396
|
const RESULT_MODIFIER = {
|
1302
|
-
"module.modules": result =>
|
1303
|
-
return indent(result, "| ");
|
1304
|
-
}
|
1397
|
+
"module.modules": result => indent(result, "| ")
|
1305
1398
|
};
|
1306
1399
|
|
1400
|
+
/**
|
1401
|
+
* @param {string[]} array array
|
1402
|
+
* @param {string[]} preferredOrder preferred order
|
1403
|
+
* @returns {string[]} result
|
1404
|
+
*/
|
1307
1405
|
const createOrder = (array, preferredOrder) => {
|
1308
1406
|
const originalArray = array.slice();
|
1407
|
+
/** @type {Set<string>} */
|
1309
1408
|
const set = new Set(array);
|
1409
|
+
/** @type {Set<string>} */
|
1310
1410
|
const usedSet = new Set();
|
1311
1411
|
array.length = 0;
|
1312
1412
|
for (const element of preferredOrder) {
|
@@ -1333,49 +1433,218 @@ class DefaultStatsPrinterPlugin {
|
|
1333
1433
|
compiler.hooks.compilation.tap("DefaultStatsPrinterPlugin", compilation => {
|
1334
1434
|
compilation.hooks.statsPrinter.tap(
|
1335
1435
|
"DefaultStatsPrinterPlugin",
|
1336
|
-
(stats, options
|
1436
|
+
(stats, options) => {
|
1337
1437
|
// Put colors into context
|
1338
1438
|
stats.hooks.print
|
1339
1439
|
.for("compilation")
|
1340
1440
|
.tap("DefaultStatsPrinterPlugin", (compilation, context) => {
|
1341
1441
|
for (const color of Object.keys(AVAILABLE_COLORS)) {
|
1442
|
+
const name = /** @type {ColorNames} */ (color);
|
1443
|
+
/** @type {string | undefined} */
|
1342
1444
|
let start;
|
1343
1445
|
if (options.colors) {
|
1344
1446
|
if (
|
1345
1447
|
typeof options.colors === "object" &&
|
1346
|
-
typeof options.colors[
|
1448
|
+
typeof options.colors[name] === "string"
|
1347
1449
|
) {
|
1348
|
-
start = options.colors[
|
1450
|
+
start = options.colors[name];
|
1349
1451
|
} else {
|
1350
|
-
start = AVAILABLE_COLORS[
|
1452
|
+
start = AVAILABLE_COLORS[name];
|
1351
1453
|
}
|
1352
1454
|
}
|
1353
1455
|
if (start) {
|
1456
|
+
/**
|
1457
|
+
* @param {string} str string
|
1458
|
+
* @returns {string} string with color
|
1459
|
+
*/
|
1354
1460
|
context[color] = str =>
|
1355
1461
|
`${start}${
|
1356
1462
|
typeof str === "string"
|
1357
1463
|
? str.replace(
|
1358
|
-
/((\
|
1464
|
+
/((\u001B\[39m|\u001B\[22m|\u001B\[0m)+)/g,
|
1359
1465
|
`$1${start}`
|
1360
1466
|
)
|
1361
1467
|
: str
|
1362
|
-
}\
|
1468
|
+
}\u001B[39m\u001B[22m`;
|
1363
1469
|
} else {
|
1470
|
+
/**
|
1471
|
+
* @param {string} str string
|
1472
|
+
* @returns {string} str string
|
1473
|
+
*/
|
1364
1474
|
context[color] = str => str;
|
1365
1475
|
}
|
1366
1476
|
}
|
1367
1477
|
for (const format of Object.keys(AVAILABLE_FORMATS)) {
|
1368
|
-
context[format] =
|
1369
|
-
|
1478
|
+
context[format] =
|
1479
|
+
/**
|
1480
|
+
* @param {string | number} content content
|
1481
|
+
* @param {...TODO} args args
|
1482
|
+
* @returns {string} result
|
1483
|
+
*/
|
1484
|
+
(content, ...args) =>
|
1485
|
+
AVAILABLE_FORMATS[format](
|
1486
|
+
content,
|
1487
|
+
/** @type {Required<KnownStatsPrinterColorFn> & StatsPrinterContext} */
|
1488
|
+
(context),
|
1489
|
+
...args
|
1490
|
+
);
|
1370
1491
|
}
|
1371
1492
|
context.timeReference = compilation.time;
|
1372
1493
|
});
|
1373
1494
|
|
1374
|
-
for (const key of Object.keys(
|
1495
|
+
for (const key of Object.keys(COMPILATION_SIMPLE_PRINTERS)) {
|
1496
|
+
stats.hooks.print
|
1497
|
+
.for(key)
|
1498
|
+
.tap("DefaultStatsPrinterPlugin", (obj, ctx) =>
|
1499
|
+
COMPILATION_SIMPLE_PRINTERS[key](
|
1500
|
+
obj,
|
1501
|
+
/** @type {Required<KnownStatsPrinterColorFn> & Required<KnownStatsPrinterFormaters> & WithRequired<StatsPrinterContext, "type" | "compilation">} */
|
1502
|
+
(ctx),
|
1503
|
+
stats
|
1504
|
+
)
|
1505
|
+
);
|
1506
|
+
}
|
1507
|
+
|
1508
|
+
for (const key of Object.keys(ASSET_SIMPLE_PRINTERS)) {
|
1509
|
+
stats.hooks.print
|
1510
|
+
.for(key)
|
1511
|
+
.tap("DefaultStatsPrinterPlugin", (obj, ctx) =>
|
1512
|
+
ASSET_SIMPLE_PRINTERS[key](
|
1513
|
+
obj,
|
1514
|
+
/** @type {Required<KnownStatsPrinterColorFn> & Required<KnownStatsPrinterFormaters> & WithRequired<StatsPrinterContext, "type" | "compilation" | "asset">} */
|
1515
|
+
(ctx),
|
1516
|
+
stats
|
1517
|
+
)
|
1518
|
+
);
|
1519
|
+
}
|
1520
|
+
|
1521
|
+
for (const key of Object.keys(MODULE_SIMPLE_PRINTERS)) {
|
1522
|
+
stats.hooks.print
|
1523
|
+
.for(key)
|
1524
|
+
.tap("DefaultStatsPrinterPlugin", (obj, ctx) =>
|
1525
|
+
MODULE_SIMPLE_PRINTERS[key](
|
1526
|
+
obj,
|
1527
|
+
/** @type {Required<KnownStatsPrinterColorFn> & Required<KnownStatsPrinterFormaters> & WithRequired<StatsPrinterContext, "type" | "compilation" | "module">} */
|
1528
|
+
(ctx),
|
1529
|
+
stats
|
1530
|
+
)
|
1531
|
+
);
|
1532
|
+
}
|
1533
|
+
|
1534
|
+
for (const key of Object.keys(MODULE_ISSUER_PRINTERS)) {
|
1535
|
+
stats.hooks.print
|
1536
|
+
.for(key)
|
1537
|
+
.tap("DefaultStatsPrinterPlugin", (obj, ctx) =>
|
1538
|
+
MODULE_ISSUER_PRINTERS[key](
|
1539
|
+
obj,
|
1540
|
+
/** @type {Required<KnownStatsPrinterColorFn> & Required<KnownStatsPrinterFormaters> & WithRequired<StatsPrinterContext, "type" | "compilation" | "moduleIssuer">} */
|
1541
|
+
(ctx),
|
1542
|
+
stats
|
1543
|
+
)
|
1544
|
+
);
|
1545
|
+
}
|
1546
|
+
|
1547
|
+
for (const key of Object.keys(MODULE_REASON_PRINTERS)) {
|
1548
|
+
stats.hooks.print
|
1549
|
+
.for(key)
|
1550
|
+
.tap("DefaultStatsPrinterPlugin", (obj, ctx) =>
|
1551
|
+
MODULE_REASON_PRINTERS[key](
|
1552
|
+
obj,
|
1553
|
+
/** @type {Required<KnownStatsPrinterColorFn> & Required<KnownStatsPrinterFormaters> & WithRequired<StatsPrinterContext, "type" | "compilation" | "moduleReason">} */
|
1554
|
+
(ctx),
|
1555
|
+
stats
|
1556
|
+
)
|
1557
|
+
);
|
1558
|
+
}
|
1559
|
+
|
1560
|
+
for (const key of Object.keys(MODULE_PROFILE_PRINTERS)) {
|
1561
|
+
stats.hooks.print
|
1562
|
+
.for(key)
|
1563
|
+
.tap("DefaultStatsPrinterPlugin", (obj, ctx) =>
|
1564
|
+
MODULE_PROFILE_PRINTERS[key](
|
1565
|
+
obj,
|
1566
|
+
/** @type {Required<KnownStatsPrinterColorFn> & Required<KnownStatsPrinterFormaters> & WithRequired<StatsPrinterContext, "type" | "compilation" | "profile">} */
|
1567
|
+
(ctx),
|
1568
|
+
stats
|
1569
|
+
)
|
1570
|
+
);
|
1571
|
+
}
|
1572
|
+
|
1573
|
+
for (const key of Object.keys(CHUNK_GROUP_PRINTERS)) {
|
1574
|
+
stats.hooks.print
|
1575
|
+
.for(key)
|
1576
|
+
.tap("DefaultStatsPrinterPlugin", (obj, ctx) =>
|
1577
|
+
CHUNK_GROUP_PRINTERS[key](
|
1578
|
+
obj,
|
1579
|
+
/** @type {Required<KnownStatsPrinterColorFn> & Required<KnownStatsPrinterFormaters> & WithRequired<StatsPrinterContext, "type" | "compilation" | "chunkGroupKind" | "chunkGroup">} */
|
1580
|
+
(ctx),
|
1581
|
+
stats
|
1582
|
+
)
|
1583
|
+
);
|
1584
|
+
}
|
1585
|
+
|
1586
|
+
for (const key of Object.keys(CHUNK_PRINTERS)) {
|
1587
|
+
stats.hooks.print
|
1588
|
+
.for(key)
|
1589
|
+
.tap("DefaultStatsPrinterPlugin", (obj, ctx) =>
|
1590
|
+
CHUNK_PRINTERS[key](
|
1591
|
+
obj,
|
1592
|
+
/** @type {Required<KnownStatsPrinterColorFn> & Required<KnownStatsPrinterFormaters> & WithRequired<StatsPrinterContext, "type" | "compilation" | "chunk">} */
|
1593
|
+
(ctx),
|
1594
|
+
stats
|
1595
|
+
)
|
1596
|
+
);
|
1597
|
+
}
|
1598
|
+
|
1599
|
+
for (const key of Object.keys(ERROR_PRINTERS)) {
|
1600
|
+
stats.hooks.print
|
1601
|
+
.for(key)
|
1602
|
+
.tap("DefaultStatsPrinterPlugin", (obj, ctx) =>
|
1603
|
+
ERROR_PRINTERS[key](
|
1604
|
+
obj,
|
1605
|
+
/** @type {Required<KnownStatsPrinterColorFn> & Required<KnownStatsPrinterFormaters> & WithRequired<StatsPrinterContext, "type" | "compilation" | "error">} */
|
1606
|
+
(ctx),
|
1607
|
+
stats
|
1608
|
+
)
|
1609
|
+
);
|
1610
|
+
}
|
1611
|
+
|
1612
|
+
for (const key of Object.keys(LOG_ENTRY_PRINTERS)) {
|
1613
|
+
stats.hooks.print
|
1614
|
+
.for(key)
|
1615
|
+
.tap("DefaultStatsPrinterPlugin", (obj, ctx) =>
|
1616
|
+
LOG_ENTRY_PRINTERS[key](
|
1617
|
+
obj,
|
1618
|
+
/** @type {Required<KnownStatsPrinterColorFn> & Required<KnownStatsPrinterFormaters> & WithRequired<StatsPrinterContext, "type" | "compilation" | "logging">} */
|
1619
|
+
(ctx),
|
1620
|
+
stats
|
1621
|
+
)
|
1622
|
+
);
|
1623
|
+
}
|
1624
|
+
|
1625
|
+
for (const key of Object.keys(MODULE_TRACE_DEPENDENCY_PRINTERS)) {
|
1626
|
+
stats.hooks.print
|
1627
|
+
.for(key)
|
1628
|
+
.tap("DefaultStatsPrinterPlugin", (obj, ctx) =>
|
1629
|
+
MODULE_TRACE_DEPENDENCY_PRINTERS[key](
|
1630
|
+
obj,
|
1631
|
+
/** @type {Required<KnownStatsPrinterColorFn> & Required<KnownStatsPrinterFormaters> & WithRequired<StatsPrinterContext, "type" | "compilation" | "moduleTraceDependency">} */
|
1632
|
+
(ctx),
|
1633
|
+
stats
|
1634
|
+
)
|
1635
|
+
);
|
1636
|
+
}
|
1637
|
+
|
1638
|
+
for (const key of Object.keys(MODULE_TRACE_ITEM_PRINTERS)) {
|
1375
1639
|
stats.hooks.print
|
1376
1640
|
.for(key)
|
1377
1641
|
.tap("DefaultStatsPrinterPlugin", (obj, ctx) =>
|
1378
|
-
|
1642
|
+
MODULE_TRACE_ITEM_PRINTERS[key](
|
1643
|
+
obj,
|
1644
|
+
/** @type {Required<KnownStatsPrinterColorFn> & Required<KnownStatsPrinterFormaters> & WithRequired<StatsPrinterContext, "type" | "compilation" | "moduleTraceItem">} */
|
1645
|
+
(ctx),
|
1646
|
+
stats
|
1647
|
+
)
|
1379
1648
|
);
|
1380
1649
|
}
|
1381
1650
|
|
@@ -1409,7 +1678,7 @@ class DefaultStatsPrinterPlugin {
|
|
1409
1678
|
const joiner = SIMPLE_ELEMENT_JOINERS[key];
|
1410
1679
|
stats.hooks.printElements
|
1411
1680
|
.for(key)
|
1412
|
-
.tap("DefaultStatsPrinterPlugin", joiner);
|
1681
|
+
.tap("DefaultStatsPrinterPlugin", /** @type {TODO} */ (joiner));
|
1413
1682
|
}
|
1414
1683
|
|
1415
1684
|
for (const key of Object.keys(RESULT_MODIFIER)) {
|