Bundle Analysis
- Check build tool:
cat package.json | grep -E '"build"|vite|webpack|rollup|esbuild|next'
- Generate bundle stats:
# Next.js
npx next build --analyze 2>/dev/null
# Vite
npx vite-bundle-visualizer 2>/dev/null
# Generic build size
bun run build 2>&1 | grep -E "\.js|\.css|kB|MB"
- Identify heavy dependencies:
cat package.json | grep -E '"dependencies"' -A 50
# Check bundle phobia for top suspects
- Find optimization opportunities:
- Libraries with lighter alternatives (moment.js → date-fns, lodash → native)
- Packages imported entirely but only a few functions used
- Client-side code that could be server-side
- Missing dynamic imports for routes/heavy components
- Report:
Total bundle: X KB (gzipped: Y KB)
Top 5 contributors:
react-dom 45 KB
chart-library 120 KB ← consider lighter alternative
...
Potential savings: ~Z KB with recommended changes
Use this skill with your AI agent:
Open on Skill Issue to copy, download, or add to your library.
Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.