9
9
*/
10
10
11
11
import type { Compiler } from "../Compiler" ;
12
+ import type { StatsColorOptions } from "../config" ;
12
13
import { compareIds } from "../util/comparators" ;
13
14
import { formatSize } from "../util/SizeFormatHelpers" ;
14
15
import type { StatsPrinter , StatsPrinterContext } from "./StatsPrinter" ;
@@ -1197,7 +1198,7 @@ const SIMPLE_ELEMENT_JOINERS: Record<
1197
1198
moduleTraceDependency : joinOneLine
1198
1199
} ;
1199
1200
1200
- const AVAILABLE_COLORS = {
1201
+ const AVAILABLE_COLORS : Record < keyof StatsColorOptions , string > = {
1201
1202
bold : "\u001b[1m" ,
1202
1203
yellow : "\u001b[1m\u001b[33m" ,
1203
1204
red : "\u001b[1m\u001b[31m" ,
@@ -1359,8 +1360,13 @@ export class DefaultStatsPrinterPlugin {
1359
1360
"DefaultStatsPrinterPlugin" ,
1360
1361
// @ts -expect-error
1361
1362
( compilation : StatsCompilation , context ) => {
1362
- for ( const color of Object . keys ( AVAILABLE_COLORS ) ) {
1363
+ const colorNames = Object . keys (
1364
+ AVAILABLE_COLORS
1365
+ ) as ( keyof typeof AVAILABLE_COLORS ) [ ] ;
1366
+
1367
+ for ( const color of colorNames ) {
1363
1368
let start : string | undefined ;
1369
+
1364
1370
if ( options . colors ) {
1365
1371
if (
1366
1372
typeof options . colors === "object" &&
@@ -1372,6 +1378,7 @@ export class DefaultStatsPrinterPlugin {
1372
1378
AVAILABLE_COLORS [ color as keyof typeof AVAILABLE_COLORS ] ;
1373
1379
}
1374
1380
}
1381
+
1375
1382
if ( start ) {
1376
1383
context [ color ] = ( str : string ) =>
1377
1384
`${ start } ${
@@ -1386,12 +1393,14 @@ export class DefaultStatsPrinterPlugin {
1386
1393
context [ color ] = ( str : string ) => str ;
1387
1394
}
1388
1395
}
1396
+
1389
1397
for ( const format of Object . keys ( AVAILABLE_FORMATS ) ) {
1390
1398
// @ts -expect-error
1391
1399
context [ format ] = ( content , ...args ) =>
1392
1400
// @ts -expect-error
1393
1401
AVAILABLE_FORMATS [ format ] ( content , context , ...args ) ;
1394
1402
}
1403
+
1395
1404
context . timeReference = compilation . time ;
1396
1405
}
1397
1406
) ;
0 commit comments