Registry / observability / rollup-plugin-bundle-stats

rollup-plugin-bundle-stats

JSON →
library4.22.1jsnpmunverified

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.

npm install rollup-plugin-bundle-stats
INSTALL
IMPORT
SIG · ROLLUP-PLUGIN-BUND
R
rollup-plugin-bundle-stats
observabilityjavascriptv4.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 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

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

bundleStats
import { bundleStats } from 'rollup-plugin-bundle-stats'
const bundleStats = require('rollup-plugin-bundle-stats')
ESM-only since v4; named export only; no default export
BundleStatsOptions
import type { BundleStatsOptions } from 'rollup-plugin-bundle-stats'
import { BundleStatsOptions } from 'rollup-plugin-bundle-stats'
TypeScript type import; use `import type` to avoid bundling
bundleStats
const { bundleStats } = await import('rollup-plugin-bundle-stats')
const bundleStats = require('rollup-plugin-bundle-stats')
Dynamic import for CJS compatibility; avoid require in ESM context

Configures Vite plugin to generate HTML bundle stats report with comparison mode, outputting to 'bundle-stats' directory.

// vite.config.js import { defineConfig } from 'vite'; import { bundleStats } from 'rollup-plugin-bundle-stats'; export default defineConfig({ plugins: [ bundleStats({ compare: true, baseline: true, html: true, json: false, outDir: 'bundle-stats', silent: false }) ] });
Debug
Known issues
breakingv4 drops CommonJS support and requires ESM imports; require() will throw
fix
Use ES module syntax: `import { bundleStats } from 'rollup-plugin-bundle-stats'`
affects: >=4.0.0
breakingPeer dependency range changed in v4; incompatible with Rollup <3 or Vite <5
fix
Ensure Rollup ^3 || ^4, Vite ^5 || ^6 || ^7 || ^8
affects: >=4.0.0
gotchaOption `compare` requires a baseline file from a previous build; otherwise report will be empty
fix
Run with `baseline: true` first to generate baseline JSON, then subsequent runs with `compare: true`
affects: >=1.0.0
deprecatedOption `stats` was deprecated in v3 and removed in v4; use `bundleStats()` directly
fix
Remove `stats` option; pass options directly to `bundleStats()`
affects: >=4.0.0
Errors
Common errors & fixes
Error [ERR_REQUIRE_ESM]: require() of ES Module /path/to/rollup-plugin-bundle-stats from ... not supported. Instead change the require of ... to a dynamic import() which is available in all CommonJS modules.
Using require() on v4 ESM-only package in a CommonJS context
fix
Use dynamic import: `const { bundleStats } = await import('rollup-plugin-bundle-stats')` or switch to ESM
TypeError: bundleStats is not a function
Incorrect import: using default import instead of named import
fix
Use named import: `import { bundleStats } from 'rollup-plugin-bundle-stats'`
Error: Cannot find module 'rollup-plugin-bundle-stats'
Missing installation or incorrect module resolution
fix
Install the package: `npm install --dev rollup-plugin-bundle-stats`
Upgrade
Version history
4.22.1latest on npm
Audit
Dependencies
rolluprequiredRequired as peer dependency to run as a Rollup plugin; also needed for Vite and Rolldown integrations
viteoptionalOptional peer dependency for Vite integration
rolldownoptionalOptional peer dependency for Rolldown integration
Agent activity
32 hits · last 30 days
node
28
OpenAI (training)
2
Amazon
1
Resources
rollup-plugin-bundle-stats — npm install rollup-plugin-bundle-stats · libregistry