Registry / devops / bundle-stats-webpack-plugin

bundle-stats-webpack-plugin

JSON →
library4.22.1jsnpmunverified

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-plugin
INSTALL
IMPORT
SIG · BUNDLE-STATS-WEBPA
B
bundle-stats-webpack-plugin
devopsjavascriptv4.22.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

BundleStatsWebpackPlugin
const { BundleStatsWebpackPlugin } = require('bundle-stats-webpack-plugin');
import BundleStatsWebpackPlugin from 'bundle-stats-webpack-plugin';
The package exports a named export, not default. Use destructured require. ESM import also works: import { BundleStatsWebpackPlugin } from 'bundle-stats-webpack-plugin';
BundleStatsWebpackPlugin (ESM)
import { BundleStatsWebpackPlugin } from 'bundle-stats-webpack-plugin';
import BundleStatsWebpackPlugin from 'bundle-stats-webpack-plugin';
ESM import must use named import. The package is ESM-compatible since v4.
BundleStatsWebpackPlugin (TypeScript)
import { BundleStatsWebpackPlugin } from 'bundle-stats-webpack-plugin';
TypeScript types are included. No need for @types/bundle-stats-webpack-plugin.

Basic webpack configuration using BundleStatsWebpackPlugin with baseline comparison enabled.

// webpack.config.js const path = require('path'); const { BundleStatsWebpackPlugin } = require('bundle-stats-webpack-plugin'); module.exports = { entry: './src/index.js', output: { path: path.resolve(__dirname, 'dist'), filename: 'bundle.js', }, plugins: [ new BundleStatsWebpackPlugin({ baseline: true, // enables comparison with previous build outDir: './bundle-stats', }), ], };
bundle-stats --version
Debug
Known issues
breakingPlugin v4 requires Node.js >= 14 and webpack 4 or 5 (webpack 3 not supported).
fix
Upgrade Node.js to >=14, and webpack to >=4.
affects: >=4.0.0
breakingThe output format changed between v3 and v4: baseline comparison now uses a JSON file instead of inline stats.
fix
Use baseline: true option to enable comparison, and check outDir for output.
affects: >=4.0.0
deprecatedOption `compare` is deprecated in v4; use `baseline` instead.
fix
Replace `compare: true` with `baseline: true`.
affects: >=4.0.0 <4.22.0
gotchaPlugin will fail silently if webpack stats are not generated (e.g., when using webpack-dev-server with lazy mode).
fix
Ensure webpack configuration produces stats (e.g., not using lazy: true in devServer).
affects: >=4.0.0
gotchaWhen using Rspack, the plugin requires @rspack/core as a peer dependency and must be imported from the same package.
fix
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.
affects: >=4.0.0
Errors
Common errors & fixes
Cannot find module 'bundle-stats-webpack-plugin'
Package not installed or not in node_modules.
fix
Run `npm install --save-dev bundle-stats-webpack-plugin`
TypeError: BundleStatsWebpackPlugin is not a constructor
Using default import instead of named import.
fix
Use `const { BundleStatsWebpackPlugin } = require('bundle-stats-webpack-plugin');`
Error: webpack < 4 is not supported
Webpack version is less than 4.
fix
Upgrade webpack to version 4 or 5.
Upgrade
Version history
4.22.1latest on npm
Audit
Dependencies
webpackrequiredPeer dependency; plugin works with webpack 4 or 5
@rspack/coreoptionalOptional peer dependency for Rspack support (0.x or 1.x)
Agent activity
6 hits · last 30 days
node
6
Resources
bundle-stats-webpack-plugin — npm install bundle-stats-webpack-plugin · libregistry