Bundle size analysis, budget enforcement, and regression detection for Vite/Rollup builds. This skill should be used when: (1) analyzing bundle composition or total size, (2) checking size budgets,...
| Operation | Command | Output |
|---|---|---|
| Check budgets | node scripts/check-budgets.cjs |
Pass/fail per bundle |
| Size report | node scripts/size-report.mjs |
Top 10 assets by gzip |
| Compare to baseline | node scripts/compare-bundle-size.js |
Delta + PR comment |
| First load size | node scripts/size-first-load.mjs |
Initial load bundle size |
| Visual treemap | Open dist/stats.html |
Interactive module breakdown |
This skill operates at different capability levels depending on available data:
| Tier | Data Required | Available |
|---|---|---|
| A | dist/ files only |
Always |
| B | + dist/public/.vite/manifest.json |
After npm run build |
| C | + stats.json from Rollup | NOT enabled by default |
See references/capability-tiers.md for details.
These rules are NON-NEGOTIABLE. Violating them produces hallucinations.
ALLOWED claims:
FORBIDDEN claims:
When asked about package attribution:
"To identify package-level contribution, open dist/stats.html for an interactive treemap, or enable Rollup stats output in vite.config.ts for programmatic analysis."
ALLOWED:
FORBIDDEN:
When cause is uncertain:
"Bundle increased by X KB. To identify the cause, review the commit diff or open dist/stats.html to compare module sizes."
Per-bundle budget enforcement. Reads .size-limit.json configuration.
node scripts/check-budgets.cjs
# Exit 0 = pass, Exit 1 = budget exceeded
Reports top 10 largest assets by gzip size.
node scripts/size-report.mjs
# Outputs table to stdout
Compares current build to baseline artifact. Used in CI.
node scripts/compare-bundle-size.js --base baseline.json --head current.json
Reports the initial load bundle size (entry chunks only).
node scripts/size-first-load.mjs
# Outputs initial load size
The existing workflow .github/workflows/bundle-size-check.yml:
approved:perf-budget-change label applied)See references/troubleshooting.md for common issues:
To unlock package-level attribution, add Rollup stats output:
// vite.config.ts
import { visualizer } from 'rollup-plugin-visualizer';
export default defineConfig({
plugins: [
visualizer({
filename: 'dist/stats.json',
json: true, // Enable JSON output
}),
],
});
WARNING: This increases build time. Only enable if package attribution is regularly needed.