File tree Expand file tree Collapse file tree 3 files changed +35
-1
lines changed
Expand file tree Collapse file tree 3 files changed +35
-1
lines changed Original file line number Diff line number Diff line change 55 "description" : " CodeQL action" ,
66 "scripts" : {
77 "_build_comment" : " echo 'Run the full build so we typecheck the project and can reuse the transpiled files in npm test'" ,
8- "build" : " ./scripts/check-node-modules.sh && npm run transpile && node build.mjs" ,
8+ "build" : " ./scripts/check-node-modules.sh && npm run transpile && node build.mjs && npx tsx ./pr-checks/bundle-metadata.ts " ,
99 "lint" : " eslint --report-unused-disable-directives --max-warnings=0 ." ,
1010 "lint-ci" : " SARIF_ESLINT_IGNORE_SUPPRESSED=true eslint --report-unused-disable-directives --max-warnings=0 . --format @microsoft/eslint-formatter-sarif --output-file=eslint.sarif" ,
1111 "lint-fix" : " eslint --report-unused-disable-directives --max-warnings=0 . --fix" ,
Original file line number Diff line number Diff line change 1+ #!/usr/bin/env npx tsx
2+
3+ import * as fs from "node:fs/promises" ;
4+
5+ import { BUNDLE_METADATA_FILE } from "./config" ;
6+
7+ interface Output {
8+ bytes : number ;
9+ }
10+
11+ interface Metadata {
12+ outputs : Output [ ] ;
13+ }
14+
15+ async function main ( ) {
16+ const fileContents = await fs . readFile ( BUNDLE_METADATA_FILE ) ;
17+ const metadata = JSON . parse ( String ( fileContents ) ) as Metadata ;
18+
19+ for ( const [ outputFile , outputData ] of Object . entries (
20+ metadata . outputs ,
21+ ) . reverse ( ) ) {
22+ console . info (
23+ `${ outputFile } : ${ ( outputData . bytes / ( 1024 * 1024 ) ) . toFixed ( 2 ) } MB` ,
24+ ) ;
25+ }
26+ }
27+
28+ // Only call `main` if this script was run directly.
29+ if ( require . main === module ) {
30+ void main ( ) ;
31+ }
Original file line number Diff line number Diff line change @@ -8,3 +8,6 @@ export const PR_CHECKS_DIR = __dirname;
88
99/** The path of the file configuring which checks shouldn't be required. */
1010export const PR_CHECK_EXCLUDED_FILE = path . join ( PR_CHECKS_DIR , "excluded.yml" ) ;
11+
12+ /** The path to the esbuild metadata file. */
13+ export const BUNDLE_METADATA_FILE = path . join ( PR_CHECKS_DIR , ".." , "meta.json" ) ;
You can’t perform that action at this time.
0 commit comments