Registry / devops / rollup-plugin-analyzer

rollup-plugin-analyzer

JSON →
library4.0.0jsnpmunverified

Rollup plugin that prints detailed bundle analysis metrics to the console, including bundle size, original size, code reduction percentage, module count, and per-file breakdown with rendered size, original size, relative contribution, and dependents. Version 4.0.0 supports Rollup 2.x/3.x. Outputs formatted tables and optional summary-only view. Useful for CI gating via onAnalysis callback. Differentiators include zero dependencies, optional CI integration, and summaryOnly mode for concise output.

npm install rollup-plugin-analyzer
INSTALL
IMPORT
SIG · ROLLUP-PLUGIN-ANAL
R
rollup-plugin-analyzer
devopsjavascriptv4.0.0
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.

default (analyze)
import analyze from 'rollup-plugin-analyzer'
import { analyze } from 'rollup-plugin-analyzer'
Default export only. Named import will result in undefined.
default (analyze) via require
const analyze = require('rollup-plugin-analyzer')
CJS require style, works in Node.js < 12 or when type: 'commonjs' is set.
onAnalysis callback
import analyze from 'rollup-plugin-analyzer'; analyze({ onAnalysis: ({ bundleSize }) => { /* ... */ } })
import { onAnalysis } from 'rollup-plugin-analyzer'
onAnalysis is an option, not a separate export. Pass it as a property.

Configure rollup-plugin-analyzer with summary-only output, limiting to top 10 modules, filtering out node_modules, and calling onAnalysis callback for custom reporting.

// rollup.config.js import analyze from 'rollup-plugin-analyzer'; export default { input: 'src/index.js', output: { file: 'dist/bundle.js', format: 'cjs' }, plugins: [ analyze({ summaryOnly: true, limit: 10, filter: (module) => !module.includes('node_modules'), onAnalysis: ({ bundleSize, moduleCount }) => { console.log(`Bundle size: ${bundleSize} bytes, modules: ${moduleCount}`); } }) ] };
Debug
Known issues
breakingVersion 4.0.0 drops support for Rollup < 2.x. Ensure you are using Rollup 2 or higher.
fix
Upgrade to Rollup 2.x or later, or pin to rollup-plugin-analyzer@3.x.
affects: >=4.0.0
gotchaThe module counts rendered size (after tree-shaking), not original size. Be aware when comparing numbers.
fix
Read documentation: rendered size is post-tree-shaking; original size is before.
affects: *
deprecatedThe `entry` and `dest` options in the example are for Rollup < 1.x. Modern Rollup uses `input` and `output`.
fix
Use `input` and `output` per Rollup 1.x+ API. Example in README may be outdated.
affects: *
gotchaIf using ESM in Node.js (e.g., type: 'module'), ensure your config file uses .mjs extension or dynamic import for CJS plugins.
fix
Rename config to rollup.config.mjs or use createRequire from 'module'.
affects: *
Errors
Common errors & fixes
Error [ERR_REQUIRE_ESM]: require() of ES Module [...] from [...] not supported.
Node.js trying to require an ESM module when using require() with type: 'module' or .mjs files.
fix
Use import instead of require() in your rollup config, or rename file to .cjs.
TypeError: analyze is not a function
Using named import { analyze } instead of default import.
fix
Use: import analyze from 'rollup-plugin-analyzer' (no braces).
Error: Cannot find module 'rollup-plugin-analyzer'
Package not installed or not in node_modules.
fix
Run: npm install --save-dev rollup-plugin-analyzer
Upgrade
Version history
4.0.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

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