Registry / devops / rollup-plugin-stats

rollup-plugin-stats

JSON →
library2.1.1jsnpmunverified

A Vite/Rolldown/Rollup plugin that generates a bundle stats JSON file (stats.json) containing detailed information about assets, chunks, and modules. Current stable version is 2.1.1. The plugin is actively maintained, with regular releases (multiple per month). Key differentiators: works across Vite (v5–v8), Rolldown (v1), and Rollup (v3–v4); supports selective asset/module inclusion/exclusion; integrates with RelativeCI and bundle-stats ecosystem for further analysis. Requires Node >=18.

npm install rollup-plugin-stats
INSTALL
IMPORT
SIG · ROLLUP-PLUGIN-STAT
R
rollup-plugin-stats
devopsjavascriptv2.1.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.

pluginStats (default)
import pluginStats from 'rollup-plugin-stats'
const pluginStats = require('rollup-plugin-stats').default
Since v2.0.0, the module provides both ESM and CJS exports; default import works directly. For CommonJS, use require('rollup-plugin-stats') (no .default) as it correctly resolves the module.exports.
PluginStatsOptions
import { PluginStatsOptions } from 'rollup-plugin-stats'
TypeScript type exported since v2.1.1
Stats
import type { Stats } from 'rollup-plugin-stats'
import { Stats } from 'rollup-plugin-stats'
The Stats interface is a type only; import it with `import type` to avoid runtime issues.

Shows the minimal Vite config to generate bundle stats JSON. Plugin is added last, output goes to stats.json.

import pluginStats from 'rollup-plugin-stats'; import { defineConfig } from 'vite'; export default defineConfig({ plugins: [ pluginStats({ fileName: 'stats.json', stats: { source: false, map: false } }) ] });
Debug
Known issues
breakingv2.0.0 changed default export: previously required require().default, now require() returns the function directly.
fix
Use `import pluginStats from 'rollup-plugin-stats'` or `const pluginStats = require('rollup-plugin-stats')` (no .default).
affects: >=2.0.0
gotchaPlugin must be added as the last plugin in the plugins array to capture all build output correctly.
fix
Place pluginStats() after all other plugins in the plugins array.
affects: >=1.0.0
deprecatedv1.x CommonJS usage with require('rollup-plugin-stats').default is deprecated since v2.0.0; will be removed in future major.
fix
Use `const pluginStats = require('rollup-plugin-stats')` directly.
affects: >=2.0.0
gotchaThe stats.json file is written by default with `fs.write` which may overwrite existing files without warning.
fix
Either back up existing stats.json or use a custom `write` option to handle overwriting.
affects: >=1.0.0
gotchaSetting `stats.source: true` includes full source code in the output, potentially increasing file size significantly and exposing source code.
fix
Only enable `stats.source` if required for analysis; avoid in production CI artifacts.
affects: >=1.0.0
Errors
Common errors & fixes
Error [ERR_REQUIRE_ESM]: require() of ES Module /path/to/node_modules/rollup-plugin-stats/dist/index.mjs not supported.
Using CommonJS require() on an ESM-only version before v2.0.0.
fix
Upgrade to v2.0.0+ or use dynamic import: `const pluginStats = (await import('rollup-plugin-stats')).default`.
TypeError: pluginStats is not a function
Using `require('rollup-plugin-stats').default` on v2.0.0+ where the module.exports is already the function.
fix
Use `const pluginStats = require('rollup-plugin-stats')` (no .default) for CommonJS.
The stats file is empty or missing assets.
Plugin not placed as the last plugin in the plugins array.
fix
Move pluginStats() to the end of the plugins array.
Cannot find module 'rollup-plugin-stats' or its corresponding type declarations.
Missing dev dependency or TypeScript not configured to resolve types.
fix
Install with `npm install --save-dev rollup-plugin-stats` and ensure tsconfig includes `node_modules` or has `moduleResolution: 'node'` or 'bundler'.
Upgrade
Version history
2.1.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
10 hits · last 30 days
node
8
Resources
rollup-plugin-stats — npm install rollup-plugin-stats · libregistry