Find bundle bloat and replace it with vanilla JavaScript
npm install lean-stack-auditor

Find bundle bloat and replace it with vanilla JavaScript.
Now powered by esbuild for accurate, real-world size analysis.
- ๐ฏ Real-Time Analysis: Uses esbuild to bundle your dependencies on-the-fly and calculate their actual minified + gzipped size. No more static guessing.
- ๐ฏ Duplicate Scanner: Detects when you have multiple versions of the same library installed (e.g., lodash v3 and v4).
- ๐งน Bloat Detection: Automatically flags heavy libraries (Moment.js, Lodash, etc.) that can be replaced with native APIs.
- ๐ก Native Alternatives: Provides copy-paste vanilla JS alternatives for common libraries.
- ๐ Cost Calculator: Estimates the bandwidth cost of your bundle bloat.
- ๐ข Node.js Support: Works for both frontend and backend projects (correctly handles node: builtins).
``bash`
npx lean-stack-auditor
Or install globally:
`bash`
npm install -g lean-stack-auditor
Navigate to your project root (where package.json is) and run:
`bash`
npx lean-stack-auditor
`bashVerbose mode (See all dependencies, not just bloat)
lean-stack-auditor --verbose
Example Output
`
๐ LEAN STACK AUDITOR
Find bloat. Ship faster.โ Analysis complete!
๐ฆ Project Analysis:
Project: my-app
Total dependencies: 12
Bundle size (minified+gzipped): 127KB
โ Found 3 Bloated Dependencies:
1. moment.js (72KB) - CRITICAL
Reason: Deprecated and very heavy
Common usage: Date formatting
Alternative: Intl.DateTimeFormat (native)
Potential savings: 72KB
๐ก Vanilla JS Alternative:
const formatted = new Intl.DateTimeFormat('en-US').format(new Date());
2. lodash (25KB) - HIGH
Reason: Most projects use only 3-5 functions
Alternative: Vanilla JS implementations
Potential savings: 25KB
๐ฐ Total Potential Savings: 97KB (76%)
`Configuration (Budget Enforcer)
Create a
lean-stack.config.json to enforce limits in CI:`json
{
"maxBundleSize": "150KB",
"disallowed": ["moment", "lodash"],
"allowDuplicates": false
}
`Run with:
`bash
lean-stack-auditor --check-budget
`
(Exits with code 1 if failed)How It Works
1. Scans
package.json: Identifies your production dependencies.
2. Bundles with esbuild`: Creates a temporary, minified bundle for each dependency to inspect its true weight.MIT