// Bundle-size budget gate. Sums the gzipped size of the built app JS and fails if it // exceeds the budget — a guard against an accidental heavy dependency. The real // transport build is ~69 KB gzip today; the budget leaves headroom. import { readdirSync, readFileSync } from 'node:fs'; import { gzipSync } from 'node:zlib'; const BUDGET = 100 * 1024; // gzip bytes for app JS const dir = 'dist/assets'; let total = 0; for (const f of readdirSync(dir)) { if (!f.endsWith('.js')) continue; const gz = gzipSync(readFileSync(`${dir}/${f}`)).length; total += gz; console.log(`${f}: ${(gz / 1024).toFixed(1)} KB gzip`); } console.log(`total app JS: ${(total / 1024).toFixed(1)} KB gzip (budget ${BUDGET / 1024} KB)`); if (total > BUDGET) { console.error('bundle exceeds size budget'); process.exit(1); }