Registry / devops / rollup-plugin-sizes

rollup-plugin-sizes

JSON →
library1.1.0jsnpmunverified

A Rollup plugin that analyzes bundle composition by showing sizes and percentages for each module and its constituent files. Current stable version 1.1.0 (2024) supports Rollup 2, 3, and 4, and is compatible with Vite. It helps identify bloated libraries by printing a hierarchical breakdown of output chunks, optionally with per-file details. Differentiators: lightweight (only 4 dependencies), simple reporter API, and dual ESM/CJS support. Released under MIT license.

npm install rollup-plugin-sizes
INSTALL
IMPORT
SIG · ROLLUP-PLUGIN-SIZE
R
rollup-plugin-sizes
devopsjavascriptv1.1.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.

sizes
import sizes from 'rollup-plugin-sizes'
const sizes = require('rollup-plugin-sizes')
Package works with both ESM and CJS; require is valid in Node but ESM is preferred for modern projects.
sizes
import sizes from 'rollup-plugin-sizes'
import { sizes } from 'rollup-plugin-sizes'
The plugin exports a default function, not a named export. Named import will result in undefined.
sizes
const sizes = require('rollup-plugin-sizes')
CJS require works for Node.js projects.

Shows how to add the plugin to a Rollup config, enabling per-file breakdown.

import sizes from 'rollup-plugin-sizes'; export default { input: 'src/main.js', output: { dir: 'dist', format: 'esm' }, plugins: [ sizes({ details: true }) ] };
Debug
Known issues
gotchaMust be the last plugin in the Rollup plugin list to capture final bundle sizes.
fix
Place sizes() after all other plugins in the plugins array.
affects: >=1.0.0
gotchaOnly works with Rollup 2.x, 3.x, or 4.x. Not compatible with Rollup 1.x.
fix
Use rollup-plugin-sizes@1.0.0 or later with Rollup >=2.
affects: >=1.0.0
gotchaIf no bundle is generated (e.g., due to errors), the plugin will not output any size information.
fix
Ensure the build completes successfully before expecting output.
affects: >=1.0.0
gotchaThe 'details' option may produce very verbose output for large bundles.
fix
Set details: false (default) to see only top-level module sizes.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module 'rollup-plugin-sizes'
Package not installed in node_modules.
fix
Run 'npm install rollup-plugin-sizes --save-dev'.
TypeError: sizes is not a function
Using named import instead of default import.
fix
Use 'import sizes from 'rollup-plugin-sizes'' instead of '{ sizes }'.
Error: The plugin 'sizes' must be placed after all other plugins.
Plugin order incorrect; sizes must be last to get final sizes.
fix
Move sizes() to the end of the plugins array.
Error: [object Object] is not a function
Likely passing options incorrectly (e.g., no parentheses).
fix
Use 'sizes({ details: true })' with parentheses.
Upgrade
Version history
1.1.0latest on npm
Audit
Dependencies
rolluprequiredPeer dependency required as a plugin for Rollup bundler.
Agent activity
6 hits · last 30 days
node
6
Resources
rollup-plugin-sizes — npm install rollup-plugin-sizes · libregistry