rollup-plugin-filesize
raw JSON → 10.0.0 verified Mon Apr 27 auth: no javascript
A Rollup plugin that displays the size of output files in the CLI, including minified, gzipped, and Brotli sizes. Version 10.0.0 is the latest stable, requiring Node >=16 and Rollup >=4 (ESM-only). It offers customizable output formatting, a reporter API for custom handlers (e.g., badge generation), and experimental size comparisons against previous releases or builds. Differentiates from alternative size plugins with built-in Brotli support and theme-aware display.
Common errors
error Error [ERR_REQUIRE_ESM]: require() of ES Module not supported ↓
cause Package is ESM-only; CommonJS require fails.
fix
Use import syntax instead of require().
error TypeError: filesize is not a function ↓
cause Default import used but named import does not match.
fix
Use import filesize from 'rollup-plugin-filesize'.
error Error: Cannot find module 'rollup-plugin-filesize' ↓
cause Package not installed or incorrect path.
fix
Run npm install rollup-plugin-filesize --save-dev.
Warnings
breaking Version 10 drops CommonJS support; package is ESM-only. ↓
fix Use import syntax and ensure Node >=16.
breaking Version 6 drops terser for minification; minification is optional. ↓
fix If minification is needed, use a separate plugin like @rollup/plugin-terser.
deprecated The 'render' function option is deprecated; use 'reporter' instead. ↓
fix Replace 'render' with 'reporter' option.
gotcha For code-splitting builds, the plugin reports each file individually. ↓
fix Check console output for per-file sizes; aggregate manually if needed.
gotcha Windows compatibility fixed in v8.0.1 for import paths. ↓
fix Use v8.0.1 or later on Windows.
deprecated showBeforeSizes is experimental and may change. ↓
fix Do not rely on it for production use.
Install
npm install rollup-plugin-filesize yarn add rollup-plugin-filesize pnpm add rollup-plugin-filesize Imports
- filesize wrong
const filesize = require('rollup-plugin-filesize');correctimport filesize from 'rollup-plugin-filesize'; - filesize wrong
import filesize from 'rollup-plugin-filesize';correctimport { filesize } from 'rollup-plugin-filesize'; - Plugin wrong
import { Plugin } from 'rollup-plugin-filesize';correctimport type { Plugin } from 'rollup';
Quickstart
import { rollup } from 'rollup';
import filesize from 'rollup-plugin-filesize';
async function build() {
const bundle = await rollup({
input: 'src/index.js',
plugins: [
filesize({
showMinifiedSize: true,
showGzippedSize: true,
showBrotliSize: false,
theme: 'dark'
})
]
});
await bundle.write({ file: 'dist/bundle.js', format: 'es' });
}
build().catch(err => console.error(err));