{"id":21944,"library":"rollup-plugin-bundle-stats","title":"rollup-plugin-bundle-stats","description":"Analyze Rollup, Vite, and Rolldown bundle stats (size, assets, modules, packages) with support for side-by-side comparison between builds. Current stable version is 4.22.1, released under the MIT license. It outputs HTML reports and integrates with RelativeCI for continuous monitoring. Key differentiators include duplicate package detection, cache invalidation metrics, and multi-build comparison. Ships TypeScript types. Requires Node >= 16. Peer dependencies: Rollup ^3 || ^4, Vite ^5 || ^6 || ^7 || ^8, Rolldown ^1.0.0-beta.0. Actively maintained on GitHub with weekly or monthly releases.","status":"active","version":"4.22.1","language":"javascript","source_language":"en","source_url":"https://github.com/relative-ci/bundle-stats","tags":["javascript","rollup","rollup-plugin","vite","vite-plugin","rolldown","rolldown-plugin","bundle-size","bundle-analyzer","typescript"],"install":[{"cmd":"npm install rollup-plugin-bundle-stats","lang":"bash","label":"npm"},{"cmd":"yarn add rollup-plugin-bundle-stats","lang":"bash","label":"yarn"},{"cmd":"pnpm add rollup-plugin-bundle-stats","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required as peer dependency to run as a Rollup plugin; also needed for Vite and Rolldown integrations","package":"rollup","optional":false},{"reason":"Optional peer dependency for Vite integration","package":"vite","optional":true},{"reason":"Optional peer dependency for Rolldown integration","package":"rolldown","optional":true}],"imports":[{"note":"ESM-only since v4; named export only; no default export","wrong":"const bundleStats = require('rollup-plugin-bundle-stats')","symbol":"bundleStats","correct":"import { bundleStats } from 'rollup-plugin-bundle-stats'"},{"note":"TypeScript type import; use `import type` to avoid bundling","wrong":"import { BundleStatsOptions } from 'rollup-plugin-bundle-stats'","symbol":"BundleStatsOptions","correct":"import type { BundleStatsOptions } from 'rollup-plugin-bundle-stats'"},{"note":"Dynamic import for CJS compatibility; avoid require in ESM context","wrong":"const bundleStats = require('rollup-plugin-bundle-stats')","symbol":"bundleStats","correct":"const { bundleStats } = await import('rollup-plugin-bundle-stats')"}],"quickstart":{"code":"// vite.config.js\nimport { defineConfig } from 'vite';\nimport { bundleStats } from 'rollup-plugin-bundle-stats';\n\nexport default defineConfig({\n  plugins: [\n    bundleStats({\n      compare: true,\n      baseline: true,\n      html: true,\n      json: false,\n      outDir: 'bundle-stats',\n      silent: false\n    })\n  ]\n});","lang":"javascript","description":"Configures Vite plugin to generate HTML bundle stats report with comparison mode, outputting to 'bundle-stats' directory."},"warnings":[{"fix":"Use ES module syntax: `import { bundleStats } from 'rollup-plugin-bundle-stats'`","message":"v4 drops CommonJS support and requires ESM imports; require() will throw","severity":"breaking","affected_versions":">=4.0.0"},{"fix":"Ensure Rollup ^3 || ^4, Vite ^5 || ^6 || ^7 || ^8","message":"Peer dependency range changed in v4; incompatible with Rollup <3 or Vite <5","severity":"breaking","affected_versions":">=4.0.0"},{"fix":"Run with `baseline: true` first to generate baseline JSON, then subsequent runs with `compare: true`","message":"Option `compare` requires a baseline file from a previous build; otherwise report will be empty","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Remove `stats` option; pass options directly to `bundleStats()`","message":"Option `stats` was deprecated in v3 and removed in v4; use `bundleStats()` directly","severity":"deprecated","affected_versions":">=4.0.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Use dynamic import: `const { bundleStats } = await import('rollup-plugin-bundle-stats')` or switch to ESM","cause":"Using require() on v4 ESM-only package in a CommonJS context","error":"Error [ERR_REQUIRE_ESM]: require() of ES Module /path/to/rollup-plugin-bundle-stats from ... not supported.\nInstead change the require of ... to a dynamic import() which is available in all CommonJS modules."},{"fix":"Use named import: `import { bundleStats } from 'rollup-plugin-bundle-stats'`","cause":"Incorrect import: using default import instead of named import","error":"TypeError: bundleStats is not a function"},{"fix":"Install the package: `npm install --dev rollup-plugin-bundle-stats`","cause":"Missing installation or incorrect module resolution","error":"Error: Cannot find module 'rollup-plugin-bundle-stats'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}