{"id":19397,"library":"bundle-stats-webpack-plugin","title":"BundleStatsWebpackPlugin","description":"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.","status":"active","version":"4.22.1","language":"javascript","source_language":"en","source_url":"https://github.com/relative-ci/bundle-stats","tags":["javascript","webpack","webpack-plugin","bundle-size","bundle-analyzer","bundle-stats","stats","bundle","size","typescript"],"install":[{"cmd":"npm install bundle-stats-webpack-plugin","lang":"bash","label":"npm"},{"cmd":"yarn add bundle-stats-webpack-plugin","lang":"bash","label":"yarn"},{"cmd":"pnpm add bundle-stats-webpack-plugin","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency; plugin works with webpack 4 or 5","package":"webpack","optional":false},{"reason":"Optional peer dependency for Rspack support (0.x or 1.x)","package":"@rspack/core","optional":true}],"imports":[{"note":"The package exports a named export, not default. Use destructured require. ESM import also works: import { BundleStatsWebpackPlugin } from 'bundle-stats-webpack-plugin';","wrong":"import BundleStatsWebpackPlugin from 'bundle-stats-webpack-plugin';","symbol":"BundleStatsWebpackPlugin","correct":"const { BundleStatsWebpackPlugin } = require('bundle-stats-webpack-plugin');"},{"note":"ESM import must use named import. The package is ESM-compatible since v4.","wrong":"import BundleStatsWebpackPlugin from 'bundle-stats-webpack-plugin';","symbol":"BundleStatsWebpackPlugin (ESM)","correct":"import { BundleStatsWebpackPlugin } from 'bundle-stats-webpack-plugin';"},{"note":"TypeScript types are included. No need for @types/bundle-stats-webpack-plugin.","wrong":null,"symbol":"BundleStatsWebpackPlugin (TypeScript)","correct":"import { BundleStatsWebpackPlugin } from 'bundle-stats-webpack-plugin';"}],"quickstart":{"code":"// webpack.config.js\nconst path = require('path');\nconst { BundleStatsWebpackPlugin } = require('bundle-stats-webpack-plugin');\n\nmodule.exports = {\n  entry: './src/index.js',\n  output: {\n    path: path.resolve(__dirname, 'dist'),\n    filename: 'bundle.js',\n  },\n  plugins: [\n    new BundleStatsWebpackPlugin({\n      baseline: true, // enables comparison with previous build\n      outDir: './bundle-stats',\n    }),\n  ],\n};","lang":"javascript","description":"Basic webpack configuration using BundleStatsWebpackPlugin with baseline comparison enabled."},"warnings":[{"fix":"Upgrade Node.js to >=14, and webpack to >=4.","message":"Plugin v4 requires Node.js >= 14 and webpack 4 or 5 (webpack 3 not supported).","severity":"breaking","affected_versions":">=4.0.0"},{"fix":"Use baseline: true option to enable comparison, and check outDir for output.","message":"The output format changed between v3 and v4: baseline comparison now uses a JSON file instead of inline stats.","severity":"breaking","affected_versions":">=4.0.0"},{"fix":"Replace `compare: true` with `baseline: true`.","message":"Option `compare` is deprecated in v4; use `baseline` instead.","severity":"deprecated","affected_versions":">=4.0.0 <4.22.0"},{"fix":"Ensure webpack configuration produces stats (e.g., not using lazy: true in devServer).","message":"Plugin will fail silently if webpack stats are not generated (e.g., when using webpack-dev-server with lazy mode).","severity":"gotcha","affected_versions":">=4.0.0"},{"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.","message":"When using Rspack, the plugin requires @rspack/core as a peer dependency and must be imported from the same package.","severity":"gotcha","affected_versions":">=4.0.0"}],"env_vars":null,"search_vec":"'0':44 '1':46 '4':41 '5':42 'activ':34 'also':49,66 'analysi':64 'analyz':6,91 'asset':19 'bundl':5,17,87,90,93,96 'bundle-analyz':89 'bundle-s':86 'bundle-stat':92 'bundlestatswebpackplugin':1 'cach':70 'comparison':28,75 'current':30 'depth':4 'detail':13 'detect':69 'differenti':58 'duplic':67 'frequent':37 'generat':12 'histor':74 'html':14 'in-depth':2 'invalid':71 'javascript':81 'key':57 'maintain':35 'metric':72 'modul':20 'packag':22,68 'plugin':51,85 'provid':60 'relativeci':77 'releas':38 'report':15 'rolldown':56 'rollup':54 'rspack':10,43 'ship':78 'side':25,27 'side-by-sid':24 'size':18,63,88,97 'stabl':31 'stat':94,95 'support':29,39 'type':80 'typescript':79,98 'v4.22.1':33 'version':32 'via':76 'vite':53 'webpack':8,40,82,84 'webpack-plugin':83 'x':45,47","created_at":"2026-04-25T11:17:35.684120+00:00","updated_at":"2026-04-25T11:17:35.684120+00:00","problems":[{"fix":"Run `npm install --save-dev bundle-stats-webpack-plugin`","cause":"Package not installed or not in node_modules.","error":"Cannot find module 'bundle-stats-webpack-plugin'"},{"fix":"Use `const { BundleStatsWebpackPlugin } = require('bundle-stats-webpack-plugin');`","cause":"Using default import instead of named import.","error":"TypeError: BundleStatsWebpackPlugin is not a constructor"},{"fix":"Upgrade webpack to version 4 or 5.","cause":"Webpack version is less than 4.","error":"Error: webpack < 4 is not supported"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"bundle-stats","cli_version":null,"type":"library","homepage":"https://relative-ci.com/tools/webpack-bundle-stats","github":"https://github.com/relative-ci/bundle-stats","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/bundle-stats-webpack-plugin","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-17","next_check":"2026-07-24","install_tag":null}}