Registry / devops / rollup-plugin-size-snapshot

rollup-plugin-size-snapshot

JSON →
library0.12.0jsnpmunverified

Rollup plugin that generates a .size-snapshot.json file tracking actual, minified, and gzipped bundle sizes. Current stable version v0.12.0 requires rollup >=2 and Node >=10. Key differentiator: also shows treeshaken sizes for es output via both Rollup and Webpack to detect dead code. Supports threshold for CI snapshot matching.

npm install rollup-plugin-size-snapshot
INSTALL
IMPORT
SIG · ROLLUP-PLUGIN-SIZE
R
rollup-plugin-size-snapshot
devopsjavascriptv0.12.0
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
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 18–223 runs
build_error
glibc
node 18–223 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

sizeSnapshot
✓ import { sizeSnapshot } from 'rollup-plugin-size-snapshot'
✗ import sizeSnapshot from 'rollup-plugin-size-snapshot'
This plugin exports a named function; default import does not work.
sizeSnapshot
✓ const { sizeSnapshot } = require('rollup-plugin-size-snapshot')
✗ const sizeSnapshot = require('rollup-plugin-size-snapshot')
CommonJS require must destructure the named export.
types
✓ import type { RollupOptions } from 'rollup'
✗ import { RollupOptions } from 'rollup-plugin-size-snapshot'
This plugin does not export types; they come from Rollup itself.

This code shows the basic usage of the plugin with a Rollup config, outputting an ES bundle and generating a snapshot file.

import { sizeSnapshot } from 'rollup-plugin-size-snapshot'; export default { input: 'src/index.js', output: { file: 'dist/bundle.js', format: 'es' }, plugins: [ sizeSnapshot({ snapshotPath: '.size-snapshot.json', printInfo: true }) ] };
Debug
Known issues
breakingv0.12.0 dropped support for rollup < 2
fix
Upgrade rollup to >=2.0.0
affects: <0.12.0
breakingv0.8.0 upgraded to rollup v1, breaking rollup < 1
fix
Upgrade rollup to >=1.0.0
affects: <0.8.0
gotchaPlace uglify/terser plugins after sizeSnapshot to get correct minified sizes
fix
Order plugins: [sizeSnapshot(), uglify({ toplevel: true })]
affects: >=0.5.0
gotchamatchSnapshot is intended for CI, not local development
fix
Set matchSnapshot: true only in CI environment, not in default config.
affects: >=0.6.0
deprecatedrollup-plugin-uglify is deprecated; use rollup-plugin-terser instead
fix
Replace uglify with terser: import { terser } from 'rollup-plugin-terser'
affects: >=0.5.0
Errors
Common errors & fixes
Error: Cannot find module 'rollup-plugin-size-snapshot'
Package not installed
fix
npm install --save-dev rollup-plugin-size-snapshot
TypeError: sizeSnapshot is not a function
Using default import instead of named import
fix
Change to: import { sizeSnapshot } from 'rollup-plugin-size-snapshot'
Plugin 'size-snapshot': Cannot find module 'terser'
Missing terser dependency when using minification
fix
npm install --save-dev terser or rollup-plugin-terser accordingly
Upgrade
Version history
0.12.0latest on npm
Audit
Dependencies
rolluprequiredpeer dependency, plugin requires rollup >=2.0.0
Agent activity
10 hits · last 30 days
node
8
Amazon
1
Resources
rollup-plugin-size-snapshot — npm install rollup-plugin-size-snapshot · libregistry