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-snapshotVerified import paths — ran on the pinned version, not inferred.
This code shows the basic usage of the plugin with a Rollup config, outputting an ES bundle and generating a snapshot file.
Upgrade rollup to >=2.0.0
Upgrade rollup to >=1.0.0
Order plugins: [sizeSnapshot(), uglify({ toplevel: true })]Set matchSnapshot: true only in CI environment, not in default config.
Replace uglify with terser: import { terser } from 'rollup-plugin-terser'npm install --save-dev rollup-plugin-size-snapshot
Change to: import { sizeSnapshot } from 'rollup-plugin-size-snapshot'npm install --save-dev terser or rollup-plugin-terser accordingly