rollup-plugin-size
raw JSON → 0.3.1 verified Mon Apr 27 auth: no javascript maintenance
Prints gzipped sizes of Rollup bundle assets and tracks changes since last build. Version 0.3.1 is the latest release, with low maintenance. It is a port of Google Chrome Labs' size-plugin for Webpack, providing per-file size comparison and historical tracking via a stored .size-snapshot.json file. Key differentiator: integrates directly into Rollup's output lifecycle.
Common errors
error TypeError: size is not a function ↓
cause Using a named import `{ size }` instead of default import.
fix
Use
import size from 'rollup-plugin-size' (default import). error Error: Cannot find module 'rollup-plugin-size' ↓
cause Package not installed or missing from node_modules.
fix
Run
npm install --save-dev rollup-plugin-size. Warnings
breaking The plugin writes a .size-snapshot.json file in the current directory by default, which may conflict with version control or CI processes. ↓
fix Set the 'filename' option to a custom path or add .size-snapshot.json to .gitignore.
deprecated The 'profile' option has been removed in recent versions. ↓
fix Remove the 'profile' option from plugin configuration.
gotcha The plugin requires the 'rollup' peer dependency to be installed. It will not work without Rollup being present in the project. ↓
fix Install Rollup via `npm install --save-dev rollup`.
gotcha Changes tracking is based on a file system snapshot; if the snapshot is deleted or not committed across environments, comparisons will be incomplete. ↓
fix Commit the .size-snapshot.json file to version control if you want persistent change tracking across builds.
Install
npm install rollup-plugin-size yarn add rollup-plugin-size pnpm add rollup-plugin-size Imports
- size wrong
const { size } = require('rollup-plugin-size')correctimport size from 'rollup-plugin-size' - Plugin (type) wrong
import { Plugin } from 'rollup-plugin-size'correctimport type { Plugin } from 'rollup'; import size from 'rollup-plugin-size'
Quickstart
import size from 'rollup-plugin-size';
export default {
input: 'src/main.js',
output: { dir: 'dist', format: 'esm' },
plugins: [size()]
};