webpack 4.1.0 → 4.4.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 +719 -721
- package/bin/webpack.js +69 -10
- package/lib/APIPlugin.js +84 -84
- package/lib/AmdMainTemplatePlugin.js +75 -77
- package/lib/AsyncDependencyToInitialChunkError.js +21 -23
- package/lib/BannerPlugin.js +101 -101
- package/lib/Chunk.js +477 -469
- package/lib/ChunkTemplate.js +51 -53
- package/lib/Compilation.js +1858 -1851
- package/lib/Compiler.js +493 -478
- package/lib/ConcurrentCompilationError.js +19 -0
- package/lib/ContextModule.js +696 -685
- package/lib/ContextModuleFactory.js +245 -243
- package/lib/DefinePlugin.js +197 -197
- package/lib/DelegatedModule.js +101 -101
- package/lib/DependenciesBlockVariable.js +51 -52
- package/lib/Dependency.js +53 -52
- package/lib/DllModule.js +54 -54
- package/lib/DllModuleFactory.js +29 -29
- package/lib/EnvironmentPlugin.js +65 -67
- package/lib/EvalDevToolModuleTemplatePlugin.js +60 -60
- package/lib/EvalSourceMapDevToolModuleTemplatePlugin.js +105 -105
- package/lib/ExportPropertyMainTemplatePlugin.js +40 -40
- package/lib/ExternalModule.js +159 -159
- package/lib/FunctionModuleTemplatePlugin.js +98 -98
- package/lib/HotModuleReplacement.runtime.js +631 -631
- package/lib/HotModuleReplacementPlugin.js +407 -406
- package/lib/HotUpdateChunkTemplate.js +78 -80
- package/lib/JavascriptGenerator.js +228 -229
- package/lib/JavascriptModulesPlugin.js +184 -158
- package/lib/JsonGenerator.js +42 -42
- package/lib/MainTemplate.js +406 -402
- package/lib/Module.js +343 -340
- package/lib/ModuleBuildError.js +42 -42
- package/lib/ModuleError.js +28 -28
- package/lib/ModuleFilenameHelpers.js +166 -166
- package/lib/ModuleTemplate.js +77 -79
- package/lib/ModuleWarning.js +30 -30
- package/lib/MultiCompiler.js +271 -259
- package/lib/MultiModule.js +78 -75
- package/lib/MultiModuleFactory.js +23 -23
- package/lib/MultiWatching.js +38 -37
- package/lib/NoModeWarning.js +23 -21
- package/lib/NormalModule.js +478 -470
- package/lib/NormalModuleFactory.js +483 -481
- package/lib/OptionsDefaulter.js +80 -86
- package/lib/Parser.js +2074 -2071
- package/lib/ProgressPlugin.js +231 -231
- package/lib/RawModule.js +54 -55
- package/lib/RecordIdsPlugin.js +160 -160
- package/lib/RemovedPluginError.js +13 -13
- package/lib/ResolverFactory.js +64 -67
- package/lib/RuntimeTemplate.js +267 -297
- package/lib/SetVarMainTemplatePlugin.js +57 -57
- package/lib/SourceMapDevToolPlugin.js +302 -308
- package/lib/Stats.js +1234 -1212
- package/lib/Template.js +205 -205
- package/lib/TemplatedPathPlugin.js +170 -143
- package/lib/UmdMainTemplatePlugin.js +264 -269
- package/lib/Watching.js +193 -193
- package/lib/WebAssemblyParser.js +50 -54
- package/lib/WebpackOptionsApply.js +401 -401
- package/lib/WebpackOptionsDefaulter.js +337 -317
- package/lib/WebpackOptionsValidationError.js +316 -319
- package/lib/debug/ProfilingPlugin.js +409 -405
- package/lib/dependencies/AMDDefineDependencyParserPlugin.js +328 -311
- package/lib/dependencies/AMDRequireContextDependency.js +20 -20
- package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +270 -241
- package/lib/dependencies/HarmonyAcceptImportDependency.js +23 -23
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +620 -606
- package/lib/dependencies/HarmonyExportSpecifierDependency.js +53 -53
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +214 -214
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +154 -156
- package/lib/dependencies/ImportDependenciesBlock.js +17 -17
- package/lib/dependencies/ImportDependency.js +34 -34
- package/lib/dependencies/ImportEagerDependency.js +32 -32
- package/lib/dependencies/ImportParserPlugin.js +175 -179
- package/lib/dependencies/ImportWeakDependency.js +34 -34
- package/lib/dependencies/JsonExportsDependency.js +25 -25
- package/lib/dependencies/ModuleDependency.js +20 -20
- package/lib/dependencies/NullDependency.js +20 -20
- package/lib/dependencies/RequireContextDependency.js +22 -22
- package/lib/dependencies/RequireIncludeDependency.js +40 -40
- package/lib/dependencies/WebpackMissingModule.js +20 -22
- package/lib/node/NodeChunkTemplatePlugin.js +31 -31
- package/lib/node/NodeHotUpdateChunkTemplatePlugin.js +36 -36
- package/lib/node/NodeMainTemplatePlugin.js +320 -273
- package/lib/node/ReadFileCompileWasmMainTemplatePlugin.js +113 -115
- package/lib/optimize/AggressiveSplittingPlugin.js +281 -281
- package/lib/optimize/ConcatenatedModule.js +1364 -1366
- package/lib/optimize/RemoveParentModulesPlugin.js +114 -114
- package/lib/optimize/SplitChunksPlugin.js +519 -491
- package/lib/performance/SizeLimitsPlugin.js +105 -105
- package/lib/util/TrackingSet.js +35 -35
- package/lib/util/objectToMap.js +10 -10
- package/lib/wasm/WasmModuleTemplatePlugin.js +106 -106
- package/lib/web/JsonpChunkTemplatePlugin.js +47 -47
- package/lib/web/JsonpExportMainTemplatePlugin.js +47 -47
- package/lib/web/JsonpHotUpdateChunkTemplatePlugin.js +39 -39
- package/lib/web/JsonpMainTemplatePlugin.js +425 -403
- package/lib/webpack.js +182 -179
- package/lib/webworker/WebWorkerChunkTemplatePlugin.js +35 -35
- package/lib/webworker/WebWorkerHotUpdateChunkTemplatePlugin.js +40 -40
- package/lib/webworker/WebWorkerMainTemplatePlugin.js +177 -154
- package/package.json +9 -8
- package/schemas/WebpackOptions.json +1973 -1951
- package/schemas/ajv.absolutePath.js +55 -29
- package/schemas/plugins/BannerPlugin.json +85 -85
- package/schemas/plugins/DllPlugin.json +28 -28
- package/schemas/plugins/DllReferencePlugin.json +99 -99
- package/schemas/plugins/HashedModuleIdsPlugin.json +24 -24
- package/schemas/plugins/LoaderOptionsPlugin.json +26 -26
- package/schemas/plugins/SourceMapDevToolPlugin.json +187 -187
- package/schemas/plugins/WatchIgnorePlugin.json +16 -16
- package/schemas/plugins/debug/ProfilingPlugin.json +12 -12
- package/schemas/plugins/optimize/AggressiveSplittingPlugin.json +22 -22
- package/schemas/plugins/optimize/LimitChunkCountPlugin.json +15 -15
- package/schemas/plugins/optimize/MinChunkSizePlugin.json +13 -13
package/lib/Stats.js
CHANGED
@@ -1,1212 +1,1234 @@
|
|
1
|
-
/*
|
2
|
-
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
-
Author Tobias Koppers @sokra
|
4
|
-
*/
|
5
|
-
"use strict";
|
6
|
-
|
7
|
-
const RequestShortener = require("./RequestShortener");
|
8
|
-
const SizeFormatHelpers = require("./SizeFormatHelpers");
|
9
|
-
const formatLocation = require("./formatLocation");
|
10
|
-
const identifierUtils = require("./util/identifier");
|
11
|
-
|
12
|
-
const optionsOrFallback = (...args) => {
|
13
|
-
let optionValues = [];
|
14
|
-
optionValues.push(...args);
|
15
|
-
return optionValues.find(optionValue => typeof optionValue !== "undefined");
|
16
|
-
};
|
17
|
-
|
18
|
-
class Stats {
|
19
|
-
constructor(compilation) {
|
20
|
-
this.compilation = compilation;
|
21
|
-
this.hash = compilation.hash;
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
options =
|
89
|
-
}
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
if (typeof item === "
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
compilation.compiler.context
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
const
|
124
|
-
const
|
125
|
-
const
|
126
|
-
const
|
127
|
-
const
|
128
|
-
const
|
129
|
-
const
|
130
|
-
const
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
const
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
);
|
147
|
-
const
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
const
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
);
|
163
|
-
const
|
164
|
-
const
|
165
|
-
const
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
const
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
const
|
180
|
-
|
181
|
-
|
182
|
-
const
|
183
|
-
options.
|
184
|
-
|
185
|
-
);
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
if (
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
if (e.
|
255
|
-
text +=
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
) {
|
262
|
-
text += `${e.
|
263
|
-
}
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
text +=
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
}
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
if (
|
332
|
-
obj.
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
}
|
474
|
-
if (
|
475
|
-
obj.
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
}
|
483
|
-
if (
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
}
|
543
|
-
if (
|
544
|
-
obj.
|
545
|
-
.
|
546
|
-
.
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
typeof
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
obj.
|
592
|
-
}
|
593
|
-
if (
|
594
|
-
obj.
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
const
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
|
667
|
-
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
|
686
|
-
|
687
|
-
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
for (let
|
692
|
-
|
693
|
-
|
694
|
-
const value = `${getText(array, row, col)}`;
|
695
|
-
|
696
|
-
|
697
|
-
|
698
|
-
|
699
|
-
|
700
|
-
|
701
|
-
|
702
|
-
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
|
713
|
-
|
714
|
-
|
715
|
-
|
716
|
-
|
717
|
-
|
718
|
-
|
719
|
-
|
720
|
-
|
721
|
-
|
722
|
-
|
723
|
-
|
724
|
-
|
725
|
-
colors.
|
726
|
-
|
727
|
-
|
728
|
-
|
729
|
-
|
730
|
-
|
731
|
-
|
732
|
-
|
733
|
-
|
734
|
-
colors.normal(" ");
|
735
|
-
colors.bold(
|
736
|
-
|
737
|
-
|
738
|
-
|
739
|
-
|
740
|
-
|
741
|
-
|
742
|
-
|
743
|
-
|
744
|
-
|
745
|
-
|
746
|
-
|
747
|
-
|
748
|
-
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
|
753
|
-
|
754
|
-
|
755
|
-
|
756
|
-
|
757
|
-
|
758
|
-
|
759
|
-
|
760
|
-
|
761
|
-
|
762
|
-
|
763
|
-
|
764
|
-
|
765
|
-
|
766
|
-
|
767
|
-
|
768
|
-
|
769
|
-
|
770
|
-
|
771
|
-
|
772
|
-
|
773
|
-
|
774
|
-
|
775
|
-
|
776
|
-
|
777
|
-
|
778
|
-
|
779
|
-
|
780
|
-
|
781
|
-
|
782
|
-
|
783
|
-
|
784
|
-
|
785
|
-
|
786
|
-
|
787
|
-
|
788
|
-
|
789
|
-
|
790
|
-
|
791
|
-
|
792
|
-
|
793
|
-
|
794
|
-
|
795
|
-
|
796
|
-
|
797
|
-
|
798
|
-
|
799
|
-
|
800
|
-
|
801
|
-
|
802
|
-
|
803
|
-
|
804
|
-
|
805
|
-
|
806
|
-
|
807
|
-
|
808
|
-
|
809
|
-
|
810
|
-
|
811
|
-
|
812
|
-
|
813
|
-
|
814
|
-
|
815
|
-
|
816
|
-
|
817
|
-
|
818
|
-
|
819
|
-
|
820
|
-
|
821
|
-
|
822
|
-
|
823
|
-
|
824
|
-
|
825
|
-
|
826
|
-
|
827
|
-
|
828
|
-
|
829
|
-
|
830
|
-
|
831
|
-
|
832
|
-
|
833
|
-
|
834
|
-
|
835
|
-
|
836
|
-
|
837
|
-
|
838
|
-
|
839
|
-
|
840
|
-
|
841
|
-
|
842
|
-
|
843
|
-
|
844
|
-
}
|
845
|
-
|
846
|
-
|
847
|
-
|
848
|
-
const
|
849
|
-
|
850
|
-
|
851
|
-
|
852
|
-
|
853
|
-
|
854
|
-
|
855
|
-
|
856
|
-
|
857
|
-
|
858
|
-
|
859
|
-
|
860
|
-
}
|
861
|
-
|
862
|
-
|
863
|
-
|
864
|
-
|
865
|
-
|
866
|
-
|
867
|
-
|
868
|
-
|
869
|
-
|
870
|
-
|
871
|
-
|
872
|
-
}
|
873
|
-
if (module.
|
874
|
-
|
875
|
-
|
876
|
-
|
877
|
-
);
|
878
|
-
|
879
|
-
|
880
|
-
|
881
|
-
|
882
|
-
|
883
|
-
|
884
|
-
|
885
|
-
if (
|
886
|
-
colors.
|
887
|
-
|
888
|
-
|
889
|
-
|
890
|
-
|
891
|
-
|
892
|
-
|
893
|
-
|
894
|
-
|
895
|
-
|
896
|
-
|
897
|
-
|
898
|
-
|
899
|
-
|
900
|
-
|
901
|
-
|
902
|
-
|
903
|
-
|
904
|
-
|
905
|
-
|
906
|
-
|
907
|
-
|
908
|
-
|
909
|
-
|
910
|
-
|
911
|
-
|
912
|
-
|
913
|
-
|
914
|
-
|
915
|
-
|
916
|
-
|
917
|
-
|
918
|
-
|
919
|
-
|
920
|
-
if (
|
921
|
-
|
922
|
-
|
923
|
-
|
924
|
-
|
925
|
-
|
926
|
-
colors.
|
927
|
-
|
928
|
-
|
929
|
-
|
930
|
-
|
931
|
-
|
932
|
-
|
933
|
-
|
934
|
-
|
935
|
-
|
936
|
-
|
937
|
-
|
938
|
-
|
939
|
-
|
940
|
-
|
941
|
-
|
942
|
-
|
943
|
-
|
944
|
-
|
945
|
-
|
946
|
-
|
947
|
-
|
948
|
-
|
949
|
-
|
950
|
-
|
951
|
-
colors.normal("
|
952
|
-
|
953
|
-
|
954
|
-
|
955
|
-
|
956
|
-
|
957
|
-
|
958
|
-
|
959
|
-
|
960
|
-
|
961
|
-
|
962
|
-
|
963
|
-
|
964
|
-
|
965
|
-
|
966
|
-
|
967
|
-
|
968
|
-
|
969
|
-
|
970
|
-
|
971
|
-
|
972
|
-
|
973
|
-
|
974
|
-
|
975
|
-
|
976
|
-
|
977
|
-
|
978
|
-
|
979
|
-
|
980
|
-
|
981
|
-
|
982
|
-
|
983
|
-
|
984
|
-
|
985
|
-
|
986
|
-
|
987
|
-
|
988
|
-
|
989
|
-
|
990
|
-
|
991
|
-
|
992
|
-
|
993
|
-
|
994
|
-
|
995
|
-
|
996
|
-
|
997
|
-
|
998
|
-
|
999
|
-
|
1000
|
-
|
1001
|
-
|
1002
|
-
colors.normal(
|
1003
|
-
|
1004
|
-
|
1005
|
-
if (
|
1006
|
-
|
1007
|
-
|
1008
|
-
|
1009
|
-
|
1010
|
-
|
1011
|
-
|
1012
|
-
|
1013
|
-
|
1014
|
-
|
1015
|
-
|
1016
|
-
|
1017
|
-
|
1018
|
-
|
1019
|
-
|
1020
|
-
|
1021
|
-
|
1022
|
-
if (
|
1023
|
-
colors.normal(
|
1024
|
-
colors.normal(
|
1025
|
-
colors.normal("
|
1026
|
-
|
1027
|
-
|
1028
|
-
|
1029
|
-
|
1030
|
-
|
1031
|
-
|
1032
|
-
|
1033
|
-
|
1034
|
-
|
1035
|
-
|
1036
|
-
|
1037
|
-
|
1038
|
-
|
1039
|
-
|
1040
|
-
|
1041
|
-
|
1042
|
-
|
1043
|
-
|
1044
|
-
if (chunk.
|
1045
|
-
colors.
|
1046
|
-
|
1047
|
-
colors.
|
1048
|
-
}
|
1049
|
-
|
1050
|
-
|
1051
|
-
|
1052
|
-
|
1053
|
-
colors.
|
1054
|
-
|
1055
|
-
|
1056
|
-
|
1057
|
-
|
1058
|
-
|
1059
|
-
|
1060
|
-
|
1061
|
-
|
1062
|
-
|
1063
|
-
|
1064
|
-
|
1065
|
-
|
1066
|
-
|
1067
|
-
|
1068
|
-
|
1069
|
-
|
1070
|
-
|
1071
|
-
|
1072
|
-
|
1073
|
-
|
1074
|
-
|
1075
|
-
|
1076
|
-
|
1077
|
-
|
1078
|
-
|
1079
|
-
|
1080
|
-
|
1081
|
-
|
1082
|
-
|
1083
|
-
|
1084
|
-
|
1085
|
-
|
1086
|
-
|
1087
|
-
|
1088
|
-
|
1089
|
-
|
1090
|
-
|
1091
|
-
|
1092
|
-
|
1093
|
-
|
1094
|
-
|
1095
|
-
|
1096
|
-
|
1097
|
-
|
1098
|
-
|
1099
|
-
|
1100
|
-
|
1101
|
-
|
1102
|
-
|
1103
|
-
|
1104
|
-
|
1105
|
-
|
1106
|
-
|
1107
|
-
|
1108
|
-
|
1109
|
-
|
1110
|
-
|
1111
|
-
|
1112
|
-
|
1113
|
-
|
1114
|
-
|
1115
|
-
|
1116
|
-
|
1117
|
-
|
1118
|
-
|
1119
|
-
|
1120
|
-
|
1121
|
-
|
1122
|
-
|
1123
|
-
|
1124
|
-
|
1125
|
-
|
1126
|
-
|
1127
|
-
|
1128
|
-
|
1129
|
-
|
1130
|
-
|
1131
|
-
|
1132
|
-
|
1133
|
-
|
1134
|
-
|
1135
|
-
|
1136
|
-
|
1137
|
-
|
1138
|
-
|
1139
|
-
|
1140
|
-
|
1141
|
-
|
1142
|
-
|
1143
|
-
}
|
1144
|
-
|
1145
|
-
|
1146
|
-
|
1147
|
-
|
1148
|
-
|
1149
|
-
|
1150
|
-
|
1151
|
-
|
1152
|
-
|
1153
|
-
|
1154
|
-
|
1155
|
-
|
1156
|
-
|
1157
|
-
|
1158
|
-
|
1159
|
-
|
1160
|
-
|
1161
|
-
|
1162
|
-
case "
|
1163
|
-
return {
|
1164
|
-
|
1165
|
-
|
1166
|
-
|
1167
|
-
|
1168
|
-
|
1169
|
-
|
1170
|
-
|
1171
|
-
|
1172
|
-
|
1173
|
-
|
1174
|
-
|
1175
|
-
|
1176
|
-
|
1177
|
-
|
1178
|
-
|
1179
|
-
|
1180
|
-
|
1181
|
-
|
1182
|
-
|
1183
|
-
|
1184
|
-
|
1185
|
-
|
1186
|
-
|
1187
|
-
|
1188
|
-
|
1189
|
-
|
1190
|
-
|
1191
|
-
|
1192
|
-
|
1193
|
-
|
1194
|
-
|
1195
|
-
|
1196
|
-
|
1197
|
-
|
1198
|
-
|
1199
|
-
|
1200
|
-
|
1201
|
-
|
1202
|
-
|
1203
|
-
|
1204
|
-
|
1205
|
-
|
1206
|
-
|
1207
|
-
|
1208
|
-
|
1209
|
-
|
1210
|
-
|
1211
|
-
|
1212
|
-
|
1
|
+
/*
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
+
Author Tobias Koppers @sokra
|
4
|
+
*/
|
5
|
+
"use strict";
|
6
|
+
|
7
|
+
const RequestShortener = require("./RequestShortener");
|
8
|
+
const SizeFormatHelpers = require("./SizeFormatHelpers");
|
9
|
+
const formatLocation = require("./formatLocation");
|
10
|
+
const identifierUtils = require("./util/identifier");
|
11
|
+
|
12
|
+
const optionsOrFallback = (...args) => {
|
13
|
+
let optionValues = [];
|
14
|
+
optionValues.push(...args);
|
15
|
+
return optionValues.find(optionValue => typeof optionValue !== "undefined");
|
16
|
+
};
|
17
|
+
|
18
|
+
class Stats {
|
19
|
+
constructor(compilation) {
|
20
|
+
this.compilation = compilation;
|
21
|
+
this.hash = compilation.hash;
|
22
|
+
this.startTime = undefined;
|
23
|
+
this.endTime = undefined;
|
24
|
+
}
|
25
|
+
|
26
|
+
static filterWarnings(warnings, warningsFilter) {
|
27
|
+
// we dont have anything to filter so all warnings can be shown
|
28
|
+
if (!warningsFilter) {
|
29
|
+
return warnings;
|
30
|
+
}
|
31
|
+
|
32
|
+
// create a chain of filters
|
33
|
+
// if they return "true" a warning should be suppressed
|
34
|
+
const normalizedWarningsFilters = [].concat(warningsFilter).map(filter => {
|
35
|
+
if (typeof filter === "string") {
|
36
|
+
return warning => warning.includes(filter);
|
37
|
+
}
|
38
|
+
|
39
|
+
if (filter instanceof RegExp) {
|
40
|
+
return warning => filter.test(warning);
|
41
|
+
}
|
42
|
+
|
43
|
+
if (typeof filter === "function") {
|
44
|
+
return filter;
|
45
|
+
}
|
46
|
+
|
47
|
+
throw new Error(
|
48
|
+
`Can only filter warnings with Strings or RegExps. (Given: ${filter})`
|
49
|
+
);
|
50
|
+
});
|
51
|
+
return warnings.filter(warning => {
|
52
|
+
return !normalizedWarningsFilters.some(check => check(warning));
|
53
|
+
});
|
54
|
+
}
|
55
|
+
|
56
|
+
hasWarnings() {
|
57
|
+
return (
|
58
|
+
this.compilation.warnings.length > 0 ||
|
59
|
+
this.compilation.children.some(child => child.getStats().hasWarnings())
|
60
|
+
);
|
61
|
+
}
|
62
|
+
|
63
|
+
hasErrors() {
|
64
|
+
return (
|
65
|
+
this.compilation.errors.length > 0 ||
|
66
|
+
this.compilation.children.some(child => child.getStats().hasErrors())
|
67
|
+
);
|
68
|
+
}
|
69
|
+
|
70
|
+
// remove a prefixed "!" that can be specified to reverse sort order
|
71
|
+
normalizeFieldKey(field) {
|
72
|
+
if (field[0] === "!") {
|
73
|
+
return field.substr(1);
|
74
|
+
}
|
75
|
+
return field;
|
76
|
+
}
|
77
|
+
|
78
|
+
// if a field is prefixed by a "!" reverse sort order
|
79
|
+
sortOrderRegular(field) {
|
80
|
+
if (field[0] === "!") {
|
81
|
+
return false;
|
82
|
+
}
|
83
|
+
return true;
|
84
|
+
}
|
85
|
+
|
86
|
+
toJson(options, forToString) {
|
87
|
+
if (typeof options === "boolean" || typeof options === "string") {
|
88
|
+
options = Stats.presetToOptions(options);
|
89
|
+
} else if (!options) {
|
90
|
+
options = {};
|
91
|
+
}
|
92
|
+
|
93
|
+
const optionOrLocalFallback = (v, def) =>
|
94
|
+
typeof v !== "undefined"
|
95
|
+
? v
|
96
|
+
: typeof options.all !== "undefined" ? options.all : def;
|
97
|
+
|
98
|
+
const testAgainstGivenOption = item => {
|
99
|
+
if (typeof item === "string") {
|
100
|
+
const regExp = new RegExp(
|
101
|
+
`[\\\\/]${item.replace(
|
102
|
+
/[-[\]{}()*+?.\\^$|]/g,
|
103
|
+
"\\$&"
|
104
|
+
)}([\\\\/]|$|!|\\?)`
|
105
|
+
); // eslint-disable-line no-useless-escape
|
106
|
+
return ident => regExp.test(ident);
|
107
|
+
}
|
108
|
+
if (item && typeof item === "object" && typeof item.test === "function")
|
109
|
+
return ident => item.test(ident);
|
110
|
+
if (typeof item === "function") return item;
|
111
|
+
if (typeof item === "boolean") return () => item;
|
112
|
+
};
|
113
|
+
|
114
|
+
const compilation = this.compilation;
|
115
|
+
const context = optionsOrFallback(
|
116
|
+
options.context,
|
117
|
+
compilation.compiler.context
|
118
|
+
);
|
119
|
+
const requestShortener =
|
120
|
+
compilation.compiler.context === context
|
121
|
+
? compilation.requestShortener
|
122
|
+
: new RequestShortener(context);
|
123
|
+
const showPerformance = optionOrLocalFallback(options.performance, true);
|
124
|
+
const showHash = optionOrLocalFallback(options.hash, true);
|
125
|
+
const showEnv = optionOrLocalFallback(options.env, false);
|
126
|
+
const showVersion = optionOrLocalFallback(options.version, true);
|
127
|
+
const showTimings = optionOrLocalFallback(options.timings, true);
|
128
|
+
const showBuiltAt = optionOrLocalFallback(options.builtAt, true);
|
129
|
+
const showAssets = optionOrLocalFallback(options.assets, true);
|
130
|
+
const showEntrypoints = optionOrLocalFallback(options.entrypoints, true);
|
131
|
+
const showChunks = optionOrLocalFallback(options.chunks, !forToString);
|
132
|
+
const showChunkModules = optionOrLocalFallback(options.chunkModules, true);
|
133
|
+
const showChunkOrigins = optionOrLocalFallback(
|
134
|
+
options.chunkOrigins,
|
135
|
+
!forToString
|
136
|
+
);
|
137
|
+
const showModules = optionOrLocalFallback(options.modules, true);
|
138
|
+
const showNestedModules = optionOrLocalFallback(
|
139
|
+
options.nestedModules,
|
140
|
+
true
|
141
|
+
);
|
142
|
+
const showModuleAssets = optionOrLocalFallback(
|
143
|
+
options.moduleAssets,
|
144
|
+
!forToString
|
145
|
+
);
|
146
|
+
const showDepth = optionOrLocalFallback(options.depth, !forToString);
|
147
|
+
const showCachedModules = optionOrLocalFallback(options.cached, true);
|
148
|
+
const showCachedAssets = optionOrLocalFallback(options.cachedAssets, true);
|
149
|
+
const showReasons = optionOrLocalFallback(options.reasons, !forToString);
|
150
|
+
const showUsedExports = optionOrLocalFallback(
|
151
|
+
options.usedExports,
|
152
|
+
!forToString
|
153
|
+
);
|
154
|
+
const showProvidedExports = optionOrLocalFallback(
|
155
|
+
options.providedExports,
|
156
|
+
!forToString
|
157
|
+
);
|
158
|
+
const showOptimizationBailout = optionOrLocalFallback(
|
159
|
+
options.optimizationBailout,
|
160
|
+
!forToString
|
161
|
+
);
|
162
|
+
const showChildren = optionOrLocalFallback(options.children, true);
|
163
|
+
const showSource = optionOrLocalFallback(options.source, !forToString);
|
164
|
+
const showModuleTrace = optionOrLocalFallback(options.moduleTrace, true);
|
165
|
+
const showErrors = optionOrLocalFallback(options.errors, true);
|
166
|
+
const showErrorDetails = optionOrLocalFallback(
|
167
|
+
options.errorDetails,
|
168
|
+
!forToString
|
169
|
+
);
|
170
|
+
const showWarnings = optionOrLocalFallback(options.warnings, true);
|
171
|
+
const warningsFilter = optionsOrFallback(options.warningsFilter, null);
|
172
|
+
const showPublicPath = optionOrLocalFallback(
|
173
|
+
options.publicPath,
|
174
|
+
!forToString
|
175
|
+
);
|
176
|
+
const excludeModules = []
|
177
|
+
.concat(optionsOrFallback(options.excludeModules, options.exclude, []))
|
178
|
+
.map(testAgainstGivenOption);
|
179
|
+
const excludeAssets = []
|
180
|
+
.concat(optionsOrFallback(options.excludeAssets, []))
|
181
|
+
.map(testAgainstGivenOption);
|
182
|
+
const maxModules = optionsOrFallback(
|
183
|
+
options.maxModules,
|
184
|
+
forToString ? 15 : Infinity
|
185
|
+
);
|
186
|
+
const sortModules = optionsOrFallback(options.modulesSort, "id");
|
187
|
+
const sortChunks = optionsOrFallback(options.chunksSort, "id");
|
188
|
+
const sortAssets = optionsOrFallback(options.assetsSort, "");
|
189
|
+
const showOutputPath = optionOrLocalFallback(
|
190
|
+
options.outputPath,
|
191
|
+
!forToString
|
192
|
+
);
|
193
|
+
|
194
|
+
if (!showCachedModules) {
|
195
|
+
excludeModules.push((ident, module) => !module.built);
|
196
|
+
}
|
197
|
+
|
198
|
+
const createModuleFilter = () => {
|
199
|
+
let i = 0;
|
200
|
+
return module => {
|
201
|
+
if (excludeModules.length > 0) {
|
202
|
+
const ident = requestShortener.shorten(module.resource);
|
203
|
+
const excluded = excludeModules.some(fn => fn(ident, module));
|
204
|
+
if (excluded) return false;
|
205
|
+
}
|
206
|
+
const result = i < maxModules;
|
207
|
+
i++;
|
208
|
+
return result;
|
209
|
+
};
|
210
|
+
};
|
211
|
+
|
212
|
+
const createAssetFilter = () => {
|
213
|
+
return asset => {
|
214
|
+
if (excludeAssets.length > 0) {
|
215
|
+
const ident = asset.name;
|
216
|
+
const excluded = excludeAssets.some(fn => fn(ident, asset));
|
217
|
+
if (excluded) return false;
|
218
|
+
}
|
219
|
+
return showCachedAssets || asset.emitted;
|
220
|
+
};
|
221
|
+
};
|
222
|
+
|
223
|
+
const sortByFieldAndOrder = (fieldKey, a, b) => {
|
224
|
+
if (a[fieldKey] === null && b[fieldKey] === null) return 0;
|
225
|
+
if (a[fieldKey] === null) return 1;
|
226
|
+
if (b[fieldKey] === null) return -1;
|
227
|
+
if (a[fieldKey] === b[fieldKey]) return 0;
|
228
|
+
return a[fieldKey] < b[fieldKey] ? -1 : 1;
|
229
|
+
};
|
230
|
+
|
231
|
+
const sortByField = field => (a, b) => {
|
232
|
+
if (!field) {
|
233
|
+
return 0;
|
234
|
+
}
|
235
|
+
|
236
|
+
const fieldKey = this.normalizeFieldKey(field);
|
237
|
+
|
238
|
+
// if a field is prefixed with a "!" the sort is reversed!
|
239
|
+
const sortIsRegular = this.sortOrderRegular(field);
|
240
|
+
|
241
|
+
return sortByFieldAndOrder(
|
242
|
+
fieldKey,
|
243
|
+
sortIsRegular ? a : b,
|
244
|
+
sortIsRegular ? b : a
|
245
|
+
);
|
246
|
+
};
|
247
|
+
|
248
|
+
const formatError = e => {
|
249
|
+
let text = "";
|
250
|
+
if (typeof e === "string")
|
251
|
+
e = {
|
252
|
+
message: e
|
253
|
+
};
|
254
|
+
if (e.chunk) {
|
255
|
+
text += `chunk ${e.chunk.name || e.chunk.id}${
|
256
|
+
e.chunk.hasRuntime()
|
257
|
+
? " [entry]"
|
258
|
+
: e.chunk.canBeInitial() ? " [initial]" : ""
|
259
|
+
}\n`;
|
260
|
+
}
|
261
|
+
if (e.file) {
|
262
|
+
text += `${e.file}\n`;
|
263
|
+
}
|
264
|
+
if (
|
265
|
+
e.module &&
|
266
|
+
e.module.readableIdentifier &&
|
267
|
+
typeof e.module.readableIdentifier === "function"
|
268
|
+
) {
|
269
|
+
text += `${e.module.readableIdentifier(requestShortener)}\n`;
|
270
|
+
}
|
271
|
+
text += e.message;
|
272
|
+
if (showErrorDetails && e.details) text += `\n${e.details}`;
|
273
|
+
if (showErrorDetails && e.missing)
|
274
|
+
text += e.missing.map(item => `\n[${item}]`).join("");
|
275
|
+
if (showModuleTrace && e.origin) {
|
276
|
+
text += `\n @ ${e.origin.readableIdentifier(requestShortener)}`;
|
277
|
+
if (typeof e.originLoc === "object") {
|
278
|
+
const locInfo = formatLocation(e.originLoc);
|
279
|
+
if (locInfo) text += ` ${locInfo}`;
|
280
|
+
}
|
281
|
+
if (e.dependencies) {
|
282
|
+
for (const dep of e.dependencies) {
|
283
|
+
if (!dep.loc) continue;
|
284
|
+
if (typeof dep.loc === "string") continue;
|
285
|
+
const locInfo = formatLocation(dep.loc);
|
286
|
+
if (!locInfo) continue;
|
287
|
+
text += ` ${locInfo}`;
|
288
|
+
}
|
289
|
+
}
|
290
|
+
let current = e.origin;
|
291
|
+
while (current.issuer) {
|
292
|
+
current = current.issuer;
|
293
|
+
text += `\n @ ${current.readableIdentifier(requestShortener)}`;
|
294
|
+
}
|
295
|
+
}
|
296
|
+
return text;
|
297
|
+
};
|
298
|
+
|
299
|
+
const obj = {
|
300
|
+
errors: compilation.errors.map(formatError),
|
301
|
+
warnings: Stats.filterWarnings(
|
302
|
+
compilation.warnings.map(formatError),
|
303
|
+
warningsFilter
|
304
|
+
)
|
305
|
+
};
|
306
|
+
|
307
|
+
//We just hint other renderers since actually omitting
|
308
|
+
//errors/warnings from the JSON would be kind of weird.
|
309
|
+
Object.defineProperty(obj, "_showWarnings", {
|
310
|
+
value: showWarnings,
|
311
|
+
enumerable: false
|
312
|
+
});
|
313
|
+
Object.defineProperty(obj, "_showErrors", {
|
314
|
+
value: showErrors,
|
315
|
+
enumerable: false
|
316
|
+
});
|
317
|
+
|
318
|
+
if (showVersion) {
|
319
|
+
obj.version = require("../package.json").version;
|
320
|
+
}
|
321
|
+
|
322
|
+
if (showHash) obj.hash = this.hash;
|
323
|
+
if (showTimings && this.startTime && this.endTime) {
|
324
|
+
obj.time = this.endTime - this.startTime;
|
325
|
+
}
|
326
|
+
|
327
|
+
if (showBuiltAt && this.endTime) {
|
328
|
+
obj.builtAt = this.endTime;
|
329
|
+
}
|
330
|
+
|
331
|
+
if (showEnv && options._env) {
|
332
|
+
obj.env = options._env;
|
333
|
+
}
|
334
|
+
|
335
|
+
if (compilation.needAdditionalPass) {
|
336
|
+
obj.needAdditionalPass = true;
|
337
|
+
}
|
338
|
+
if (showPublicPath) {
|
339
|
+
obj.publicPath = this.compilation.mainTemplate.getPublicPath({
|
340
|
+
hash: this.compilation.hash
|
341
|
+
});
|
342
|
+
}
|
343
|
+
if (showOutputPath) {
|
344
|
+
obj.outputPath = this.compilation.mainTemplate.outputOptions.path;
|
345
|
+
}
|
346
|
+
if (showAssets) {
|
347
|
+
const assetsByFile = {};
|
348
|
+
const compilationAssets = Object.keys(compilation.assets);
|
349
|
+
obj.assetsByChunkName = {};
|
350
|
+
obj.assets = compilationAssets
|
351
|
+
.map(asset => {
|
352
|
+
const obj = {
|
353
|
+
name: asset,
|
354
|
+
size: compilation.assets[asset].size(),
|
355
|
+
chunks: [],
|
356
|
+
chunkNames: [],
|
357
|
+
emitted: compilation.assets[asset].emitted
|
358
|
+
};
|
359
|
+
|
360
|
+
if (showPerformance) {
|
361
|
+
obj.isOverSizeLimit = compilation.assets[asset].isOverSizeLimit;
|
362
|
+
}
|
363
|
+
|
364
|
+
assetsByFile[asset] = obj;
|
365
|
+
return obj;
|
366
|
+
})
|
367
|
+
.filter(createAssetFilter());
|
368
|
+
obj.filteredAssets = compilationAssets.length - obj.assets.length;
|
369
|
+
|
370
|
+
for (const chunk of compilation.chunks) {
|
371
|
+
for (const asset of chunk.files) {
|
372
|
+
if (assetsByFile[asset]) {
|
373
|
+
for (const id of chunk.ids) {
|
374
|
+
assetsByFile[asset].chunks.push(id);
|
375
|
+
}
|
376
|
+
if (chunk.name) {
|
377
|
+
assetsByFile[asset].chunkNames.push(chunk.name);
|
378
|
+
if (obj.assetsByChunkName[chunk.name])
|
379
|
+
obj.assetsByChunkName[chunk.name] = []
|
380
|
+
.concat(obj.assetsByChunkName[chunk.name])
|
381
|
+
.concat([asset]);
|
382
|
+
else obj.assetsByChunkName[chunk.name] = asset;
|
383
|
+
}
|
384
|
+
}
|
385
|
+
}
|
386
|
+
}
|
387
|
+
obj.assets.sort(sortByField(sortAssets));
|
388
|
+
}
|
389
|
+
|
390
|
+
if (showEntrypoints) {
|
391
|
+
obj.entrypoints = {};
|
392
|
+
for (const keyValuePair of compilation.entrypoints) {
|
393
|
+
const name = keyValuePair[0];
|
394
|
+
const ep = keyValuePair[1];
|
395
|
+
obj.entrypoints[name] = {
|
396
|
+
chunks: ep.chunks.map(c => c.id),
|
397
|
+
assets: ep.chunks.reduce(
|
398
|
+
(array, c) => array.concat(c.files || []),
|
399
|
+
[]
|
400
|
+
)
|
401
|
+
};
|
402
|
+
if (showPerformance) {
|
403
|
+
obj.entrypoints[name].isOverSizeLimit = ep.isOverSizeLimit;
|
404
|
+
}
|
405
|
+
}
|
406
|
+
}
|
407
|
+
|
408
|
+
const fnModule = module => {
|
409
|
+
const path = [];
|
410
|
+
let current = module;
|
411
|
+
while (current.issuer) {
|
412
|
+
path.push((current = current.issuer));
|
413
|
+
}
|
414
|
+
path.reverse();
|
415
|
+
const obj = {
|
416
|
+
id: module.id,
|
417
|
+
identifier: module.identifier(),
|
418
|
+
name: module.readableIdentifier(requestShortener),
|
419
|
+
index: module.index,
|
420
|
+
index2: module.index2,
|
421
|
+
size: module.size(),
|
422
|
+
cacheable: module.buildInfo.cacheable,
|
423
|
+
built: !!module.built,
|
424
|
+
optional: module.optional,
|
425
|
+
prefetched: module.prefetched,
|
426
|
+
chunks: Array.from(module.chunksIterable, chunk => chunk.id),
|
427
|
+
issuer: module.issuer && module.issuer.identifier(),
|
428
|
+
issuerId: module.issuer && module.issuer.id,
|
429
|
+
issuerName:
|
430
|
+
module.issuer && module.issuer.readableIdentifier(requestShortener),
|
431
|
+
issuerPath:
|
432
|
+
module.issuer &&
|
433
|
+
path.map(module => ({
|
434
|
+
id: module.id,
|
435
|
+
identifier: module.identifier(),
|
436
|
+
name: module.readableIdentifier(requestShortener),
|
437
|
+
profile: module.profile
|
438
|
+
})),
|
439
|
+
profile: module.profile,
|
440
|
+
failed: !!module.error,
|
441
|
+
errors: module.errors ? module.errors.length : 0,
|
442
|
+
warnings: module.warnings ? module.warnings.length : 0
|
443
|
+
};
|
444
|
+
if (showModuleAssets) {
|
445
|
+
obj.assets = Object.keys(module.buildInfo.assets || {});
|
446
|
+
}
|
447
|
+
if (showReasons) {
|
448
|
+
obj.reasons = module.reasons
|
449
|
+
.map(reason => {
|
450
|
+
const obj = {
|
451
|
+
moduleId: reason.module ? reason.module.id : null,
|
452
|
+
moduleIdentifier: reason.module
|
453
|
+
? reason.module.identifier()
|
454
|
+
: null,
|
455
|
+
module: reason.module
|
456
|
+
? reason.module.readableIdentifier(requestShortener)
|
457
|
+
: null,
|
458
|
+
moduleName: reason.module
|
459
|
+
? reason.module.readableIdentifier(requestShortener)
|
460
|
+
: null,
|
461
|
+
type: reason.dependency ? reason.dependency.type : null,
|
462
|
+
userRequest: reason.dependency
|
463
|
+
? reason.dependency.userRequest
|
464
|
+
: null
|
465
|
+
};
|
466
|
+
if (reason.dependency) {
|
467
|
+
const locInfo = formatLocation(reason.dependency.loc);
|
468
|
+
if (locInfo) obj.loc = locInfo;
|
469
|
+
}
|
470
|
+
return obj;
|
471
|
+
})
|
472
|
+
.sort((a, b) => a.moduleId - b.moduleId);
|
473
|
+
}
|
474
|
+
if (showUsedExports) {
|
475
|
+
if (module.used === true) obj.usedExports = module.usedExports;
|
476
|
+
else if (module.used === false) obj.usedExports = false;
|
477
|
+
}
|
478
|
+
if (showProvidedExports) {
|
479
|
+
obj.providedExports = Array.isArray(module.buildMeta.providedExports)
|
480
|
+
? module.buildMeta.providedExports
|
481
|
+
: null;
|
482
|
+
}
|
483
|
+
if (showOptimizationBailout) {
|
484
|
+
obj.optimizationBailout = module.optimizationBailout.map(item => {
|
485
|
+
if (typeof item === "function") return item(requestShortener);
|
486
|
+
return item;
|
487
|
+
});
|
488
|
+
}
|
489
|
+
if (showDepth) {
|
490
|
+
obj.depth = module.depth;
|
491
|
+
}
|
492
|
+
if (showNestedModules) {
|
493
|
+
if (module.modules) {
|
494
|
+
const modules = module.modules;
|
495
|
+
obj.modules = modules
|
496
|
+
.sort(sortByField("depth"))
|
497
|
+
.filter(createModuleFilter())
|
498
|
+
.map(fnModule);
|
499
|
+
obj.filteredModules = modules.length - obj.modules.length;
|
500
|
+
obj.modules.sort(sortByField(sortModules));
|
501
|
+
}
|
502
|
+
}
|
503
|
+
if (showSource && module._source) {
|
504
|
+
obj.source = module._source.source();
|
505
|
+
}
|
506
|
+
return obj;
|
507
|
+
};
|
508
|
+
if (showChunks) {
|
509
|
+
obj.chunks = compilation.chunks.map(chunk => {
|
510
|
+
const parents = new Set();
|
511
|
+
const children = new Set();
|
512
|
+
const siblings = new Set();
|
513
|
+
for (const chunkGroup of chunk.groupsIterable) {
|
514
|
+
for (const parentGroup of chunkGroup.parentsIterable) {
|
515
|
+
for (const chunk of parentGroup.chunks) {
|
516
|
+
parents.add(chunk.id);
|
517
|
+
}
|
518
|
+
}
|
519
|
+
for (const childGroup of chunkGroup.childrenIterable) {
|
520
|
+
for (const chunk of childGroup.chunks) {
|
521
|
+
children.add(chunk.id);
|
522
|
+
}
|
523
|
+
}
|
524
|
+
for (const sibling of chunkGroup.chunks) {
|
525
|
+
if (sibling !== chunk) siblings.add(sibling.id);
|
526
|
+
}
|
527
|
+
}
|
528
|
+
const obj = {
|
529
|
+
id: chunk.id,
|
530
|
+
rendered: chunk.rendered,
|
531
|
+
initial: chunk.canBeInitial(),
|
532
|
+
entry: chunk.hasRuntime(),
|
533
|
+
recorded: chunk.recorded,
|
534
|
+
reason: chunk.chunkReason,
|
535
|
+
size: chunk.modulesSize(),
|
536
|
+
names: chunk.name ? [chunk.name] : [],
|
537
|
+
files: chunk.files.slice(),
|
538
|
+
hash: chunk.renderedHash,
|
539
|
+
siblings: Array.from(siblings).sort(),
|
540
|
+
parents: Array.from(parents).sort(),
|
541
|
+
children: Array.from(children).sort()
|
542
|
+
};
|
543
|
+
if (showChunkModules) {
|
544
|
+
obj.modules = chunk
|
545
|
+
.getModules()
|
546
|
+
.sort(sortByField("depth"))
|
547
|
+
.filter(createModuleFilter())
|
548
|
+
.map(fnModule);
|
549
|
+
obj.filteredModules = chunk.getNumberOfModules() - obj.modules.length;
|
550
|
+
obj.modules.sort(sortByField(sortModules));
|
551
|
+
}
|
552
|
+
if (showChunkOrigins) {
|
553
|
+
obj.origins = Array.from(chunk.groupsIterable, g => g.origins)
|
554
|
+
.reduce((a, b) => a.concat(b), [])
|
555
|
+
.map(origin => ({
|
556
|
+
moduleId: origin.module ? origin.module.id : undefined,
|
557
|
+
module: origin.module ? origin.module.identifier() : "",
|
558
|
+
moduleIdentifier: origin.module ? origin.module.identifier() : "",
|
559
|
+
moduleName: origin.module
|
560
|
+
? origin.module.readableIdentifier(requestShortener)
|
561
|
+
: "",
|
562
|
+
loc: formatLocation(origin.loc),
|
563
|
+
request: origin.request,
|
564
|
+
reasons: origin.reasons || []
|
565
|
+
}))
|
566
|
+
.sort((a, b) => {
|
567
|
+
if (
|
568
|
+
typeof a.moduleId === "number" &&
|
569
|
+
typeof b.moduleId !== "number"
|
570
|
+
)
|
571
|
+
return 1;
|
572
|
+
if (
|
573
|
+
typeof a.moduleId !== "number" &&
|
574
|
+
typeof b.moduleId === "number"
|
575
|
+
)
|
576
|
+
return -1;
|
577
|
+
if (
|
578
|
+
typeof a.moduleId === "number" &&
|
579
|
+
typeof b.moduleId === "number"
|
580
|
+
) {
|
581
|
+
const diffId = a.moduleId - b.moduleId;
|
582
|
+
if (diffId !== 0) return diffId;
|
583
|
+
}
|
584
|
+
if (a.loc < b.loc) return -1;
|
585
|
+
if (a.loc > b.loc) return 1;
|
586
|
+
return 0;
|
587
|
+
});
|
588
|
+
}
|
589
|
+
return obj;
|
590
|
+
});
|
591
|
+
obj.chunks.sort(sortByField(sortChunks));
|
592
|
+
}
|
593
|
+
if (showModules) {
|
594
|
+
obj.modules = compilation.modules
|
595
|
+
.slice()
|
596
|
+
.sort(sortByField("depth"))
|
597
|
+
.filter(createModuleFilter())
|
598
|
+
.map(fnModule);
|
599
|
+
obj.filteredModules = compilation.modules.length - obj.modules.length;
|
600
|
+
obj.modules.sort(sortByField(sortModules));
|
601
|
+
}
|
602
|
+
if (showChildren) {
|
603
|
+
obj.children = compilation.children.map((child, idx) => {
|
604
|
+
const childOptions = Stats.getChildOptions(options, idx);
|
605
|
+
const obj = new Stats(child).toJson(childOptions, forToString);
|
606
|
+
delete obj.hash;
|
607
|
+
delete obj.version;
|
608
|
+
if (child.name)
|
609
|
+
obj.name = identifierUtils.makePathsRelative(
|
610
|
+
context,
|
611
|
+
child.name,
|
612
|
+
compilation.cache
|
613
|
+
);
|
614
|
+
return obj;
|
615
|
+
});
|
616
|
+
}
|
617
|
+
|
618
|
+
return obj;
|
619
|
+
}
|
620
|
+
|
621
|
+
toString(options) {
|
622
|
+
if (typeof options === "boolean" || typeof options === "string") {
|
623
|
+
options = Stats.presetToOptions(options);
|
624
|
+
} else if (!options) {
|
625
|
+
options = {};
|
626
|
+
}
|
627
|
+
|
628
|
+
const useColors = optionsOrFallback(options.colors, false);
|
629
|
+
|
630
|
+
const obj = this.toJson(options, true);
|
631
|
+
|
632
|
+
return Stats.jsonToString(obj, useColors);
|
633
|
+
}
|
634
|
+
|
635
|
+
static jsonToString(obj, useColors) {
|
636
|
+
const buf = [];
|
637
|
+
|
638
|
+
const defaultColors = {
|
639
|
+
bold: "\u001b[1m",
|
640
|
+
yellow: "\u001b[1m\u001b[33m",
|
641
|
+
red: "\u001b[1m\u001b[31m",
|
642
|
+
green: "\u001b[1m\u001b[32m",
|
643
|
+
cyan: "\u001b[1m\u001b[36m",
|
644
|
+
magenta: "\u001b[1m\u001b[35m"
|
645
|
+
};
|
646
|
+
|
647
|
+
const colors = Object.keys(defaultColors).reduce(
|
648
|
+
(obj, color) => {
|
649
|
+
obj[color] = str => {
|
650
|
+
if (useColors) {
|
651
|
+
buf.push(
|
652
|
+
useColors === true || useColors[color] === undefined
|
653
|
+
? defaultColors[color]
|
654
|
+
: useColors[color]
|
655
|
+
);
|
656
|
+
}
|
657
|
+
buf.push(str);
|
658
|
+
if (useColors) {
|
659
|
+
buf.push("\u001b[39m\u001b[22m");
|
660
|
+
}
|
661
|
+
};
|
662
|
+
return obj;
|
663
|
+
},
|
664
|
+
{
|
665
|
+
normal: str => buf.push(str)
|
666
|
+
}
|
667
|
+
);
|
668
|
+
|
669
|
+
const coloredTime = time => {
|
670
|
+
let times = [800, 400, 200, 100];
|
671
|
+
if (obj.time) {
|
672
|
+
times = [obj.time / 2, obj.time / 4, obj.time / 8, obj.time / 16];
|
673
|
+
}
|
674
|
+
if (time < times[3]) colors.normal(`${time}ms`);
|
675
|
+
else if (time < times[2]) colors.bold(`${time}ms`);
|
676
|
+
else if (time < times[1]) colors.green(`${time}ms`);
|
677
|
+
else if (time < times[0]) colors.yellow(`${time}ms`);
|
678
|
+
else colors.red(`${time}ms`);
|
679
|
+
};
|
680
|
+
|
681
|
+
const newline = () => buf.push("\n");
|
682
|
+
|
683
|
+
const getText = (arr, row, col) => {
|
684
|
+
return arr[row][col].value;
|
685
|
+
};
|
686
|
+
|
687
|
+
const table = (array, align, splitter) => {
|
688
|
+
const rows = array.length;
|
689
|
+
const cols = array[0].length;
|
690
|
+
const colSizes = new Array(cols);
|
691
|
+
for (let col = 0; col < cols; col++) colSizes[col] = 0;
|
692
|
+
for (let row = 0; row < rows; row++) {
|
693
|
+
for (let col = 0; col < cols; col++) {
|
694
|
+
const value = `${getText(array, row, col)}`;
|
695
|
+
if (value.length > colSizes[col]) {
|
696
|
+
colSizes[col] = value.length;
|
697
|
+
}
|
698
|
+
}
|
699
|
+
}
|
700
|
+
for (let row = 0; row < rows; row++) {
|
701
|
+
for (let col = 0; col < cols; col++) {
|
702
|
+
const format = array[row][col].color;
|
703
|
+
const value = `${getText(array, row, col)}`;
|
704
|
+
let l = value.length;
|
705
|
+
if (align[col] === "l") format(value);
|
706
|
+
for (; l < colSizes[col] && col !== cols - 1; l++) colors.normal(" ");
|
707
|
+
if (align[col] === "r") format(value);
|
708
|
+
if (col + 1 < cols && colSizes[col] !== 0)
|
709
|
+
colors.normal(splitter || " ");
|
710
|
+
}
|
711
|
+
newline();
|
712
|
+
}
|
713
|
+
};
|
714
|
+
|
715
|
+
const getAssetColor = (asset, defaultColor) => {
|
716
|
+
if (asset.isOverSizeLimit) {
|
717
|
+
return colors.yellow;
|
718
|
+
}
|
719
|
+
|
720
|
+
return defaultColor;
|
721
|
+
};
|
722
|
+
|
723
|
+
if (obj.hash) {
|
724
|
+
colors.normal("Hash: ");
|
725
|
+
colors.bold(obj.hash);
|
726
|
+
newline();
|
727
|
+
}
|
728
|
+
if (obj.version) {
|
729
|
+
colors.normal("Version: webpack ");
|
730
|
+
colors.bold(obj.version);
|
731
|
+
newline();
|
732
|
+
}
|
733
|
+
if (typeof obj.time === "number") {
|
734
|
+
colors.normal("Time: ");
|
735
|
+
colors.bold(obj.time);
|
736
|
+
colors.normal("ms");
|
737
|
+
newline();
|
738
|
+
}
|
739
|
+
if (typeof obj.builtAt === "number") {
|
740
|
+
const builtAtDate = new Date(obj.builtAt);
|
741
|
+
colors.normal("Built at: ");
|
742
|
+
colors.normal(
|
743
|
+
builtAtDate.toLocaleDateString({
|
744
|
+
day: "2-digit",
|
745
|
+
month: "2-digit",
|
746
|
+
year: "numeric"
|
747
|
+
})
|
748
|
+
);
|
749
|
+
colors.normal(" ");
|
750
|
+
colors.bold(builtAtDate.toLocaleTimeString());
|
751
|
+
newline();
|
752
|
+
}
|
753
|
+
if (obj.env) {
|
754
|
+
colors.normal("Environment (--env): ");
|
755
|
+
colors.bold(JSON.stringify(obj.env, null, 2));
|
756
|
+
newline();
|
757
|
+
}
|
758
|
+
if (obj.publicPath) {
|
759
|
+
colors.normal("PublicPath: ");
|
760
|
+
colors.bold(obj.publicPath);
|
761
|
+
newline();
|
762
|
+
}
|
763
|
+
|
764
|
+
if (obj.assets && obj.assets.length > 0) {
|
765
|
+
const t = [
|
766
|
+
[
|
767
|
+
{
|
768
|
+
value: "Asset",
|
769
|
+
color: colors.bold
|
770
|
+
},
|
771
|
+
{
|
772
|
+
value: "Size",
|
773
|
+
color: colors.bold
|
774
|
+
},
|
775
|
+
{
|
776
|
+
value: "Chunks",
|
777
|
+
color: colors.bold
|
778
|
+
},
|
779
|
+
{
|
780
|
+
value: "",
|
781
|
+
color: colors.bold
|
782
|
+
},
|
783
|
+
{
|
784
|
+
value: "",
|
785
|
+
color: colors.bold
|
786
|
+
},
|
787
|
+
{
|
788
|
+
value: "Chunk Names",
|
789
|
+
color: colors.bold
|
790
|
+
}
|
791
|
+
]
|
792
|
+
];
|
793
|
+
for (const asset of obj.assets) {
|
794
|
+
t.push([
|
795
|
+
{
|
796
|
+
value: asset.name,
|
797
|
+
color: getAssetColor(asset, colors.green)
|
798
|
+
},
|
799
|
+
{
|
800
|
+
value: SizeFormatHelpers.formatSize(asset.size),
|
801
|
+
color: getAssetColor(asset, colors.normal)
|
802
|
+
},
|
803
|
+
{
|
804
|
+
value: asset.chunks.join(", "),
|
805
|
+
color: colors.bold
|
806
|
+
},
|
807
|
+
{
|
808
|
+
value: asset.emitted ? "[emitted]" : "",
|
809
|
+
color: colors.green
|
810
|
+
},
|
811
|
+
{
|
812
|
+
value: asset.isOverSizeLimit ? "[big]" : "",
|
813
|
+
color: getAssetColor(asset, colors.normal)
|
814
|
+
},
|
815
|
+
{
|
816
|
+
value: asset.chunkNames.join(", "),
|
817
|
+
color: colors.normal
|
818
|
+
}
|
819
|
+
]);
|
820
|
+
}
|
821
|
+
table(t, "rrrlll");
|
822
|
+
}
|
823
|
+
if (obj.filteredAssets > 0) {
|
824
|
+
colors.normal(" ");
|
825
|
+
if (obj.assets.length > 0) colors.normal("+ ");
|
826
|
+
colors.normal(obj.filteredAssets);
|
827
|
+
if (obj.assets.length > 0) colors.normal(" hidden");
|
828
|
+
colors.normal(obj.filteredAssets !== 1 ? " assets" : " asset");
|
829
|
+
newline();
|
830
|
+
}
|
831
|
+
if (obj.entrypoints) {
|
832
|
+
for (const name of Object.keys(obj.entrypoints)) {
|
833
|
+
const ep = obj.entrypoints[name];
|
834
|
+
colors.normal("Entrypoint ");
|
835
|
+
colors.bold(name);
|
836
|
+
if (ep.isOverSizeLimit) {
|
837
|
+
colors.normal(" ");
|
838
|
+
colors.yellow("[big]");
|
839
|
+
}
|
840
|
+
colors.normal(" =");
|
841
|
+
for (const asset of ep.assets) {
|
842
|
+
colors.normal(" ");
|
843
|
+
colors.green(asset);
|
844
|
+
}
|
845
|
+
newline();
|
846
|
+
}
|
847
|
+
}
|
848
|
+
const modulesByIdentifier = {};
|
849
|
+
if (obj.modules) {
|
850
|
+
for (const module of obj.modules) {
|
851
|
+
modulesByIdentifier[`$${module.identifier}`] = module;
|
852
|
+
}
|
853
|
+
} else if (obj.chunks) {
|
854
|
+
for (const chunk of obj.chunks) {
|
855
|
+
if (chunk.modules) {
|
856
|
+
for (const module of chunk.modules) {
|
857
|
+
modulesByIdentifier[`$${module.identifier}`] = module;
|
858
|
+
}
|
859
|
+
}
|
860
|
+
}
|
861
|
+
}
|
862
|
+
|
863
|
+
const processModuleAttributes = module => {
|
864
|
+
colors.normal(" ");
|
865
|
+
colors.normal(SizeFormatHelpers.formatSize(module.size));
|
866
|
+
if (module.chunks) {
|
867
|
+
for (const chunk of module.chunks) {
|
868
|
+
colors.normal(" {");
|
869
|
+
colors.yellow(chunk);
|
870
|
+
colors.normal("}");
|
871
|
+
}
|
872
|
+
}
|
873
|
+
if (typeof module.depth === "number") {
|
874
|
+
colors.normal(` [depth ${module.depth}]`);
|
875
|
+
}
|
876
|
+
if (module.cacheable === false) {
|
877
|
+
colors.red(" [not cacheable]");
|
878
|
+
}
|
879
|
+
if (module.optional) {
|
880
|
+
colors.yellow(" [optional]");
|
881
|
+
}
|
882
|
+
if (module.built) {
|
883
|
+
colors.green(" [built]");
|
884
|
+
}
|
885
|
+
if (module.assets && module.assets.length) {
|
886
|
+
colors.magenta(
|
887
|
+
` [${module.assets.length} asset${
|
888
|
+
module.assets.length === 1 ? "" : "s"
|
889
|
+
}]`
|
890
|
+
);
|
891
|
+
}
|
892
|
+
if (module.prefetched) {
|
893
|
+
colors.magenta(" [prefetched]");
|
894
|
+
}
|
895
|
+
if (module.failed) colors.red(" [failed]");
|
896
|
+
if (module.warnings)
|
897
|
+
colors.yellow(
|
898
|
+
` [${module.warnings} warning${module.warnings === 1 ? "" : "s"}]`
|
899
|
+
);
|
900
|
+
if (module.errors)
|
901
|
+
colors.red(
|
902
|
+
` [${module.errors} error${module.errors === 1 ? "" : "s"}]`
|
903
|
+
);
|
904
|
+
};
|
905
|
+
|
906
|
+
const processModuleContent = (module, prefix) => {
|
907
|
+
if (Array.isArray(module.providedExports)) {
|
908
|
+
colors.normal(prefix);
|
909
|
+
if (module.providedExports.length === 0) colors.cyan("[no exports]");
|
910
|
+
else colors.cyan(`[exports: ${module.providedExports.join(", ")}]`);
|
911
|
+
newline();
|
912
|
+
}
|
913
|
+
if (module.usedExports !== undefined) {
|
914
|
+
if (module.usedExports !== true) {
|
915
|
+
colors.normal(prefix);
|
916
|
+
if (module.usedExports === null)
|
917
|
+
colors.cyan("[used exports unknown]");
|
918
|
+
else if (module.usedExports === false)
|
919
|
+
colors.cyan("[no exports used]");
|
920
|
+
else if (
|
921
|
+
Array.isArray(module.usedExports) &&
|
922
|
+
module.usedExports.length === 0
|
923
|
+
)
|
924
|
+
colors.cyan("[no exports used]");
|
925
|
+
else if (Array.isArray(module.usedExports))
|
926
|
+
colors.cyan(
|
927
|
+
`[only some exports used: ${module.usedExports.join(", ")}]`
|
928
|
+
);
|
929
|
+
newline();
|
930
|
+
}
|
931
|
+
}
|
932
|
+
if (Array.isArray(module.optimizationBailout)) {
|
933
|
+
for (const item of module.optimizationBailout) {
|
934
|
+
colors.normal(prefix);
|
935
|
+
colors.yellow(item);
|
936
|
+
newline();
|
937
|
+
}
|
938
|
+
}
|
939
|
+
if (module.reasons) {
|
940
|
+
for (const reason of module.reasons) {
|
941
|
+
colors.normal(prefix);
|
942
|
+
if (reason.type) {
|
943
|
+
colors.normal(reason.type);
|
944
|
+
colors.normal(" ");
|
945
|
+
}
|
946
|
+
if (reason.userRequest) {
|
947
|
+
colors.cyan(reason.userRequest);
|
948
|
+
colors.normal(" ");
|
949
|
+
}
|
950
|
+
if (reason.moduleId !== null) {
|
951
|
+
colors.normal("[");
|
952
|
+
colors.normal(reason.moduleId);
|
953
|
+
colors.normal("]");
|
954
|
+
}
|
955
|
+
if (reason.module && reason.module !== reason.moduleId) {
|
956
|
+
colors.normal(" ");
|
957
|
+
colors.magenta(reason.module);
|
958
|
+
}
|
959
|
+
if (reason.loc) {
|
960
|
+
colors.normal(" ");
|
961
|
+
colors.normal(reason.loc);
|
962
|
+
}
|
963
|
+
newline();
|
964
|
+
}
|
965
|
+
}
|
966
|
+
if (module.profile) {
|
967
|
+
colors.normal(prefix);
|
968
|
+
let sum = 0;
|
969
|
+
if (module.issuerPath) {
|
970
|
+
for (const m of module.issuerPath) {
|
971
|
+
colors.normal("[");
|
972
|
+
colors.normal(m.id);
|
973
|
+
colors.normal("] ");
|
974
|
+
if (m.profile) {
|
975
|
+
const time = (m.profile.factory || 0) + (m.profile.building || 0);
|
976
|
+
coloredTime(time);
|
977
|
+
sum += time;
|
978
|
+
colors.normal(" ");
|
979
|
+
}
|
980
|
+
colors.normal("-> ");
|
981
|
+
}
|
982
|
+
}
|
983
|
+
for (const key of Object.keys(module.profile)) {
|
984
|
+
colors.normal(`${key}:`);
|
985
|
+
const time = module.profile[key];
|
986
|
+
coloredTime(time);
|
987
|
+
colors.normal(" ");
|
988
|
+
sum += time;
|
989
|
+
}
|
990
|
+
colors.normal("= ");
|
991
|
+
coloredTime(sum);
|
992
|
+
newline();
|
993
|
+
}
|
994
|
+
if (module.modules) {
|
995
|
+
processModulesList(module, prefix + "| ");
|
996
|
+
}
|
997
|
+
};
|
998
|
+
|
999
|
+
const processModulesList = (obj, prefix) => {
|
1000
|
+
if (obj.modules) {
|
1001
|
+
for (const module of obj.modules) {
|
1002
|
+
colors.normal(prefix);
|
1003
|
+
const name = module.name || module.identifier;
|
1004
|
+
let contentPrefix = prefix + " ";
|
1005
|
+
if (typeof module.id === "string" || typeof module.id === "number") {
|
1006
|
+
contentPrefix += " ";
|
1007
|
+
if (module.id < 1000) colors.normal(" ");
|
1008
|
+
if (module.id < 100) colors.normal(" ");
|
1009
|
+
if (module.id < 10) colors.normal(" ");
|
1010
|
+
colors.normal("[");
|
1011
|
+
colors.normal(module.id);
|
1012
|
+
colors.normal("]");
|
1013
|
+
if (name !== module.id) colors.normal(" ");
|
1014
|
+
}
|
1015
|
+
if (name !== module.id) {
|
1016
|
+
colors.bold(name);
|
1017
|
+
}
|
1018
|
+
processModuleAttributes(module);
|
1019
|
+
newline();
|
1020
|
+
processModuleContent(module, contentPrefix);
|
1021
|
+
}
|
1022
|
+
if (obj.filteredModules > 0) {
|
1023
|
+
colors.normal(prefix);
|
1024
|
+
colors.normal(" ");
|
1025
|
+
if (obj.modules.length > 0) colors.normal(" + ");
|
1026
|
+
colors.normal(obj.filteredModules);
|
1027
|
+
if (obj.modules.length > 0) colors.normal(" hidden");
|
1028
|
+
colors.normal(obj.filteredModules !== 1 ? " modules" : " module");
|
1029
|
+
newline();
|
1030
|
+
}
|
1031
|
+
}
|
1032
|
+
};
|
1033
|
+
|
1034
|
+
if (obj.chunks) {
|
1035
|
+
for (const chunk of obj.chunks) {
|
1036
|
+
colors.normal("chunk ");
|
1037
|
+
if (chunk.id < 1000) colors.normal(" ");
|
1038
|
+
if (chunk.id < 100) colors.normal(" ");
|
1039
|
+
if (chunk.id < 10) colors.normal(" ");
|
1040
|
+
colors.normal("{");
|
1041
|
+
colors.yellow(chunk.id);
|
1042
|
+
colors.normal("} ");
|
1043
|
+
colors.green(chunk.files.join(", "));
|
1044
|
+
if (chunk.names && chunk.names.length > 0) {
|
1045
|
+
colors.normal(" (");
|
1046
|
+
colors.normal(chunk.names.join(", "));
|
1047
|
+
colors.normal(")");
|
1048
|
+
}
|
1049
|
+
colors.normal(" ");
|
1050
|
+
colors.normal(SizeFormatHelpers.formatSize(chunk.size));
|
1051
|
+
for (const id of chunk.parents) {
|
1052
|
+
colors.normal(" <{");
|
1053
|
+
colors.yellow(id);
|
1054
|
+
colors.normal("}>");
|
1055
|
+
}
|
1056
|
+
for (const id of chunk.siblings) {
|
1057
|
+
colors.normal(" ={");
|
1058
|
+
colors.yellow(id);
|
1059
|
+
colors.normal("}=");
|
1060
|
+
}
|
1061
|
+
for (const id of chunk.children) {
|
1062
|
+
colors.normal(" >{");
|
1063
|
+
colors.yellow(id);
|
1064
|
+
colors.normal("}<");
|
1065
|
+
}
|
1066
|
+
if (chunk.entry) {
|
1067
|
+
colors.yellow(" [entry]");
|
1068
|
+
} else if (chunk.initial) {
|
1069
|
+
colors.yellow(" [initial]");
|
1070
|
+
}
|
1071
|
+
if (chunk.rendered) {
|
1072
|
+
colors.green(" [rendered]");
|
1073
|
+
}
|
1074
|
+
if (chunk.recorded) {
|
1075
|
+
colors.green(" [recorded]");
|
1076
|
+
}
|
1077
|
+
if (chunk.reason) {
|
1078
|
+
colors.yellow(` ${chunk.reason}`);
|
1079
|
+
}
|
1080
|
+
newline();
|
1081
|
+
if (chunk.origins) {
|
1082
|
+
for (const origin of chunk.origins) {
|
1083
|
+
colors.normal(" > ");
|
1084
|
+
if (origin.reasons && origin.reasons.length) {
|
1085
|
+
colors.yellow(origin.reasons.join(" "));
|
1086
|
+
colors.normal(" ");
|
1087
|
+
}
|
1088
|
+
if (origin.request) {
|
1089
|
+
colors.normal(origin.request);
|
1090
|
+
colors.normal(" ");
|
1091
|
+
}
|
1092
|
+
if (origin.module) {
|
1093
|
+
colors.normal("[");
|
1094
|
+
colors.normal(origin.moduleId);
|
1095
|
+
colors.normal("] ");
|
1096
|
+
const module = modulesByIdentifier[`$${origin.module}`];
|
1097
|
+
if (module) {
|
1098
|
+
colors.bold(module.name);
|
1099
|
+
colors.normal(" ");
|
1100
|
+
}
|
1101
|
+
}
|
1102
|
+
if (origin.loc) {
|
1103
|
+
colors.normal(origin.loc);
|
1104
|
+
}
|
1105
|
+
newline();
|
1106
|
+
}
|
1107
|
+
}
|
1108
|
+
processModulesList(chunk, " ");
|
1109
|
+
}
|
1110
|
+
}
|
1111
|
+
|
1112
|
+
processModulesList(obj, "");
|
1113
|
+
|
1114
|
+
if (obj._showWarnings && obj.warnings) {
|
1115
|
+
for (const warning of obj.warnings) {
|
1116
|
+
newline();
|
1117
|
+
colors.yellow(`WARNING in ${warning}`);
|
1118
|
+
newline();
|
1119
|
+
}
|
1120
|
+
}
|
1121
|
+
if (obj._showErrors && obj.errors) {
|
1122
|
+
for (const error of obj.errors) {
|
1123
|
+
newline();
|
1124
|
+
colors.red(`ERROR in ${error}`);
|
1125
|
+
newline();
|
1126
|
+
}
|
1127
|
+
}
|
1128
|
+
if (obj.children) {
|
1129
|
+
for (const child of obj.children) {
|
1130
|
+
const childString = Stats.jsonToString(child, useColors);
|
1131
|
+
if (childString) {
|
1132
|
+
if (child.name) {
|
1133
|
+
colors.normal("Child ");
|
1134
|
+
colors.bold(child.name);
|
1135
|
+
colors.normal(":");
|
1136
|
+
} else {
|
1137
|
+
colors.normal("Child");
|
1138
|
+
}
|
1139
|
+
newline();
|
1140
|
+
buf.push(" ");
|
1141
|
+
buf.push(childString.replace(/\n/g, "\n "));
|
1142
|
+
newline();
|
1143
|
+
}
|
1144
|
+
}
|
1145
|
+
}
|
1146
|
+
if (obj.needAdditionalPass) {
|
1147
|
+
colors.yellow(
|
1148
|
+
"Compilation needs an additional pass and will compile again."
|
1149
|
+
);
|
1150
|
+
}
|
1151
|
+
|
1152
|
+
while (buf[buf.length - 1] === "\n") buf.pop();
|
1153
|
+
return buf.join("");
|
1154
|
+
}
|
1155
|
+
|
1156
|
+
static presetToOptions(name) {
|
1157
|
+
// Accepted values: none, errors-only, minimal, normal, detailed, verbose
|
1158
|
+
// Any other falsy value will behave as 'none', truthy values as 'normal'
|
1159
|
+
const pn =
|
1160
|
+
(typeof name === "string" && name.toLowerCase()) || name || "none";
|
1161
|
+
switch (pn) {
|
1162
|
+
case "none":
|
1163
|
+
return {
|
1164
|
+
all: false
|
1165
|
+
};
|
1166
|
+
case "verbose":
|
1167
|
+
return {
|
1168
|
+
entrypoints: true,
|
1169
|
+
modules: false,
|
1170
|
+
chunks: true,
|
1171
|
+
chunkModules: true,
|
1172
|
+
chunkOrigins: true,
|
1173
|
+
depth: true,
|
1174
|
+
env: true,
|
1175
|
+
reasons: true,
|
1176
|
+
usedExports: true,
|
1177
|
+
providedExports: true,
|
1178
|
+
optimizationBailout: true,
|
1179
|
+
errorDetails: true,
|
1180
|
+
publicPath: true,
|
1181
|
+
exclude: false,
|
1182
|
+
maxModules: Infinity
|
1183
|
+
};
|
1184
|
+
case "detailed":
|
1185
|
+
return {
|
1186
|
+
entrypoints: true,
|
1187
|
+
chunks: true,
|
1188
|
+
chunkModules: false,
|
1189
|
+
chunkOrigins: true,
|
1190
|
+
depth: true,
|
1191
|
+
usedExports: true,
|
1192
|
+
providedExports: true,
|
1193
|
+
optimizationBailout: true,
|
1194
|
+
errorDetails: true,
|
1195
|
+
publicPath: true,
|
1196
|
+
exclude: false,
|
1197
|
+
maxModules: Infinity
|
1198
|
+
};
|
1199
|
+
case "minimal":
|
1200
|
+
return {
|
1201
|
+
all: false,
|
1202
|
+
modules: true,
|
1203
|
+
maxModules: 0,
|
1204
|
+
errors: true,
|
1205
|
+
warnings: true
|
1206
|
+
};
|
1207
|
+
case "errors-only":
|
1208
|
+
return {
|
1209
|
+
all: false,
|
1210
|
+
errors: true,
|
1211
|
+
moduleTrace: true
|
1212
|
+
};
|
1213
|
+
default:
|
1214
|
+
return {};
|
1215
|
+
}
|
1216
|
+
}
|
1217
|
+
|
1218
|
+
static getChildOptions(options, idx) {
|
1219
|
+
let innerOptions;
|
1220
|
+
if (Array.isArray(options.children)) {
|
1221
|
+
if (idx < options.children.length) innerOptions = options.children[idx];
|
1222
|
+
} else if (typeof options.children === "object" && options.children) {
|
1223
|
+
innerOptions = options.children;
|
1224
|
+
}
|
1225
|
+
if (typeof innerOptions === "boolean" || typeof innerOptions === "string")
|
1226
|
+
innerOptions = Stats.presetToOptions(innerOptions);
|
1227
|
+
if (!innerOptions) return options;
|
1228
|
+
const childOptions = Object.assign({}, options);
|
1229
|
+
delete childOptions.children; // do not inherit children
|
1230
|
+
return Object.assign(childOptions, innerOptions);
|
1231
|
+
}
|
1232
|
+
}
|
1233
|
+
|
1234
|
+
module.exports = Stats;
|