In-depth bundle analyzer for webpack (and Rspack) that generates detailed HTML reports on bundle size, assets, modules, and packages, with side-by-side comparison support. Current stable version v4.22.1, actively maintained with frequent releases. Supports webpack 4 & 5, Rspack 0.x & 1.x, and also has plugins for Vite, Rollup, and Rolldown. Key differentiators: it provides not only size analysis but also duplicate package detection, cache invalidation metrics, and historical comparison via RelativeCI. Ships TypeScript types.
npm install bundle-stats-webpack-pluginVerified import paths — ran on the pinned version, not inferred.
Basic webpack configuration using BundleStatsWebpackPlugin with baseline comparison enabled.
Upgrade Node.js to >=14, and webpack to >=4.
Use baseline: true option to enable comparison, and check outDir for output.
Replace `compare: true` with `baseline: true`.
Ensure webpack configuration produces stats (e.g., not using lazy: true in devServer).
Install @rspack/core and use the Rspack import: const { BundleStatsWebpackPlugin } = require('bundle-stats-webpack-plugin'); still works, but ensure webpack is not installed as it might conflict.Run `npm install --save-dev bundle-stats-webpack-plugin`
Use `const { BundleStatsWebpackPlugin } = require('bundle-stats-webpack-plugin');`Upgrade webpack to version 4 or 5.