webpack 5.20.1 → 5.21.2
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.
Potentially problematic release.
This version of webpack might be problematic. Click here for more details.
- package/bin/webpack.js +0 -0
- package/lib/APIPlugin.js +6 -0
- package/lib/Compilation.js +1 -0
- package/lib/Generator.js +1 -0
- package/lib/ModuleDependencyError.js +10 -1
- package/lib/ModuleDependencyWarning.js +9 -1
- package/lib/MultiStats.js +8 -0
- package/lib/NoModeWarning.js +2 -2
- package/lib/NormalModule.js +10 -1
- package/lib/RuntimePlugin.js +1 -0
- package/lib/Stats.js +6 -0
- package/lib/asset/AssetGenerator.js +10 -1
- package/lib/asset/AssetModulesPlugin.js +14 -5
- package/lib/cache/IdleFileCachePlugin.js +9 -3
- package/lib/config/defaults.js +1 -0
- package/lib/dependencies/HarmonyImportDependency.js +5 -3
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +9 -2
- package/lib/index.js +1 -0
- package/lib/json/JsonGenerator.js +28 -7
- package/lib/serialization/ObjectMiddleware.js +8 -6
- package/lib/stats/DefaultStatsFactoryPlugin.js +350 -38
- package/lib/stats/DefaultStatsPresetPlugin.js +8 -7
- package/lib/stats/DefaultStatsPrinterPlugin.js +69 -4
- package/lib/stats/StatsPrinter.js +12 -6
- package/package.json +1 -1
- package/schemas/WebpackOptions.json +8 -1
- package/types.d.ts +215 -20
@@ -29,6 +29,7 @@ const { makePathsRelative, parseResource } = require("../util/identifier");
|
|
29
29
|
/** @typedef {import("../ChunkGroup").OriginRecord} OriginRecord */
|
30
30
|
/** @typedef {import("../Compilation")} Compilation */
|
31
31
|
/** @typedef {import("../Compilation").Asset} Asset */
|
32
|
+
/** @typedef {import("../Compilation").AssetInfo} AssetInfo */
|
32
33
|
/** @typedef {import("../Compilation").NormalizedStatsOptions} NormalizedStatsOptions */
|
33
34
|
/** @typedef {import("../Compiler")} Compiler */
|
34
35
|
/** @typedef {import("../Dependency")} Dependency */
|
@@ -44,27 +45,272 @@ const { makePathsRelative, parseResource } = require("../util/identifier");
|
|
44
45
|
/** @typedef {import("./StatsFactory")} StatsFactory */
|
45
46
|
/** @typedef {import("./StatsFactory").StatsFactoryContext} StatsFactoryContext */
|
46
47
|
|
47
|
-
/** @typedef {
|
48
|
+
/** @typedef {KnownStatsCompilation & Record<string, any>} StatsCompilation */
|
49
|
+
/**
|
50
|
+
* @typedef {Object} KnownStatsCompilation
|
51
|
+
* @property {any=} env
|
52
|
+
* @property {string=} name
|
53
|
+
* @property {string=} hash
|
54
|
+
* @property {string=} version
|
55
|
+
* @property {number=} time
|
56
|
+
* @property {number=} builtAt
|
57
|
+
* @property {boolean=} needAdditionalPass
|
58
|
+
* @property {string=} publicPath
|
59
|
+
* @property {string=} outputPath
|
60
|
+
* @property {Record<string, string[]>=} assetsByChunkName
|
61
|
+
* @property {StatsAsset[]=} assets
|
62
|
+
* @property {number=} filteredAssets
|
63
|
+
* @property {StatsChunk[]=} chunks
|
64
|
+
* @property {StatsModule[]=} modules
|
65
|
+
* @property {number=} filteredModules
|
66
|
+
* @property {Record<string, StatsChunkGroup>=} entrypoints
|
67
|
+
* @property {Record<string, StatsChunkGroup>=} namedChunkGroups
|
68
|
+
* @property {StatsError[]=} errors
|
69
|
+
* @property {number=} errorsCount
|
70
|
+
* @property {StatsError[]=} warnings
|
71
|
+
* @property {number=} warningsCount
|
72
|
+
* @property {StatsCompilation[]=} children
|
73
|
+
* @property {Record<string, StatsLogging>=} logging
|
74
|
+
*/
|
75
|
+
|
76
|
+
/** @typedef {KnownStatsLogging & Record<string, any>} StatsLogging */
|
77
|
+
/**
|
78
|
+
* @typedef {Object} KnownStatsLogging
|
79
|
+
* @property {StatsLoggingEntry[]} entries
|
80
|
+
* @property {number} filteredEntries
|
81
|
+
* @property {boolean} debug
|
82
|
+
*/
|
48
83
|
|
49
|
-
/** @
|
84
|
+
/** @typedef {KnownStatsLoggingEntry & Record<string, any>} StatsLoggingEntry */
|
85
|
+
/**
|
86
|
+
* @typedef {Object} KnownStatsLoggingEntry
|
87
|
+
* @property {string} type
|
88
|
+
* @property {string} message
|
89
|
+
* @property {string[]=} trace
|
90
|
+
* @property {StatsLoggingEntry[]=} children
|
91
|
+
* @property {any[]=} args
|
92
|
+
* @property {number=} time
|
93
|
+
*/
|
94
|
+
|
95
|
+
/** @typedef {KnownStatsAsset & Record<string, any>} StatsAsset */
|
96
|
+
/**
|
97
|
+
* @typedef {Object} KnownStatsAsset
|
98
|
+
* @property {string} type
|
99
|
+
* @property {string} name
|
100
|
+
* @property {AssetInfo} info
|
101
|
+
* @property {number} size
|
102
|
+
* @property {boolean} emitted
|
103
|
+
* @property {boolean} comparedForEmit
|
104
|
+
* @property {boolean} cached
|
105
|
+
* @property {StatsAsset[]=} related
|
106
|
+
* @property {(string|number)[]=} chunkNames
|
107
|
+
* @property {(string|number)[]=} chunkIdHints
|
108
|
+
* @property {(string|number)[]=} chunks
|
109
|
+
* @property {(string|number)[]=} auxiliaryChunkNames
|
110
|
+
* @property {(string|number)[]=} auxiliaryChunks
|
111
|
+
* @property {(string|number)[]=} auxiliaryChunkIdHints
|
112
|
+
* @property {number=} filteredRelated
|
113
|
+
* @property {boolean=} isOverSizeLimit
|
114
|
+
*/
|
115
|
+
|
116
|
+
/** @typedef {KnownStatsChunkGroup & Record<string, any>} StatsChunkGroup */
|
117
|
+
/**
|
118
|
+
* @typedef {Object} KnownStatsChunkGroup
|
119
|
+
* @property {string=} name
|
120
|
+
* @property {(string|number)[]=} chunks
|
121
|
+
* @property {({ name: string, size?: number })[]=} assets
|
122
|
+
* @property {number=} filteredAssets
|
123
|
+
* @property {number=} assetsSize
|
124
|
+
* @property {({ name: string, size?: number })[]=} auxiliaryAssets
|
125
|
+
* @property {number=} filteredAuxiliaryAssets
|
126
|
+
* @property {number=} auxiliaryAssetsSize
|
127
|
+
* @property {{ [x: string]: StatsChunkGroup[] }=} children
|
128
|
+
* @property {{ [x: string]: string[] }=} childAssets
|
129
|
+
* @property {boolean=} isOverSizeLimit
|
130
|
+
*/
|
131
|
+
|
132
|
+
/** @typedef {KnownStatsModule & Record<string, any>} StatsModule */
|
133
|
+
/**
|
134
|
+
* @typedef {Object} KnownStatsModule
|
135
|
+
* @property {string=} type
|
136
|
+
* @property {string=} moduleType
|
137
|
+
* @property {string=} layer
|
138
|
+
* @property {string=} identifier
|
139
|
+
* @property {string=} name
|
140
|
+
* @property {string=} nameForCondition
|
141
|
+
* @property {number=} index
|
142
|
+
* @property {number=} preOrderIndex
|
143
|
+
* @property {number=} index2
|
144
|
+
* @property {number=} postOrderIndex
|
145
|
+
* @property {number=} size
|
146
|
+
* @property {{[x: string]: number}=} sizes
|
147
|
+
* @property {boolean=} cacheable
|
148
|
+
* @property {boolean=} built
|
149
|
+
* @property {boolean=} codeGenerated
|
150
|
+
* @property {boolean=} cached
|
151
|
+
* @property {boolean=} optional
|
152
|
+
* @property {boolean=} orphan
|
153
|
+
* @property {string|number=} id
|
154
|
+
* @property {string|number=} issuerId
|
155
|
+
* @property {(string|number)[]=} chunks
|
156
|
+
* @property {(string|number)[]=} assets
|
157
|
+
* @property {boolean=} dependent
|
158
|
+
* @property {string=} issuer
|
159
|
+
* @property {string=} issuerName
|
160
|
+
* @property {StatsModuleIssuer[]=} issuerPath
|
161
|
+
* @property {boolean=} failed
|
162
|
+
* @property {number=} errors
|
163
|
+
* @property {number=} warnings
|
164
|
+
* @property {StatsProfile=} profile
|
165
|
+
* @property {StatsModuleReason[]=} reasons
|
166
|
+
* @property {(boolean | string[])=} usedExports
|
167
|
+
* @property {string[]=} providedExports
|
168
|
+
* @property {string[]=} optimizationBailout
|
169
|
+
* @property {number=} depth
|
170
|
+
* @property {StatsModule[]=} modules
|
171
|
+
* @property {number=} filteredModules
|
172
|
+
* @property {ReturnType<Source["source"]>=} source
|
173
|
+
*/
|
174
|
+
|
175
|
+
/** @typedef {KnownStatsProfile & Record<string, any>} StatsProfile */
|
176
|
+
/**
|
177
|
+
* @typedef {Object} KnownStatsProfile
|
178
|
+
* @property {number} total
|
179
|
+
* @property {number} resolving
|
180
|
+
* @property {number} restoring
|
181
|
+
* @property {number} building
|
182
|
+
* @property {number} integration
|
183
|
+
* @property {number} storing
|
184
|
+
* @property {number} additionalResolving
|
185
|
+
* @property {number} additionalIntegration
|
186
|
+
* @property {number} factory
|
187
|
+
* @property {number} dependencies
|
188
|
+
*/
|
189
|
+
|
190
|
+
/** @typedef {KnownStatsModuleIssuer & Record<string, any>} StatsModuleIssuer */
|
191
|
+
/**
|
192
|
+
* @typedef {Object} KnownStatsModuleIssuer
|
193
|
+
* @property {string=} identifier
|
194
|
+
* @property {string=} name
|
195
|
+
* @property {(string|number)=} id
|
196
|
+
* @property {StatsProfile=} profile
|
197
|
+
*/
|
198
|
+
|
199
|
+
/** @typedef {KnownStatsModuleReason & Record<string, any>} StatsModuleReason */
|
200
|
+
/**
|
201
|
+
* @typedef {Object} KnownStatsModuleReason
|
202
|
+
* @property {string=} moduleIdentifier
|
203
|
+
* @property {string=} module
|
204
|
+
* @property {string=} moduleName
|
205
|
+
* @property {string=} resolvedModuleIdentifier
|
206
|
+
* @property {string=} resolvedModule
|
207
|
+
* @property {string=} type
|
208
|
+
* @property {boolean} active
|
209
|
+
* @property {string=} explanation
|
210
|
+
* @property {string=} userRequest
|
211
|
+
* @property {string=} loc
|
212
|
+
* @property {(string|number)=} moduleId
|
213
|
+
* @property {(string|number)=} resolvedModuleId
|
214
|
+
*/
|
215
|
+
|
216
|
+
/** @typedef {KnownStatsChunk & Record<string, any>} StatsChunk */
|
217
|
+
/**
|
218
|
+
* @typedef {Object} KnownStatsChunk
|
219
|
+
* @property {boolean} rendered
|
220
|
+
* @property {boolean} initial
|
221
|
+
* @property {boolean} entry
|
222
|
+
* @property {boolean} recorded
|
223
|
+
* @property {string=} reason
|
224
|
+
* @property {number} size
|
225
|
+
* @property {Record<string, number>=} sizes
|
226
|
+
* @property {string[]=} names
|
227
|
+
* @property {string[]=} idHints
|
228
|
+
* @property {string[]=} runtime
|
229
|
+
* @property {string[]=} files
|
230
|
+
* @property {string[]=} auxiliaryFiles
|
231
|
+
* @property {string} hash
|
232
|
+
* @property {Record<string, (string|number)[]>=} childrenByOrder
|
233
|
+
* @property {(string|number)=} id
|
234
|
+
* @property {(string|number)[]=} siblings
|
235
|
+
* @property {(string|number)[]=} parents
|
236
|
+
* @property {(string|number)[]=} children
|
237
|
+
* @property {StatsModule[]=} modules
|
238
|
+
* @property {number=} filteredModules
|
239
|
+
* @property {StatsChunkOrigin[]=} origins
|
240
|
+
*/
|
241
|
+
|
242
|
+
/** @typedef {KnownStatsChunkOrigin & Record<string, any>} StatsChunkOrigin */
|
243
|
+
/**
|
244
|
+
* @typedef {Object} KnownStatsChunkOrigin
|
245
|
+
* @property {string=} module
|
246
|
+
* @property {string=} moduleIdentifier
|
247
|
+
* @property {string=} moduleName
|
248
|
+
* @property {string=} loc
|
249
|
+
* @property {string=} request
|
250
|
+
* @property {(string|number)=} moduleId
|
251
|
+
*/
|
252
|
+
|
253
|
+
/** @typedef {KnownStatsModuleTraceItem & Record<string, any>} StatsModuleTraceItem */
|
254
|
+
/**
|
255
|
+
* @typedef {Object} KnownStatsModuleTraceItem
|
256
|
+
* @property {string=} originIdentifier
|
257
|
+
* @property {string=} originName
|
258
|
+
* @property {string=} moduleIdentifier
|
259
|
+
* @property {string=} moduleName
|
260
|
+
* @property {StatsModuleTraceDependency[]=} dependencies
|
261
|
+
* @property {(string|number)=} originId
|
262
|
+
* @property {(string|number)=} moduleId
|
263
|
+
*/
|
264
|
+
|
265
|
+
/** @typedef {KnownStatsModuleTraceDependency & Record<string, any>} StatsModuleTraceDependency */
|
266
|
+
/**
|
267
|
+
* @typedef {Object} KnownStatsModuleTraceDependency
|
268
|
+
* @property {string=} loc
|
269
|
+
*/
|
270
|
+
|
271
|
+
/** @typedef {KnownStatsError & Record<string, any>} StatsError */
|
272
|
+
/**
|
273
|
+
* @typedef {Object} KnownStatsError
|
274
|
+
* @property {string} message
|
275
|
+
* @property {string=} chunkName
|
276
|
+
* @property {boolean=} chunkEntry
|
277
|
+
* @property {boolean=} chunkInitial
|
278
|
+
* @property {string=} file
|
279
|
+
* @property {string=} moduleIdentifier
|
280
|
+
* @property {string=} moduleName
|
281
|
+
* @property {string=} loc
|
282
|
+
* @property {string|number=} chunkId
|
283
|
+
* @property {string|number=} moduleId
|
284
|
+
* @property {any=} moduleTrace
|
285
|
+
* @property {any=} details
|
286
|
+
* @property {any=} stack
|
287
|
+
*/
|
288
|
+
|
289
|
+
/** @typedef {Asset & { type: string, related: PreprocessedAsset[] }} PreprocessedAsset */
|
290
|
+
|
291
|
+
/**
|
292
|
+
* @template T
|
293
|
+
* @template O
|
294
|
+
* @typedef {Record<string, (object: O, data: T, context: StatsFactoryContext, options: NormalizedStatsOptions, factory: StatsFactory) => void>} ExtractorsByOption
|
295
|
+
*/
|
50
296
|
|
51
297
|
/**
|
52
298
|
* @typedef {Object} SimpleExtractors
|
53
|
-
* @property {ExtractorsByOption<Compilation>} compilation
|
54
|
-
* @property {ExtractorsByOption<
|
55
|
-
* @property {ExtractorsByOption<
|
56
|
-
* @property {ExtractorsByOption<{ name: string, chunkGroup: ChunkGroup }>} chunkGroup
|
57
|
-
* @property {ExtractorsByOption<Module>} module
|
58
|
-
* @property {ExtractorsByOption<Module>} module$visible
|
59
|
-
* @property {ExtractorsByOption<Module>} moduleIssuer
|
60
|
-
* @property {ExtractorsByOption<ModuleProfile>} profile
|
61
|
-
* @property {ExtractorsByOption<ModuleGraphConnection>} moduleReason
|
62
|
-
* @property {ExtractorsByOption<Chunk>} chunk
|
63
|
-
* @property {ExtractorsByOption<OriginRecord>} chunkOrigin
|
64
|
-
* @property {ExtractorsByOption<WebpackError>} error
|
65
|
-
* @property {ExtractorsByOption<WebpackError>} warning
|
66
|
-
* @property {ExtractorsByOption<{ origin: Module, module: Module }>} moduleTraceItem
|
67
|
-
* @property {ExtractorsByOption<Dependency>} moduleTraceDependency
|
299
|
+
* @property {ExtractorsByOption<Compilation, StatsCompilation>} compilation
|
300
|
+
* @property {ExtractorsByOption<PreprocessedAsset, StatsAsset>} asset
|
301
|
+
* @property {ExtractorsByOption<PreprocessedAsset, StatsAsset>} asset$visible
|
302
|
+
* @property {ExtractorsByOption<{ name: string, chunkGroup: ChunkGroup }, StatsChunkGroup>} chunkGroup
|
303
|
+
* @property {ExtractorsByOption<Module, StatsModule>} module
|
304
|
+
* @property {ExtractorsByOption<Module, StatsModule>} module$visible
|
305
|
+
* @property {ExtractorsByOption<Module, StatsModuleIssuer>} moduleIssuer
|
306
|
+
* @property {ExtractorsByOption<ModuleProfile, StatsProfile>} profile
|
307
|
+
* @property {ExtractorsByOption<ModuleGraphConnection, StatsModuleReason>} moduleReason
|
308
|
+
* @property {ExtractorsByOption<Chunk, StatsChunk>} chunk
|
309
|
+
* @property {ExtractorsByOption<OriginRecord, StatsChunkOrigin>} chunkOrigin
|
310
|
+
* @property {ExtractorsByOption<WebpackError, StatsError>} error
|
311
|
+
* @property {ExtractorsByOption<WebpackError, StatsError>} warning
|
312
|
+
* @property {ExtractorsByOption<{ origin: Module, module: Module }, StatsModuleTraceItem>} moduleTraceItem
|
313
|
+
* @property {ExtractorsByOption<Dependency, StatsModuleTraceDependency>} moduleTraceDependency
|
68
314
|
*/
|
69
315
|
|
70
316
|
/**
|
@@ -141,7 +387,7 @@ const countWithChildren = (compilation, getItems) => {
|
|
141
387
|
return count;
|
142
388
|
};
|
143
389
|
|
144
|
-
/** @type {ExtractorsByOption<WebpackError | string>} */
|
390
|
+
/** @type {ExtractorsByOption<WebpackError | string, StatsError>} */
|
145
391
|
const EXTRACT_ERROR = {
|
146
392
|
_: (object, error, context, { requestShortener }) => {
|
147
393
|
// TODO webpack 6 disallow strings in the errors/warnings list
|
@@ -201,8 +447,17 @@ const EXTRACT_ERROR = {
|
|
201
447
|
);
|
202
448
|
}
|
203
449
|
},
|
204
|
-
errorDetails: (
|
205
|
-
|
450
|
+
errorDetails: (
|
451
|
+
object,
|
452
|
+
error,
|
453
|
+
{ type, compilation, cachedGetErrors, cachedGetWarnings },
|
454
|
+
{ errorDetails }
|
455
|
+
) => {
|
456
|
+
if (
|
457
|
+
typeof error !== "string" &&
|
458
|
+
(errorDetails === true ||
|
459
|
+
(type.endsWith(".error") && cachedGetErrors(compilation).length < 3))
|
460
|
+
) {
|
206
461
|
object.details = error.details;
|
207
462
|
}
|
208
463
|
},
|
@@ -299,10 +554,12 @@ const SIMPLE_EXTRACTORS = {
|
|
299
554
|
array.push(chunk);
|
300
555
|
}
|
301
556
|
}
|
302
|
-
/** @type {Map<string,
|
557
|
+
/** @type {Map<string, PreprocessedAsset>} */
|
303
558
|
const assetMap = new Map();
|
559
|
+
/** @type {Set<PreprocessedAsset>} */
|
304
560
|
const assets = new Set();
|
305
561
|
for (const asset of compilation.getAssets()) {
|
562
|
+
/** @type {PreprocessedAsset} */
|
306
563
|
const item = {
|
307
564
|
...asset,
|
308
565
|
type: "asset",
|
@@ -469,6 +726,29 @@ const SIMPLE_EXTRACTORS = {
|
|
469
726
|
});
|
470
727
|
});
|
471
728
|
},
|
729
|
+
errorDetails: (
|
730
|
+
object,
|
731
|
+
compilation,
|
732
|
+
{ cachedGetErrors, cachedGetWarnings },
|
733
|
+
{ errorDetails, errors, warnings }
|
734
|
+
) => {
|
735
|
+
if (errorDetails === "auto") {
|
736
|
+
if (warnings) {
|
737
|
+
const warnings = cachedGetWarnings(compilation);
|
738
|
+
object.filteredWarningDetailsCount = warnings
|
739
|
+
.map(e => typeof e !== "string" && e.details)
|
740
|
+
.filter(Boolean).length;
|
741
|
+
}
|
742
|
+
if (errors) {
|
743
|
+
const errors = cachedGetErrors(compilation);
|
744
|
+
if (errors.length >= 3) {
|
745
|
+
object.filteredErrorDetailsCount = errors
|
746
|
+
.map(e => typeof e !== "string" && e.details)
|
747
|
+
.filter(Boolean).length;
|
748
|
+
}
|
749
|
+
}
|
750
|
+
}
|
751
|
+
},
|
472
752
|
logging: (object, compilation, _context, options, factory) => {
|
473
753
|
const util = require("util");
|
474
754
|
const { loggingDebug, loggingTrace, context } = options;
|
@@ -525,7 +805,9 @@ const SIMPLE_EXTRACTORS = {
|
|
525
805
|
let depthInCollapsedGroup = 0;
|
526
806
|
for (const [origin, logEntries] of compilation.logging) {
|
527
807
|
const debugMode = loggingDebug.some(fn => fn(origin));
|
808
|
+
/** @type {KnownStatsLoggingEntry[]} */
|
528
809
|
const groupStack = [];
|
810
|
+
/** @type {KnownStatsLoggingEntry[]} */
|
529
811
|
const rootList = [];
|
530
812
|
let currentList = rootList;
|
531
813
|
let processedLogEntries = 0;
|
@@ -559,6 +841,7 @@ const SIMPLE_EXTRACTORS = {
|
|
559
841
|
} else if (entry.args && entry.args.length > 0) {
|
560
842
|
message = util.format(entry.args[0], ...entry.args.slice(1));
|
561
843
|
}
|
844
|
+
/** @type {KnownStatsLoggingEntry} */
|
562
845
|
const newEntry = {
|
563
846
|
...entry,
|
564
847
|
type,
|
@@ -696,6 +979,10 @@ const SIMPLE_EXTRACTORS = {
|
|
696
979
|
const children =
|
697
980
|
chunkGroupChildren &&
|
698
981
|
chunkGroup.getChildrenByOrders(moduleGraph, chunkGraph);
|
982
|
+
/**
|
983
|
+
* @param {string} name Name
|
984
|
+
* @returns {{ name: string, size: number }} Asset object
|
985
|
+
*/
|
699
986
|
const toAsset = name => {
|
700
987
|
const asset = compilation.getAsset(name);
|
701
988
|
return {
|
@@ -703,6 +990,7 @@ const SIMPLE_EXTRACTORS = {
|
|
703
990
|
size: asset ? asset.info.size : -1
|
704
991
|
};
|
705
992
|
};
|
993
|
+
/** @type {(total: number, asset: { size: number }) => number} */
|
706
994
|
const sizeReducer = (total, { size }) => total + size;
|
707
995
|
const assets = uniqueArray(chunkGroup.chunks, c => c.files).map(toAsset);
|
708
996
|
const auxiliaryAssets = uniqueOrderedArray(
|
@@ -712,7 +1000,8 @@ const SIMPLE_EXTRACTORS = {
|
|
712
1000
|
).map(toAsset);
|
713
1001
|
const assetsSize = assets.reduce(sizeReducer, 0);
|
714
1002
|
const auxiliaryAssetsSize = auxiliaryAssets.reduce(sizeReducer, 0);
|
715
|
-
|
1003
|
+
/** @type {KnownStatsChunkGroup} */
|
1004
|
+
const statsChunkGroup = {
|
716
1005
|
name,
|
717
1006
|
chunks: ids ? chunkGroup.chunks.map(c => c.id) : undefined,
|
718
1007
|
assets: assets.length <= chunkGroupMaxAssets ? assets : undefined,
|
@@ -739,7 +1028,9 @@ const SIMPLE_EXTRACTORS = {
|
|
739
1028
|
c => c.auxiliaryFiles,
|
740
1029
|
compareIds
|
741
1030
|
).map(toAsset);
|
742
|
-
|
1031
|
+
|
1032
|
+
/** @type {KnownStatsChunkGroup} */
|
1033
|
+
const childStatsChunkGroup = {
|
743
1034
|
name: group.name,
|
744
1035
|
chunks: ids ? group.chunks.map(c => c.id) : undefined,
|
745
1036
|
assets:
|
@@ -757,6 +1048,8 @@ const SIMPLE_EXTRACTORS = {
|
|
757
1048
|
? 0
|
758
1049
|
: auxiliaryAssets.length
|
759
1050
|
};
|
1051
|
+
|
1052
|
+
return childStatsChunkGroup;
|
760
1053
|
})
|
761
1054
|
)
|
762
1055
|
: undefined,
|
@@ -774,7 +1067,8 @@ const SIMPLE_EXTRACTORS = {
|
|
774
1067
|
return Array.from(set);
|
775
1068
|
})
|
776
1069
|
: undefined
|
777
|
-
}
|
1070
|
+
};
|
1071
|
+
Object.assign(object, statsChunkGroup);
|
778
1072
|
},
|
779
1073
|
performance: (object, { chunkGroup }) => {
|
780
1074
|
object.isOverSizeLimit = SizeLimitsPlugin.isOverSizeLimit(chunkGroup);
|
@@ -785,11 +1079,13 @@ const SIMPLE_EXTRACTORS = {
|
|
785
1079
|
const { compilation, type } = context;
|
786
1080
|
const built = compilation.builtModules.has(module);
|
787
1081
|
const codeGenerated = compilation.codeGeneratedModules.has(module);
|
1082
|
+
/** @type {{[x: string]: number}} */
|
788
1083
|
const sizes = {};
|
789
1084
|
for (const sourceType of module.getSourceTypes()) {
|
790
1085
|
sizes[sourceType] = module.size(sourceType);
|
791
1086
|
}
|
792
|
-
|
1087
|
+
/** @type {KnownStatsModule} */
|
1088
|
+
const statsModule = {
|
793
1089
|
type: "module",
|
794
1090
|
moduleType: module.type,
|
795
1091
|
layer: module.layer,
|
@@ -798,7 +1094,9 @@ const SIMPLE_EXTRACTORS = {
|
|
798
1094
|
built,
|
799
1095
|
codeGenerated,
|
800
1096
|
cached: !built && !codeGenerated
|
801
|
-
}
|
1097
|
+
};
|
1098
|
+
Object.assign(object, statsModule);
|
1099
|
+
|
802
1100
|
if (built || codeGenerated || options.cachedModules) {
|
803
1101
|
Object.assign(
|
804
1102
|
object,
|
@@ -826,11 +1124,13 @@ const SIMPLE_EXTRACTORS = {
|
|
826
1124
|
const warnings = module.getWarnings();
|
827
1125
|
const warningsCount =
|
828
1126
|
warnings !== undefined ? countIterable(warnings) : 0;
|
1127
|
+
/** @type {{[x: string]: number}} */
|
829
1128
|
const sizes = {};
|
830
1129
|
for (const sourceType of module.getSourceTypes()) {
|
831
1130
|
sizes[sourceType] = module.size(sourceType);
|
832
1131
|
}
|
833
|
-
|
1132
|
+
/** @type {KnownStatsModule} */
|
1133
|
+
const statsModule = {
|
834
1134
|
identifier: module.identifier(),
|
835
1135
|
name: module.readableIdentifier(requestShortener),
|
836
1136
|
nameForCondition: module.nameForCondition(),
|
@@ -852,7 +1152,8 @@ const SIMPLE_EXTRACTORS = {
|
|
852
1152
|
failed: errorsCount > 0,
|
853
1153
|
errors: errorsCount,
|
854
1154
|
warnings: warningsCount
|
855
|
-
}
|
1155
|
+
};
|
1156
|
+
Object.assign(object, statsModule);
|
856
1157
|
if (profile) {
|
857
1158
|
object.profile = factory.create(
|
858
1159
|
`${type.slice(0, -8)}.profile`,
|
@@ -948,7 +1249,8 @@ const SIMPLE_EXTRACTORS = {
|
|
948
1249
|
},
|
949
1250
|
profile: {
|
950
1251
|
_: (object, profile) => {
|
951
|
-
|
1252
|
+
/** @type {KnownStatsProfile} */
|
1253
|
+
const statsProfile = {
|
952
1254
|
total:
|
953
1255
|
profile.factory +
|
954
1256
|
profile.restoring +
|
@@ -966,7 +1268,8 @@ const SIMPLE_EXTRACTORS = {
|
|
966
1268
|
factory: profile.factory,
|
967
1269
|
// TODO remove this in webpack 6
|
968
1270
|
dependencies: profile.additionalFactories
|
969
|
-
}
|
1271
|
+
};
|
1272
|
+
Object.assign(object, statsProfile);
|
970
1273
|
}
|
971
1274
|
},
|
972
1275
|
moduleIssuer: {
|
@@ -974,10 +1277,12 @@ const SIMPLE_EXTRACTORS = {
|
|
974
1277
|
const { compilation, type } = context;
|
975
1278
|
const { moduleGraph } = compilation;
|
976
1279
|
const profile = moduleGraph.getProfile(module);
|
977
|
-
|
1280
|
+
/** @type {KnownStatsModuleIssuer} */
|
1281
|
+
const statsModuleIssuer = {
|
978
1282
|
identifier: module.identifier(),
|
979
1283
|
name: module.readableIdentifier(requestShortener)
|
980
|
-
}
|
1284
|
+
};
|
1285
|
+
Object.assign(object, statsModuleIssuer);
|
981
1286
|
if (profile) {
|
982
1287
|
object.profile = factory.create(`${type}.profile`, profile, context);
|
983
1288
|
}
|
@@ -991,7 +1296,8 @@ const SIMPLE_EXTRACTORS = {
|
|
991
1296
|
const dep = reason.dependency;
|
992
1297
|
const moduleDep =
|
993
1298
|
dep && dep instanceof ModuleDependency ? dep : undefined;
|
994
|
-
|
1299
|
+
/** @type {KnownStatsModuleReason} */
|
1300
|
+
const statsModuleReason = {
|
995
1301
|
moduleIdentifier: reason.originModule
|
996
1302
|
? reason.originModule.identifier()
|
997
1303
|
: null,
|
@@ -1011,7 +1317,8 @@ const SIMPLE_EXTRACTORS = {
|
|
1011
1317
|
active: reason.isActive(runtime),
|
1012
1318
|
explanation: reason.explanation,
|
1013
1319
|
userRequest: (moduleDep && moduleDep.userRequest) || null
|
1014
|
-
}
|
1320
|
+
};
|
1321
|
+
Object.assign(object, statsModuleReason);
|
1015
1322
|
if (reason.dependency) {
|
1016
1323
|
const locInfo = formatLocation(reason.dependency.loc);
|
1017
1324
|
if (locInfo) {
|
@@ -1032,7 +1339,8 @@ const SIMPLE_EXTRACTORS = {
|
|
1032
1339
|
_: (object, chunk, { makePathsRelative, compilation: { chunkGraph } }) => {
|
1033
1340
|
const childIdByOrder = chunk.getChildIdsByOrders(chunkGraph);
|
1034
1341
|
|
1035
|
-
|
1342
|
+
/** @type {KnownStatsChunk} */
|
1343
|
+
const statsChunk = {
|
1036
1344
|
rendered: chunk.rendered,
|
1037
1345
|
initial: chunk.canBeInitial(),
|
1038
1346
|
entry: chunk.hasRuntime(),
|
@@ -1052,7 +1360,8 @@ const SIMPLE_EXTRACTORS = {
|
|
1052
1360
|
auxiliaryFiles: Array.from(chunk.auxiliaryFiles).sort(compareIds),
|
1053
1361
|
hash: chunk.renderedHash,
|
1054
1362
|
childrenByOrder: childIdByOrder
|
1055
|
-
}
|
1363
|
+
};
|
1364
|
+
Object.assign(object, statsChunk);
|
1056
1365
|
},
|
1057
1366
|
ids: (object, chunk) => {
|
1058
1367
|
object.id = chunk.id;
|
@@ -1125,7 +1434,8 @@ const SIMPLE_EXTRACTORS = {
|
|
1125
1434
|
},
|
1126
1435
|
chunkOrigin: {
|
1127
1436
|
_: (object, origin, context, { requestShortener }) => {
|
1128
|
-
|
1437
|
+
/** @type {KnownStatsChunkOrigin} */
|
1438
|
+
const statsChunkOrigin = {
|
1129
1439
|
module: origin.module ? origin.module.identifier() : "",
|
1130
1440
|
moduleIdentifier: origin.module ? origin.module.identifier() : "",
|
1131
1441
|
moduleName: origin.module
|
@@ -1133,7 +1443,8 @@ const SIMPLE_EXTRACTORS = {
|
|
1133
1443
|
: "",
|
1134
1444
|
loc: formatLocation(origin.loc),
|
1135
1445
|
request: origin.request
|
1136
|
-
}
|
1446
|
+
};
|
1447
|
+
Object.assign(object, statsChunkOrigin);
|
1137
1448
|
},
|
1138
1449
|
ids: (object, origin, { compilation: { chunkGraph } }) => {
|
1139
1450
|
object.moduleId = origin.module
|
@@ -1810,6 +2121,7 @@ const sortByField = field => {
|
|
1810
2121
|
};
|
1811
2122
|
|
1812
2123
|
const ASSET_SORTERS = {
|
2124
|
+
/** @type {(comparators: Function[], context: StatsFactoryContext, options: NormalizedStatsOptions) => void} */
|
1813
2125
|
assetsSort: (comparators, context, { assetsSort }) => {
|
1814
2126
|
comparators.push(sortByField(assetsSort));
|
1815
2127
|
},
|
@@ -121,6 +121,12 @@ const ON_FOR_TO_STRING = ({ all }, { forToString }) =>
|
|
121
121
|
forToString ? all !== false : all === true;
|
122
122
|
const OFF_FOR_TO_STRING = ({ all }, { forToString }) =>
|
123
123
|
forToString ? all === true : all !== false;
|
124
|
+
const AUTO_FOR_TO_STRING = ({ all }, { forToString }) => {
|
125
|
+
if (all === false) return false;
|
126
|
+
if (all === true) return true;
|
127
|
+
if (forToString) return "auto";
|
128
|
+
return true;
|
129
|
+
};
|
124
130
|
|
125
131
|
/** @type {Record<string, (options: StatsOptions, context: CreateStatsOptionsContext, compilation: Compilation) => any>} */
|
126
132
|
const DEFAULTS = {
|
@@ -136,12 +142,7 @@ const DEFAULTS = {
|
|
136
142
|
timings: NORMAL_ON,
|
137
143
|
builtAt: OFF_FOR_TO_STRING,
|
138
144
|
assets: NORMAL_ON,
|
139
|
-
entrypoints:
|
140
|
-
if (all === false) return false;
|
141
|
-
if (all === true) return true;
|
142
|
-
if (forToString) return "auto";
|
143
|
-
return true;
|
144
|
-
},
|
145
|
+
entrypoints: AUTO_FOR_TO_STRING,
|
145
146
|
chunkGroups: OFF_FOR_TO_STRING,
|
146
147
|
chunkGroupAuxiliary: OFF_FOR_TO_STRING,
|
147
148
|
chunkGroupChildren: OFF_FOR_TO_STRING,
|
@@ -201,7 +202,7 @@ const DEFAULTS = {
|
|
201
202
|
moduleTrace: NORMAL_ON,
|
202
203
|
errors: NORMAL_ON,
|
203
204
|
errorsCount: NORMAL_ON,
|
204
|
-
errorDetails:
|
205
|
+
errorDetails: AUTO_FOR_TO_STRING,
|
205
206
|
errorStack: OFF_FOR_TO_STRING,
|
206
207
|
warnings: NORMAL_ON,
|
207
208
|
warningsCount: NORMAL_ON,
|