bundle-stats is an in-depth bundle analyzer for webpack, Rspack, Vite, Rollup, and Rolldown that provides detailed reports on bundle size, assets, modules, and packages. It supports comparing multiple builds side-by-side to identify changes, duplicate packages, and new dependencies. Current stable version is 4.22.1, released in April 2025, with active maintenance and frequent updates. Key differentiators include its cross-bundler support via rollup-plugin-webpack-stats, insights like cache invalidation and initial JS/CSS metrics, and a CLI for CI integration. Ships TypeScript types. Requires Node >= 14.
npm install bundle-statsVerified import paths — ran on the pinned version, not inferred.
Shows how to generate webpack stats JSON, run CLI analysis for single/multiple builds, and use the package programmatically in an ESM TypeScript context.
Use default import: `import bundleStats from 'bundle-stats'`.
Import from 'bundle-stats/webpack'.
Use `import { rollupPluginBundleStats } from 'bundle-stats/rollup'`.Upgrade Node to >= 14.0.
Pass multiple files: `npx bundle-stats stats1.json stats2.json`.
Run `npm install bundle-stats` and use `import { BundleStatsWebpackPlugin } from 'bundle-stats/webpack'`.Use `import bundleStats from 'bundle-stats'`.
Ensure stats file is generated with `npx webpack --profile --json > stats.json` and exists at the given path.