webpack 5.99.5 → 5.99.6
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 +1 -1
- package/lib/APIPlugin.js +2 -2
- package/lib/Cache.js +1 -1
- package/lib/Chunk.js +12 -9
- package/lib/Compilation.js +36 -27
- package/lib/Compiler.js +4 -3
- package/lib/ContextModule.js +2 -1
- package/lib/HotModuleReplacementPlugin.js +3 -3
- package/lib/Module.js +10 -2
- package/lib/ModuleFilenameHelpers.js +1 -1
- package/lib/ModuleGraph.js +15 -10
- package/lib/NormalModule.js +1 -1
- package/lib/PrefetchPlugin.js +1 -1
- package/lib/RecordIdsPlugin.js +1 -1
- package/lib/SourceMapDevToolPlugin.js +1 -1
- package/lib/Template.js +1 -1
- package/lib/WebpackOptionsApply.js +17 -2
- package/lib/buildChunkGraph.js +7 -2
- package/lib/cache/IdleFileCachePlugin.js +1 -1
- package/lib/cache/MemoryCachePlugin.js +2 -1
- package/lib/cache/MemoryWithGcCachePlugin.js +3 -2
- package/lib/cache/PackFileCacheStrategy.js +13 -21
- package/lib/cache/ResolverCachePlugin.js +14 -16
- package/lib/cli.js +3 -3
- package/lib/config/defaults.js +2 -2
- package/lib/config/target.js +6 -6
- package/lib/css/CssParser.js +1 -1
- package/lib/debug/ProfilingPlugin.js +1 -1
- package/lib/dependencies/ContextDependencyHelpers.js +1 -1
- package/lib/dependencies/CssIcssImportDependency.js +3 -2
- package/lib/dependencies/HarmonyExportExpressionDependency.js +1 -1
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +2 -1
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +1 -1
- package/lib/dependencies/JsonExportsDependency.js +1 -1
- package/lib/dependencies/LocalModulesHelpers.js +1 -1
- package/lib/dependencies/RequireResolveDependency.js +1 -1
- package/lib/dependencies/WorkerPlugin.js +2 -2
- package/lib/esm/ModuleChunkLoadingPlugin.js +20 -0
- package/lib/esm/ModuleChunkLoadingRuntimeModule.js +11 -9
- package/lib/ids/DeterministicChunkIdsPlugin.js +1 -1
- package/lib/ids/DeterministicModuleIdsPlugin.js +1 -1
- package/lib/ids/NamedChunkIdsPlugin.js +2 -2
- package/lib/ids/NamedModuleIdsPlugin.js +2 -2
- package/lib/index.js +1 -1
- package/lib/javascript/BasicEvaluatedExpression.js +2 -2
- package/lib/javascript/JavascriptParser.js +41 -37
- package/lib/library/EnableLibraryPlugin.js +15 -2
- package/lib/library/ModuleLibraryPlugin.js +6 -1
- package/lib/logging/createConsoleLogger.js +0 -1
- package/lib/node/CommonJsChunkLoadingPlugin.js +2 -2
- package/lib/node/NodeTemplatePlugin.js +2 -2
- package/lib/node/ReadFileCompileAsyncWasmPlugin.js +2 -2
- package/lib/node/ReadFileCompileWasmPlugin.js +3 -3
- package/lib/optimize/AggressiveMergingPlugin.js +1 -1
- package/lib/optimize/SplitChunksPlugin.js +2 -1
- package/lib/runtime/GetChunkFilenameRuntimeModule.js +3 -4
- package/lib/serialization/BinaryMiddleware.js +22 -38
- package/lib/serialization/FileMiddleware.js +29 -33
- package/lib/serialization/ObjectMiddleware.js +29 -30
- package/lib/serialization/Serializer.js +29 -18
- package/lib/serialization/SerializerMiddleware.js +105 -72
- package/lib/serialization/SingleItemMiddleware.js +4 -5
- package/lib/stats/DefaultStatsFactoryPlugin.js +39 -24
- package/lib/stats/DefaultStatsPrinterPlugin.js +267 -80
- package/lib/stats/StatsFactory.js +47 -10
- package/lib/stats/StatsPrinter.js +52 -31
- package/lib/util/ArrayQueue.js +1 -1
- package/lib/util/AsyncQueue.js +1 -1
- package/lib/util/TupleQueue.js +9 -7
- package/lib/util/TupleSet.js +37 -18
- package/lib/util/WeakTupleMap.js +50 -37
- package/lib/util/cleverMerge.js +2 -2
- package/lib/util/comparators.js +1 -1
- package/lib/util/createHash.js +1 -1
- package/lib/util/fs.js +1 -1
- package/lib/util/makeSerializable.js +1 -1
- package/lib/util/runtime.js +1 -0
- package/lib/util/serialization.js +50 -42
- package/lib/wasm-async/AsyncWebAssemblyGenerator.js +1 -1
- package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +1 -1
- package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +2 -2
- package/lib/wasm-sync/WebAssemblyGenerator.js +1 -1
- package/lib/wasm-sync/WebAssemblyModulesPlugin.js +1 -1
- package/lib/web/FetchCompileWasmPlugin.js +2 -2
- package/lib/webpack.js +1 -1
- package/package.json +1 -1
- package/types.d.ts +125 -73
@@ -6,17 +6,34 @@
|
|
6
6
|
"use strict";
|
7
7
|
|
8
8
|
/** @typedef {import("../Compiler")} Compiler */
|
9
|
+
/** @typedef {import("../logging/Logger").LogTypeEnum} LogTypeEnum */
|
10
|
+
/** @typedef {import("./DefaultStatsFactoryPlugin").ChunkId} ChunkId */
|
11
|
+
/** @typedef {import("./DefaultStatsFactoryPlugin").ChunkName} ChunkName */
|
12
|
+
/** @typedef {import("./DefaultStatsFactoryPlugin").KnownStatsAsset} KnownStatsAsset */
|
13
|
+
/** @typedef {import("./DefaultStatsFactoryPlugin").KnownStatsAssetChunk} KnownStatsAssetChunk */
|
14
|
+
/** @typedef {import("./DefaultStatsFactoryPlugin").KnownStatsAssetChunkIdHint} KnownStatsAssetChunkIdHint */
|
15
|
+
/** @typedef {import("./DefaultStatsFactoryPlugin").KnownStatsAssetChunkName} KnownStatsAssetChunkName */
|
16
|
+
/** @typedef {import("./DefaultStatsFactoryPlugin").KnownStatsChunk} KnownStatsChunk */
|
9
17
|
/** @typedef {import("./DefaultStatsFactoryPlugin").KnownStatsChunkGroup} KnownStatsChunkGroup */
|
18
|
+
/** @typedef {import("./DefaultStatsFactoryPlugin").KnownStatsChunkOrigin} KnownStatsChunkOrigin */
|
19
|
+
/** @typedef {import("./DefaultStatsFactoryPlugin").KnownStatsCompilation} KnownStatsCompilation */
|
10
20
|
/** @typedef {import("./DefaultStatsFactoryPlugin").KnownStatsError} KnownStatsError */
|
21
|
+
/** @typedef {import("./DefaultStatsFactoryPlugin").KnownStatsLogging} KnownStatsLogging */
|
22
|
+
/** @typedef {import("./DefaultStatsFactoryPlugin").KnownStatsLoggingEntry} KnownStatsLoggingEntry */
|
23
|
+
/** @typedef {import("./DefaultStatsFactoryPlugin").KnownStatsModule} KnownStatsModule */
|
11
24
|
/** @typedef {import("./DefaultStatsFactoryPlugin").KnownStatsModuleIssuer} KnownStatsModuleIssuer */
|
25
|
+
/** @typedef {import("./DefaultStatsFactoryPlugin").KnownStatsModuleReason} KnownStatsModuleReason */
|
12
26
|
/** @typedef {import("./DefaultStatsFactoryPlugin").KnownStatsModuleTraceDependency} KnownStatsModuleTraceDependency */
|
13
27
|
/** @typedef {import("./DefaultStatsFactoryPlugin").KnownStatsModuleTraceItem} KnownStatsModuleTraceItem */
|
14
28
|
/** @typedef {import("./DefaultStatsFactoryPlugin").KnownStatsProfile} KnownStatsProfile */
|
29
|
+
/** @typedef {import("./DefaultStatsFactoryPlugin").StatsCompilation} StatsCompilation */
|
15
30
|
/** @typedef {import("./StatsPrinter")} StatsPrinter */
|
16
|
-
/** @typedef {import("./StatsPrinter").
|
31
|
+
/** @typedef {import("./StatsPrinter").ColorFunction} ColorFunction */
|
32
|
+
/** @typedef {import("./StatsPrinter").KnownStatsPrinterColorFunctions} KnownStatsPrinterColorFunctions */
|
17
33
|
/** @typedef {import("./StatsPrinter").KnownStatsPrinterContext} KnownStatsPrinterContext */
|
18
34
|
/** @typedef {import("./StatsPrinter").KnownStatsPrinterFormatters} KnownStatsPrinterFormatters */
|
19
35
|
/** @typedef {import("./StatsPrinter").StatsPrinterContext} StatsPrinterContext */
|
36
|
+
/** @typedef {import("./StatsPrinter").StatsPrinterContextWithExtra} StatsPrinterContextWithExtra */
|
20
37
|
|
21
38
|
const DATA_URI_CONTENT_LENGTH = 16;
|
22
39
|
const MAX_MODULE_IDENTIFIER_LENGTH = 80;
|
@@ -44,10 +61,11 @@ const printSizes = (sizes, { formatSize = n => `${n}` }) => {
|
|
44
61
|
};
|
45
62
|
|
46
63
|
/**
|
47
|
-
* @param {string} resource resource
|
64
|
+
* @param {string | null} resource resource
|
48
65
|
* @returns {string} resource name for display
|
49
66
|
*/
|
50
67
|
const getResourceName = resource => {
|
68
|
+
if (!resource) return "";
|
51
69
|
const dataUrl = /^data:[^,]+,/.exec(resource);
|
52
70
|
if (!dataUrl) return resource;
|
53
71
|
|
@@ -97,10 +115,16 @@ const mapLines = (str, fn) => str.split("\n").map(fn).join("\n");
|
|
97
115
|
const twoDigit = n => (n >= 10 ? `${n}` : `0${n}`);
|
98
116
|
|
99
117
|
/**
|
100
|
-
* @param {string | number} id an id
|
101
|
-
* @returns {
|
118
|
+
* @param {string | number | null} id an id
|
119
|
+
* @returns {id is string | number} is i
|
102
120
|
*/
|
103
|
-
const isValidId = id =>
|
121
|
+
const isValidId = id => {
|
122
|
+
if (typeof id === "number" || id) {
|
123
|
+
return true;
|
124
|
+
}
|
125
|
+
|
126
|
+
return false;
|
127
|
+
};
|
104
128
|
|
105
129
|
/**
|
106
130
|
* @template T
|
@@ -119,13 +143,13 @@ const moreCount = (list, count) =>
|
|
119
143
|
|
120
144
|
/**
|
121
145
|
* @template {keyof StatsPrinterContext} RequiredStatsPrinterContextKeys
|
122
|
-
* @typedef {
|
146
|
+
* @typedef {StatsPrinterContextWithExtra & WithRequired<StatsPrinterContext, "compilation" | RequiredStatsPrinterContextKeys>} DefineStatsPrinterContext
|
123
147
|
*/
|
124
148
|
|
125
149
|
/**
|
126
150
|
* @template T
|
127
151
|
* @template {keyof StatsPrinterContext} RequiredStatsPrinterContextKeys
|
128
|
-
* @typedef {(thing: Exclude<T, undefined>, context: DefineStatsPrinterContext<RequiredStatsPrinterContextKeys>, printer: StatsPrinter) => string | undefined}
|
152
|
+
* @typedef {(thing: Exclude<T, undefined>, context: DefineStatsPrinterContext<RequiredStatsPrinterContextKeys>, printer: StatsPrinter) => string | undefined} SimplePrinter
|
129
153
|
*/
|
130
154
|
|
131
155
|
/**
|
@@ -135,24 +159,52 @@ const moreCount = (list, count) =>
|
|
135
159
|
|
136
160
|
/**
|
137
161
|
* @template {object} O
|
138
|
-
* @template {keyof O}
|
162
|
+
* @template {keyof O} K
|
139
163
|
* @template {string} B
|
140
|
-
* @typedef {
|
164
|
+
* @typedef {K extends string ? Exclude<O[K], undefined> extends EXPECTED_ANY[] ? never : `${B}.${K}` : never} PropertyName
|
141
165
|
*/
|
142
166
|
|
143
167
|
/**
|
144
|
-
* @template {
|
145
|
-
* @
|
168
|
+
* @template {object} O
|
169
|
+
* @template {keyof O} K
|
170
|
+
* @template {string} B
|
171
|
+
* @typedef {K extends string ? NonNullable<O[K]> extends EXPECTED_ANY[] ? `${B}.${K}[]` : never : never} ArrayPropertyName
|
172
|
+
*/
|
173
|
+
|
174
|
+
/**
|
175
|
+
* @template {object} O
|
176
|
+
* @template {keyof O} K
|
177
|
+
* @template {string} B
|
178
|
+
* @typedef {K extends string ? Exclude<O[K], undefined> extends EXPECTED_ANY[] ? `${B}.${K}` : never : never} MultiplePropertyName
|
179
|
+
*/
|
180
|
+
|
181
|
+
/**
|
182
|
+
* @template {object} O
|
183
|
+
* @template {string} K
|
184
|
+
* @template {string} E
|
185
|
+
* @typedef {{ [property in `${K}!`]?: SimplePrinter<O, "compilation" | E> }} Exclamation
|
146
186
|
*/
|
147
187
|
|
148
188
|
/**
|
149
189
|
* @template {object} O
|
150
190
|
* @template {string} B
|
151
191
|
* @template {string} [R=B]
|
152
|
-
* @typedef {{ [
|
192
|
+
* @typedef {{ [K in keyof O as PropertyName<O, K, B>]?: SimplePrinter<O[K], R> } &
|
193
|
+
* { [K in keyof O as ArrayPropertyName<O, K, B>]?: Exclude<O[K], undefined> extends (infer I)[] ? SimplePrinter<I, R> : never } &
|
194
|
+
* { [K in keyof O as MultiplePropertyName<O, K, B>]?: SimplePrinter<O[K], R> }
|
195
|
+
* } Printers
|
196
|
+
*/
|
197
|
+
|
198
|
+
/**
|
199
|
+
* @typedef {Printers<KnownStatsCompilation, "compilation"> &
|
200
|
+
* { ["compilation.summary!"]?: SimplePrinter<KnownStatsCompilation, "compilation"> } &
|
201
|
+
* { ["compilation.errorsInChildren!"]?: SimplePrinter<KnownStatsCompilation, "compilation"> } &
|
202
|
+
* { ["compilation.warningsInChildren!"]?: SimplePrinter<KnownStatsCompilation, "compilation"> }} CompilationSimplePrinters
|
153
203
|
*/
|
154
204
|
|
155
|
-
/**
|
205
|
+
/**
|
206
|
+
* @type {CompilationSimplePrinters}
|
207
|
+
*/
|
156
208
|
const COMPILATION_SIMPLE_PRINTERS = {
|
157
209
|
"compilation.summary!": (
|
158
210
|
_,
|
@@ -268,7 +320,11 @@ const COMPILATION_SIMPLE_PRINTERS = {
|
|
268
320
|
if (entrypoints) {
|
269
321
|
chunkGroups = chunkGroups.filter(
|
270
322
|
group =>
|
271
|
-
!Object.prototype.hasOwnProperty.call(
|
323
|
+
!Object.prototype.hasOwnProperty.call(
|
324
|
+
entrypoints,
|
325
|
+
/** @type {string} */
|
326
|
+
(group.name)
|
327
|
+
)
|
272
328
|
);
|
273
329
|
}
|
274
330
|
return printer.print(context.type, chunkGroups, {
|
@@ -359,7 +415,17 @@ const COMPILATION_SIMPLE_PRINTERS = {
|
|
359
415
|
}
|
360
416
|
};
|
361
417
|
|
362
|
-
/**
|
418
|
+
/**
|
419
|
+
* @typedef {Printers<KnownStatsAsset, "asset"> &
|
420
|
+
* Printers<KnownStatsAsset["info"], "asset.info"> &
|
421
|
+
* Exclamation<KnownStatsAsset, "asset.separator", "asset"> &
|
422
|
+
* { ["asset.filteredChildren"]?: SimplePrinter<number, "asset"> } &
|
423
|
+
* { assetChunk?: SimplePrinter<KnownStatsAssetChunk, "asset"> } &
|
424
|
+
* { assetChunkName?: SimplePrinter<KnownStatsAssetChunkName, "asset"> } &
|
425
|
+
* { assetChunkIdHint?: SimplePrinter<KnownStatsAssetChunkIdHint, "asset"> }} AssetSimplePrinters
|
426
|
+
*/
|
427
|
+
|
428
|
+
/** @type {AssetSimplePrinters} */
|
363
429
|
const ASSET_SIMPLE_PRINTERS = {
|
364
430
|
"asset.type": type => type,
|
365
431
|
"asset.name": (name, { formatFilename, asset: { isOverSizeLimit } }) =>
|
@@ -407,11 +473,18 @@ const ASSET_SIMPLE_PRINTERS = {
|
|
407
473
|
|
408
474
|
assetChunk: (id, { formatChunkId }) => formatChunkId(id),
|
409
475
|
|
410
|
-
assetChunkName: name => name,
|
411
|
-
assetChunkIdHint: name => name
|
476
|
+
assetChunkName: name => name || undefined,
|
477
|
+
assetChunkIdHint: name => name || undefined
|
412
478
|
};
|
413
479
|
|
414
|
-
/**
|
480
|
+
/**
|
481
|
+
* @typedef {Printers<KnownStatsModule, "module"> &
|
482
|
+
* Exclamation<KnownStatsModule, "module.separator", "module"> &
|
483
|
+
* { ["module.filteredChildren"]?: SimplePrinter<number, "module"> } &
|
484
|
+
* { ["module.filteredReasons"]?: SimplePrinter<number, "module"> }} ModuleSimplePrinters
|
485
|
+
*/
|
486
|
+
|
487
|
+
/** @type {ModuleSimplePrinters} */
|
415
488
|
const MODULE_SIMPLE_PRINTERS = {
|
416
489
|
"module.type": type => (type !== "module" ? type : undefined),
|
417
490
|
"module.id": (id, { formatModuleId }) =>
|
@@ -431,8 +504,8 @@ const MODULE_SIMPLE_PRINTERS = {
|
|
431
504
|
cacheable === false ? red(formatFlag("not cacheable")) : undefined,
|
432
505
|
"module.orphan": (orphan, { formatFlag, yellow }) =>
|
433
506
|
orphan ? yellow(formatFlag("orphan")) : undefined,
|
434
|
-
"module.runtime": (runtime, { formatFlag, yellow }) =>
|
435
|
-
|
507
|
+
// "module.runtime": (runtime, { formatFlag, yellow }) =>
|
508
|
+
// runtime ? yellow(formatFlag("runtime")) : undefined,
|
436
509
|
"module.optional": (optional, { formatFlag, yellow }) =>
|
437
510
|
optional ? yellow(formatFlag("optional")) : undefined,
|
438
511
|
"module.dependent": (dependent, { formatFlag, cyan }) =>
|
@@ -454,19 +527,15 @@ const MODULE_SIMPLE_PRINTERS = {
|
|
454
527
|
)
|
455
528
|
: undefined,
|
456
529
|
"module.warnings": (warnings, { formatFlag, yellow }) =>
|
457
|
-
warnings
|
458
|
-
? yellow(
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
)
|
463
|
-
: undefined,
|
530
|
+
warnings
|
531
|
+
? yellow(
|
532
|
+
formatFlag(`${warnings} ${plural(warnings, "warning", "warnings")}`)
|
533
|
+
)
|
534
|
+
: undefined,
|
464
535
|
"module.errors": (errors, { formatFlag, red }) =>
|
465
|
-
errors
|
466
|
-
? red(formatFlag("errors"))
|
467
|
-
:
|
468
|
-
? red(formatFlag(`${errors} ${plural(errors, "error", "errors")}`))
|
469
|
-
: undefined,
|
536
|
+
errors
|
537
|
+
? red(formatFlag(`${errors} ${plural(errors, "error", "errors")}`))
|
538
|
+
: undefined,
|
470
539
|
"module.providedExports": (providedExports, { formatFlag, cyan }) => {
|
471
540
|
if (Array.isArray(providedExports)) {
|
472
541
|
if (providedExports.length === 0) return cyan(formatFlag("no exports"));
|
@@ -528,25 +597,38 @@ const MODULE_SIMPLE_PRINTERS = {
|
|
528
597
|
"module.separator!": () => "\n"
|
529
598
|
};
|
530
599
|
|
531
|
-
/**
|
600
|
+
/**
|
601
|
+
* @typedef {Printers<KnownStatsModuleIssuer, "moduleIssuer"> &
|
602
|
+
* Printers<KnownStatsModuleIssuer["profile"], "moduleIssuer.profile", "moduleIssuer">} ModuleIssuerPrinters
|
603
|
+
*/
|
604
|
+
|
605
|
+
/** @type {ModuleIssuerPrinters} */
|
532
606
|
const MODULE_ISSUER_PRINTERS = {
|
533
607
|
"moduleIssuer.id": (id, { formatModuleId }) => formatModuleId(id),
|
534
608
|
"moduleIssuer.profile.total": (value, { formatTime }) => formatTime(value)
|
535
609
|
};
|
536
610
|
|
537
|
-
/**
|
611
|
+
/**
|
612
|
+
* @typedef {Printers<KnownStatsModuleReason, "moduleReason"> &
|
613
|
+
* { ["moduleReason.filteredChildren"]?: SimplePrinter<number, "moduleReason"> }} ModuleReasonsPrinters
|
614
|
+
*/
|
615
|
+
|
616
|
+
/** @type {ModuleReasonsPrinters} */
|
538
617
|
const MODULE_REASON_PRINTERS = {
|
539
|
-
"moduleReason.type": type => type,
|
618
|
+
"moduleReason.type": type => type || undefined,
|
540
619
|
"moduleReason.userRequest": (userRequest, { cyan }) =>
|
541
620
|
cyan(getResourceName(userRequest)),
|
542
621
|
"moduleReason.moduleId": (moduleId, { formatModuleId }) =>
|
543
622
|
isValidId(moduleId) ? formatModuleId(moduleId) : undefined,
|
544
|
-
"moduleReason.module": (module, { magenta }) =>
|
545
|
-
|
546
|
-
"moduleReason.
|
623
|
+
"moduleReason.module": (module, { magenta }) =>
|
624
|
+
module ? magenta(module) : undefined,
|
625
|
+
"moduleReason.loc": loc => loc || undefined,
|
626
|
+
"moduleReason.explanation": (explanation, { cyan }) =>
|
627
|
+
explanation ? cyan(explanation) : undefined,
|
547
628
|
"moduleReason.active": (active, { formatFlag }) =>
|
548
629
|
active ? undefined : formatFlag("inactive"),
|
549
|
-
"moduleReason.resolvedModule": (module, { magenta }) =>
|
630
|
+
"moduleReason.resolvedModule": (module, { magenta }) =>
|
631
|
+
module ? magenta(module) : undefined,
|
550
632
|
"moduleReason.filteredChildren": (
|
551
633
|
filteredChildren,
|
552
634
|
{ moduleReason: { children } }
|
@@ -560,7 +642,9 @@ const MODULE_REASON_PRINTERS = {
|
|
560
642
|
: undefined
|
561
643
|
};
|
562
644
|
|
563
|
-
/** @
|
645
|
+
/** @typedef {Printers<KnownStatsProfile, "module.profile", "profile">} ModuleProfilePrinters */
|
646
|
+
|
647
|
+
/** @type {ModuleProfilePrinters} */
|
564
648
|
const MODULE_PROFILE_PRINTERS = {
|
565
649
|
"module.profile.total": (value, { formatTime }) => formatTime(value),
|
566
650
|
"module.profile.resolving": (value, { formatTime }) =>
|
@@ -579,11 +663,23 @@ const MODULE_PROFILE_PRINTERS = {
|
|
579
663
|
value ? `additional integration: ${formatTime(value)}` : undefined
|
580
664
|
};
|
581
665
|
|
582
|
-
/**
|
666
|
+
/**
|
667
|
+
* @typedef {Exclamation<KnownStatsChunkGroup, "chunkGroup.kind", "chunkGroupKind"> &
|
668
|
+
* Exclamation<KnownStatsChunkGroup, "chunkGroup.separator", "chunkGroup"> &
|
669
|
+
* Printers<KnownStatsChunkGroup, "chunkGroup"> &
|
670
|
+
* Exclamation<KnownStatsChunkGroup, "chunkGroup.is", "chunkGroup"> &
|
671
|
+
* Printers<Exclude<KnownStatsChunkGroup["assets"], undefined>[number], "chunkGroupAsset" | "chunkGroup"> &
|
672
|
+
* { ['chunkGroupChildGroup.type']?: SimplePrinter<string, "chunkGroupAsset"> } &
|
673
|
+
* { ['chunkGroupChild.assets[]']?: SimplePrinter<string, "chunkGroupAsset"> } &
|
674
|
+
* { ['chunkGroupChild.chunks[]']?: SimplePrinter<ChunkId, "chunkGroupAsset"> } &
|
675
|
+
* { ['chunkGroupChild.name']?: SimplePrinter<ChunkName, "chunkGroupAsset"> }} ChunkGroupPrinters
|
676
|
+
*/
|
677
|
+
|
678
|
+
/** @type {ChunkGroupPrinters} */
|
583
679
|
const CHUNK_GROUP_PRINTERS = {
|
584
680
|
"chunkGroup.kind!": (_, { chunkGroupKind }) => chunkGroupKind,
|
585
681
|
"chunkGroup.separator!": () => "\n",
|
586
|
-
"chunkGroup.name": (name, { bold }) => bold(name),
|
682
|
+
"chunkGroup.name": (name, { bold }) => (name ? bold(name) : undefined),
|
587
683
|
"chunkGroup.isOverSizeLimit": (isOverSizeLimit, { formatFlag, yellow }) =>
|
588
684
|
isOverSizeLimit ? yellow(formatFlag("big")) : undefined,
|
589
685
|
"chunkGroup.assetsSize": (size, { formatSize }) =>
|
@@ -631,7 +727,15 @@ const CHUNK_GROUP_PRINTERS = {
|
|
631
727
|
"chunkGroupChild.name": name => (name ? `(name: ${name})` : undefined)
|
632
728
|
};
|
633
729
|
|
634
|
-
/**
|
730
|
+
/**
|
731
|
+
* @typedef {Printers<KnownStatsChunk, "chunk"> &
|
732
|
+
* { ["chunk.childrenByOrder[].type"]: SimplePrinter<string, "chunk"> } &
|
733
|
+
* { ["chunk.childrenByOrder[].children[]"]: SimplePrinter<ChunkId, "chunk"> } &
|
734
|
+
* Exclamation<KnownStatsChunk, "chunk.separator", "chunk"> &
|
735
|
+
* Printers<KnownStatsChunkOrigin, "chunkOrigin">} ChunkPrinters
|
736
|
+
*/
|
737
|
+
|
738
|
+
/** @type {ChunkPrinters} */
|
635
739
|
const CHUNK_PRINTERS = {
|
636
740
|
"chunk.id": (id, { formatChunkId }) => formatChunkId(id),
|
637
741
|
"chunk.files[]": (file, { formatFilename }) => formatFilename(file),
|
@@ -685,7 +789,15 @@ const CHUNK_PRINTERS = {
|
|
685
789
|
"chunkOrigin.loc": loc => loc
|
686
790
|
};
|
687
791
|
|
688
|
-
/**
|
792
|
+
/**
|
793
|
+
* @typedef {Printers<KnownStatsError, "error"> &
|
794
|
+
* { ["error.filteredDetails"]?: SimplePrinter<number, "error"> } &
|
795
|
+
* Exclamation<KnownStatsError, "error.separator", "error">} ErrorPrinters
|
796
|
+
*/
|
797
|
+
|
798
|
+
/**
|
799
|
+
* @type {ErrorPrinters}
|
800
|
+
*/
|
689
801
|
const ERROR_PRINTERS = {
|
690
802
|
"error.compilerPath": (compilerPath, { bold }) =>
|
691
803
|
compilerPath ? bold(`(${compilerPath})`) : undefined,
|
@@ -711,7 +823,16 @@ const ERROR_PRINTERS = {
|
|
711
823
|
"error.separator!": () => "\n"
|
712
824
|
};
|
713
825
|
|
714
|
-
/**
|
826
|
+
/**
|
827
|
+
* @typedef {Printers<KnownStatsLoggingEntry, `loggingEntry(${LogTypeEnum}).loggingEntry`> &
|
828
|
+
* { ["loggingEntry(clear).loggingEntry"]?: SimplePrinter<KnownStatsLoggingEntry, "logging"> } &
|
829
|
+
* { ["loggingEntry.trace[]"]?: SimplePrinter<Exclude<KnownStatsLoggingEntry["trace"], undefined>[number], "logging"> } &
|
830
|
+
* { loggingGroup?: SimplePrinter<KnownStatsLogging[], "logging"> } &
|
831
|
+
* Printers<KnownStatsLogging & { name: string }, `loggingGroup`> &
|
832
|
+
* Exclamation<KnownStatsLogging, "loggingGroup.separator", "loggingGroup">} LogEntryPrinters
|
833
|
+
*/
|
834
|
+
|
835
|
+
/** @type {LogEntryPrinters} */
|
715
836
|
const LOG_ENTRY_PRINTERS = {
|
716
837
|
"loggingEntry(error).loggingEntry.message": (message, { red }) =>
|
717
838
|
mapLines(message, x => `<e> ${red(x)}`),
|
@@ -751,18 +872,22 @@ const LOG_ENTRY_PRINTERS = {
|
|
751
872
|
filteredEntries > 0 ? `+ ${filteredEntries} hidden lines` : undefined
|
752
873
|
};
|
753
874
|
|
754
|
-
/** @
|
875
|
+
/** @typedef {Printers<KnownStatsModuleTraceItem, "moduleTraceItem">} ModuleTraceItemPrinters */
|
876
|
+
|
877
|
+
/** @type {ModuleTraceItemPrinters} */
|
755
878
|
const MODULE_TRACE_ITEM_PRINTERS = {
|
756
879
|
"moduleTraceItem.originName": originName => originName
|
757
880
|
};
|
758
881
|
|
759
|
-
/** @
|
882
|
+
/** @typedef {Printers<KnownStatsModuleTraceDependency, "moduleTraceDependency">} ModuleTraceDependencyPrinters */
|
883
|
+
|
884
|
+
/** @type {ModuleTraceDependencyPrinters} */
|
760
885
|
const MODULE_TRACE_DEPENDENCY_PRINTERS = {
|
761
886
|
"moduleTraceDependency.loc": loc => loc
|
762
887
|
};
|
763
888
|
|
764
889
|
/**
|
765
|
-
* @type {Record<string, string | ((item:
|
890
|
+
* @type {Record<string, string | ((item: KnownStatsLoggingEntry) => string)>}
|
766
891
|
*/
|
767
892
|
const ITEM_NAMES = {
|
768
893
|
"compilation.assets[]": "asset",
|
@@ -1154,7 +1279,7 @@ const joinError =
|
|
1154
1279
|
error =>
|
1155
1280
|
/**
|
1156
1281
|
* @param {Item[]} items items
|
1157
|
-
* @param {
|
1282
|
+
* @param {StatsPrinterContextWithExtra} ctx context
|
1158
1283
|
* @returns {string} result
|
1159
1284
|
*/
|
1160
1285
|
(items, { red, yellow }) =>
|
@@ -1163,8 +1288,8 @@ const joinError =
|
|
1163
1288
|
""
|
1164
1289
|
)}`;
|
1165
1290
|
|
1166
|
-
/** @typedef {{ element: string, content: string }} Item */
|
1167
|
-
/** @typedef {(items: Item[], context: Required<
|
1291
|
+
/** @typedef {{ element: string, content: string | undefined }} Item */
|
1292
|
+
/** @typedef {(items: Item[], context: StatsPrinterContextWithExtra & Required<KnownStatsPrinterContext>) => string} SimpleElementJoiner */
|
1168
1293
|
|
1169
1294
|
/** @type {Record<string, SimpleElementJoiner>} */
|
1170
1295
|
const SIMPLE_ELEMENT_JOINERS = {
|
@@ -1325,9 +1450,7 @@ const SIMPLE_ELEMENT_JOINERS = {
|
|
1325
1450
|
moduleTraceDependency: joinOneLine
|
1326
1451
|
};
|
1327
1452
|
|
1328
|
-
/** @
|
1329
|
-
|
1330
|
-
/** @type {Record<ColorNames, string>} */
|
1453
|
+
/** @type {Record<keyof KnownStatsPrinterColorFunctions, string>} */
|
1331
1454
|
const AVAILABLE_COLORS = {
|
1332
1455
|
bold: "\u001B[1m",
|
1333
1456
|
yellow: "\u001B[1m\u001B[33m",
|
@@ -1337,7 +1460,9 @@ const AVAILABLE_COLORS = {
|
|
1337
1460
|
magenta: "\u001B[1m\u001B[35m"
|
1338
1461
|
};
|
1339
1462
|
|
1340
|
-
/** @
|
1463
|
+
/** @typedef {Required<{ [Key in keyof KnownStatsPrinterFormatters]: (value: Parameters<NonNullable<KnownStatsPrinterFormatters[Key]>>[0], options: Required<KnownStatsPrinterColorFunctions> & StatsPrinterContext, ...args: TODO[]) => string }>} AvailableFormats */
|
1464
|
+
|
1465
|
+
/** @type {AvailableFormats} */
|
1341
1466
|
const AVAILABLE_FORMATS = {
|
1342
1467
|
formatChunkId: (id, { yellow }, direction) => {
|
1343
1468
|
switch (direction) {
|
@@ -1476,7 +1601,9 @@ class DefaultStatsPrinterPlugin {
|
|
1476
1601
|
.for("compilation")
|
1477
1602
|
.tap("DefaultStatsPrinterPlugin", (compilation, context) => {
|
1478
1603
|
for (const color of Object.keys(AVAILABLE_COLORS)) {
|
1479
|
-
const name =
|
1604
|
+
const name =
|
1605
|
+
/** @type {keyof KnownStatsPrinterColorFunctions} */
|
1606
|
+
(color);
|
1480
1607
|
/** @type {string | undefined} */
|
1481
1608
|
let start;
|
1482
1609
|
if (options.colors) {
|
@@ -1490,10 +1617,7 @@ class DefaultStatsPrinterPlugin {
|
|
1490
1617
|
}
|
1491
1618
|
}
|
1492
1619
|
if (start) {
|
1493
|
-
/**
|
1494
|
-
* @param {string} str string
|
1495
|
-
* @returns {string} string with color
|
1496
|
-
*/
|
1620
|
+
/** @type {ColorFunction} */
|
1497
1621
|
context[color] = str =>
|
1498
1622
|
`${start}${
|
1499
1623
|
typeof str === "string"
|
@@ -1519,9 +1643,15 @@ class DefaultStatsPrinterPlugin {
|
|
1519
1643
|
* @returns {string} result
|
1520
1644
|
*/
|
1521
1645
|
(content, ...args) =>
|
1522
|
-
|
1646
|
+
/** @type {TODO} */
|
1647
|
+
(
|
1648
|
+
AVAILABLE_FORMATS[
|
1649
|
+
/** @type {keyof AvailableFormats} */
|
1650
|
+
(format)
|
1651
|
+
]
|
1652
|
+
)(
|
1523
1653
|
content,
|
1524
|
-
/** @type {Required<
|
1654
|
+
/** @type {StatsPrinterContext & Required<KnownStatsPrinterColorFunctions>} */
|
1525
1655
|
(context),
|
1526
1656
|
...args
|
1527
1657
|
);
|
@@ -1533,7 +1663,13 @@ class DefaultStatsPrinterPlugin {
|
|
1533
1663
|
stats.hooks.print
|
1534
1664
|
.for(key)
|
1535
1665
|
.tap("DefaultStatsPrinterPlugin", (obj, ctx) =>
|
1536
|
-
|
1666
|
+
/** @type {TODO} */
|
1667
|
+
(
|
1668
|
+
COMPILATION_SIMPLE_PRINTERS[
|
1669
|
+
/** @type {keyof CompilationSimplePrinters} */
|
1670
|
+
(key)
|
1671
|
+
]
|
1672
|
+
)(
|
1537
1673
|
obj,
|
1538
1674
|
/** @type {DefineStatsPrinterContext<"compilation">} */
|
1539
1675
|
(ctx),
|
@@ -1546,9 +1682,15 @@ class DefaultStatsPrinterPlugin {
|
|
1546
1682
|
stats.hooks.print
|
1547
1683
|
.for(key)
|
1548
1684
|
.tap("DefaultStatsPrinterPlugin", (obj, ctx) =>
|
1549
|
-
|
1685
|
+
/** @type {NonNullable<AssetSimplePrinters[keyof AssetSimplePrinters]>} */
|
1686
|
+
(
|
1687
|
+
ASSET_SIMPLE_PRINTERS[
|
1688
|
+
/** @type {keyof AssetSimplePrinters} */
|
1689
|
+
(key)
|
1690
|
+
]
|
1691
|
+
)(
|
1550
1692
|
obj,
|
1551
|
-
/** @type {DefineStatsPrinterContext<"asset">} */
|
1693
|
+
/** @type {DefineStatsPrinterContext<"asset" | "asset.info">} */
|
1552
1694
|
(ctx),
|
1553
1695
|
stats
|
1554
1696
|
)
|
@@ -1559,7 +1701,13 @@ class DefaultStatsPrinterPlugin {
|
|
1559
1701
|
stats.hooks.print
|
1560
1702
|
.for(key)
|
1561
1703
|
.tap("DefaultStatsPrinterPlugin", (obj, ctx) =>
|
1562
|
-
|
1704
|
+
/** @type {TODO} */
|
1705
|
+
(
|
1706
|
+
MODULE_SIMPLE_PRINTERS[
|
1707
|
+
/** @type {keyof ModuleSimplePrinters} */
|
1708
|
+
(key)
|
1709
|
+
]
|
1710
|
+
)(
|
1563
1711
|
obj,
|
1564
1712
|
/** @type {DefineStatsPrinterContext<"module">} */
|
1565
1713
|
(ctx),
|
@@ -1572,8 +1720,13 @@ class DefaultStatsPrinterPlugin {
|
|
1572
1720
|
stats.hooks.print
|
1573
1721
|
.for(key)
|
1574
1722
|
.tap("DefaultStatsPrinterPlugin", (obj, ctx) =>
|
1575
|
-
/** @type {
|
1576
|
-
(
|
1723
|
+
/** @type {NonNullable<ModuleIssuerPrinters[keyof ModuleIssuerPrinters]>} */
|
1724
|
+
(
|
1725
|
+
MODULE_ISSUER_PRINTERS[
|
1726
|
+
/** @type {keyof ModuleIssuerPrinters} */
|
1727
|
+
(key)
|
1728
|
+
]
|
1729
|
+
)(
|
1577
1730
|
obj,
|
1578
1731
|
/** @type {DefineStatsPrinterContext<"moduleIssuer">} */
|
1579
1732
|
(ctx),
|
@@ -1586,7 +1739,13 @@ class DefaultStatsPrinterPlugin {
|
|
1586
1739
|
stats.hooks.print
|
1587
1740
|
.for(key)
|
1588
1741
|
.tap("DefaultStatsPrinterPlugin", (obj, ctx) =>
|
1589
|
-
|
1742
|
+
/** @type {TODO} */
|
1743
|
+
(
|
1744
|
+
MODULE_REASON_PRINTERS[
|
1745
|
+
/** @type {keyof ModuleReasonsPrinters} */
|
1746
|
+
(key)
|
1747
|
+
]
|
1748
|
+
)(
|
1590
1749
|
obj,
|
1591
1750
|
/** @type {DefineStatsPrinterContext<"moduleReason">} */
|
1592
1751
|
(ctx),
|
@@ -1599,8 +1758,13 @@ class DefaultStatsPrinterPlugin {
|
|
1599
1758
|
stats.hooks.print
|
1600
1759
|
.for(key)
|
1601
1760
|
.tap("DefaultStatsPrinterPlugin", (obj, ctx) =>
|
1602
|
-
/** @type {
|
1603
|
-
(
|
1761
|
+
/** @type {NonNullable<ModuleProfilePrinters[keyof ModuleProfilePrinters]>} */
|
1762
|
+
(
|
1763
|
+
MODULE_PROFILE_PRINTERS[
|
1764
|
+
/** @type {keyof ModuleProfilePrinters} */
|
1765
|
+
(key)
|
1766
|
+
]
|
1767
|
+
)(
|
1604
1768
|
obj,
|
1605
1769
|
/** @type {DefineStatsPrinterContext<"profile">} */
|
1606
1770
|
(ctx),
|
@@ -1613,7 +1777,13 @@ class DefaultStatsPrinterPlugin {
|
|
1613
1777
|
stats.hooks.print
|
1614
1778
|
.for(key)
|
1615
1779
|
.tap("DefaultStatsPrinterPlugin", (obj, ctx) =>
|
1616
|
-
|
1780
|
+
/** @type {TODO} */
|
1781
|
+
(
|
1782
|
+
CHUNK_GROUP_PRINTERS[
|
1783
|
+
/** @type {keyof ChunkGroupPrinters} */
|
1784
|
+
(key)
|
1785
|
+
]
|
1786
|
+
)(
|
1617
1787
|
obj,
|
1618
1788
|
/** @type {DefineStatsPrinterContext<"chunkGroupKind" | "chunkGroup">} */
|
1619
1789
|
(ctx),
|
@@ -1626,7 +1796,8 @@ class DefaultStatsPrinterPlugin {
|
|
1626
1796
|
stats.hooks.print
|
1627
1797
|
.for(key)
|
1628
1798
|
.tap("DefaultStatsPrinterPlugin", (obj, ctx) =>
|
1629
|
-
|
1799
|
+
/** @type {TODO} */
|
1800
|
+
(CHUNK_PRINTERS[/** @type {keyof ChunkPrinters} */ (key)])(
|
1630
1801
|
obj,
|
1631
1802
|
/** @type {DefineStatsPrinterContext<"chunk">} */
|
1632
1803
|
(ctx),
|
@@ -1639,8 +1810,8 @@ class DefaultStatsPrinterPlugin {
|
|
1639
1810
|
stats.hooks.print
|
1640
1811
|
.for(key)
|
1641
1812
|
.tap("DefaultStatsPrinterPlugin", (obj, ctx) =>
|
1642
|
-
/** @type {
|
1643
|
-
(ERROR_PRINTERS
|
1813
|
+
/** @type {TODO} */
|
1814
|
+
(ERROR_PRINTERS[/** @type {keyof ErrorPrinters} */ (key)])(
|
1644
1815
|
obj,
|
1645
1816
|
/** @type {DefineStatsPrinterContext<"error">} */
|
1646
1817
|
(ctx),
|
@@ -1653,7 +1824,13 @@ class DefaultStatsPrinterPlugin {
|
|
1653
1824
|
stats.hooks.print
|
1654
1825
|
.for(key)
|
1655
1826
|
.tap("DefaultStatsPrinterPlugin", (obj, ctx) =>
|
1656
|
-
|
1827
|
+
/** @type {TODO} */
|
1828
|
+
(
|
1829
|
+
LOG_ENTRY_PRINTERS[
|
1830
|
+
/** @type {keyof LogEntryPrinters} */
|
1831
|
+
(key)
|
1832
|
+
]
|
1833
|
+
)(
|
1657
1834
|
obj,
|
1658
1835
|
/** @type {DefineStatsPrinterContext<"logging">} */
|
1659
1836
|
(ctx),
|
@@ -1666,8 +1843,13 @@ class DefaultStatsPrinterPlugin {
|
|
1666
1843
|
stats.hooks.print
|
1667
1844
|
.for(key)
|
1668
1845
|
.tap("DefaultStatsPrinterPlugin", (obj, ctx) =>
|
1669
|
-
/** @type {
|
1670
|
-
(
|
1846
|
+
/** @type {NonNullable<ModuleTraceDependencyPrinters[keyof ModuleTraceDependencyPrinters]>} */
|
1847
|
+
(
|
1848
|
+
MODULE_TRACE_DEPENDENCY_PRINTERS[
|
1849
|
+
/** @type {keyof ModuleTraceDependencyPrinters} */
|
1850
|
+
(key)
|
1851
|
+
]
|
1852
|
+
)(
|
1671
1853
|
obj,
|
1672
1854
|
/** @type {DefineStatsPrinterContext<"moduleTraceDependency">} */
|
1673
1855
|
(ctx),
|
@@ -1680,8 +1862,13 @@ class DefaultStatsPrinterPlugin {
|
|
1680
1862
|
stats.hooks.print
|
1681
1863
|
.for(key)
|
1682
1864
|
.tap("DefaultStatsPrinterPlugin", (obj, ctx) =>
|
1683
|
-
/** @type {
|
1684
|
-
(
|
1865
|
+
/** @type {NonNullable<ModuleTraceItemPrinters[keyof ModuleTraceItemPrinters]>} */
|
1866
|
+
(
|
1867
|
+
MODULE_TRACE_ITEM_PRINTERS[
|
1868
|
+
/** @type {keyof ModuleTraceItemPrinters} */
|
1869
|
+
(key)
|
1870
|
+
]
|
1871
|
+
)(
|
1685
1872
|
obj,
|
1686
1873
|
/** @type {DefineStatsPrinterContext<"moduleTraceItem">} */
|
1687
1874
|
(ctx),
|