Your bundle is bloated. This tells you exactly why.
npx bundle-autopsy dist/
You opened webpack-bundle-analyzer. It's a colorful treemap. Cool.
You stare at it for five minutes, squinting at rectangles. You now know moment is big. You knew that already.
bundle-autopsy tells you EXACTLY what to replace and how much you'll save.
BUNDLE-AUTOPSY v1.0.0
Analyzing 3 files
Total bundle: 847.0 KB (3 files, ~12 modules detected)
-- Top Offenders ------------------------------------
# 1 moment + moment-timezone 254 KB (30.0%) ##############..
# 2 lodash 72 KB ( 8.5%) #####...........
# 3 validator 60 KB ( 7.1%) ####............
# 4 react-dom 42 KB ( 5.0%) ###.............
# 5 axios 13 KB ( 1.5%) #...............
-- Lighter Alternatives -----------------------------
moment (67KB) -> date-fns (13KB) save 54 KB
moment-timezone (187KB) -> Intl.DateTimeFormat save 187 KB
lodash (72KB) -> lodash-es (tree-shake) save ~67 KB
validator (60KB) -> zod + native save 50 KB
axios (13KB) -> native fetch save 13 KB
-- Potential Savings --------------------------------
Current: 847.0 KB
After swaps: 476.0 KB
Potential savings: 371.0 KB (43.8% of bundle)
-- Tree-Shake Opportunities -------------------------
> import lodash from 'lodash' -> import { ... } from 'lodash-es'
> import * as utils from './utils' -- import only what you need
# Run without installing (recommended)
npx bundle-autopsy dist/
# Install globally
npm install -g bundle-autopsy
# Install as dev dependency
npm install -D bundle-autopsy| Command | Description |
|---|---|
bundle-autopsy dist/ |
Analyze all JS files in a directory |
bundle-autopsy bundle.js |
Analyze a specific file |
bundle-autopsy . --sourcemap |
Use source maps for precise module-level analysis |
bundle-autopsy . --budget 200 |
Set size budget in KB, exit 1 if exceeded |
bundle-autopsy . --json |
JSON output (for CI pipelines and scripting) |
bundle-autopsy . --top 20 |
Show top 20 offenders (default: 10) |
Fail your build when the bundle gets too big:
# GitHub Actions
- name: Bundle size check
run: npx bundle-autopsy dist/ --budget 500 --json
# package.json scripts
"scripts": {
"build:check": "vite build && bundle-autopsy dist/ --budget 300"
}Exit codes:
0— Analysis complete, budget OK (or no budget set)1— Budget exceeded, or fatal error
For precise, byte-accurate module sizes, build with source maps enabled and use --sourcemap:
Vite:
// vite.config.js
export default { build: { sourcemap: true } }webpack:
// webpack.config.js
module.exports = { devtool: 'source-map' }Rollup:
// rollup.config.js
export default { output: { sourcemap: true } }Then run:
bundle-autopsy dist/ --sourcemapWithout source maps, autopsy uses heuristics — still useful, just less precise.
40+ packages covered. A sample:
| Package | Size | Alternative | Alt Size | Savings |
|---|---|---|---|---|
| moment | 67KB | date-fns | 13KB | 54KB |
| moment-timezone | 187KB | Intl.DateTimeFormat | 0KB | 187KB |
| lodash | 72KB | lodash-es (tree-shake) | ~5KB | 67KB |
| axios | 13KB | native fetch | 0KB | 13KB |
| validator | 60KB | zod + native | ~10KB | 50KB |
| joi | 142KB | zod | ~10KB | 132KB |
| jquery | 87KB | native DOM APIs | 0KB | 87KB |
| uuid | 12KB | crypto.randomUUID() | 0KB | 12KB |
| bluebird | 30KB | native Promise | 0KB | 30KB |
| core-js | 500KB | targeted polyfills | ~20KB | 480KB |
| highlight.js | 1100KB | selective languages | ~20KB | 1080KB |
| request | 49KB | native fetch/undici | 0KB | 49KB |
| chalk | 12KB | picocolors | 1KB | 11KB |
| immutable | 57KB | immer | ~13KB | 44KB |
| crypto-js | 51KB | Web Crypto API | 0KB | 51KB |
webpack-bundle-analyzer shows you the problem.
bundle-autopsy gives you the fix.
| Feature | webpack-bundle-analyzer | bundle-autopsy |
|---|---|---|
| Visualizes module sizes | Yes (treemap) | Yes (terminal bar chart) |
| Suggests replacements | No | Yes, with savings estimates |
| Tree-shake opportunities | No | Yes |
| CI-friendly with exit codes | No | Yes (--budget) |
| JSON output for scripting | No | Yes (--json) |
| Works without config | No (webpack only) | Yes, any bundler |
| Requires a browser | Yes | No |
Works with output from any bundler that produces standard JS:
- webpack (module IDs, CONCATENATED MODULE comments)
- vite (ES module output, rollup-based)
- rollup (module markers, import paths)
- esbuild (chunk comments, module paths)
- parcel (node_modules references)
For best results with any bundler, enable source maps and use --sourcemap.
MIT - Nicholas Ashkar, 2026