File tree Expand file tree Collapse file tree 1 file changed +20
-3
lines changed
Expand file tree Collapse file tree 1 file changed +20
-3
lines changed Original file line number Diff line number Diff line change @@ -4,24 +4,41 @@ import * as fs from "node:fs/promises";
44
55import { BUNDLE_METADATA_FILE } from "./config" ;
66
7+ interface InputInfo {
8+ bytesInOutput : number ;
9+ }
10+
11+ type Inputs = Record < string , InputInfo > ;
12+
713interface Output {
814 bytes : number ;
15+ inputs : Inputs ;
916}
1017
1118interface Metadata {
1219 outputs : Output [ ] ;
1320}
1421
22+ function toMB ( bytes : number ) : string {
23+ return `${ ( bytes / ( 1024 * 1024 ) ) . toFixed ( 2 ) } MB` ;
24+ }
25+
1526async function main ( ) {
1627 const fileContents = await fs . readFile ( BUNDLE_METADATA_FILE ) ;
1728 const metadata = JSON . parse ( String ( fileContents ) ) as Metadata ;
1829
1930 for ( const [ outputFile , outputData ] of Object . entries (
2031 metadata . outputs ,
2132 ) . reverse ( ) ) {
22- console . info (
23- `${ outputFile } : ${ ( outputData . bytes / ( 1024 * 1024 ) ) . toFixed ( 2 ) } MB` ,
24- ) ;
33+ console . info ( `${ outputFile } : ${ toMB ( outputData . bytes ) } ` ) ;
34+
35+ for ( const [ inputName , inputData ] of Object . entries ( outputData . inputs ) ) {
36+ // Ignore any inputs that make up less than 5% of the output.
37+ const percentage = ( inputData . bytesInOutput / outputData . bytes ) * 100.0 ;
38+ if ( percentage < 5.0 ) continue ;
39+
40+ console . info ( ` ${ inputName } : ${ toMB ( inputData . bytesInOutput ) } ` ) ;
41+ }
2542 }
2643}
2744
You can’t perform that action at this time.
0 commit comments