TrySound/rollup-plugin-size-snapshot(opens in a new tab)
Language: JavaScript
Track your library bundles size and its treeshakability with less effort
- stars
- 166
- watchers
- 4
- forks
- 11
- open issues
- 28
- Last updated
- 01/06/2023
Language: JavaScript
Track your library bundles size and its treeshakability with less effort
This plugin provides details about
All of these sizes are important criteria when choosing a library, and they will be stored in the .size-snapshot.json file.
There is also a nice feature for the es output format which provides sizes of treeshaked bundles with both rollup and webpack, so if your library has more than one independent parts, you can track that users will not consume dead code. Such bundles entry point looks like this
// nothing is imported here so nothing should go in user bundle import {} from "library";
import { sizeSnapshot } from "rollup-plugin-size-snapshot"; export default { input: "src/index.js", output: { file: "dist/index.js", format: "es", }, plugins: [sizeSnapshot()], };
If you use uglify or terser plugins, then make sure they are placed after this one.
import { uglify } from "rollup-plugin-uglify"; // or import { terser } from "rollup-plugin-terser"; import { sizeSnapshot } from "rollup-plugin-size-snapshot"; export default { // ... plugins: [sizeSnapshot(), uglify({ toplevel: true })], };
type: string
default: '.size-snapshot.json'
This option allows you to verify that contributors don't forget to build or commit the .size-snapshot.json file. If this is true, the plugin will validate the snapshot against an existing one. Typically, one would define this option's value as true during continuous integration; using it locally is unintended.
type: boolean
default: false
Possible difference between sizes in actual snapshot and generated one.
Note: Make sense only when matchSnapshot is true.
type: number
default: 0
Allows you to disable log to terminal.
type: boolean
default: true
MIT © Bogdan Chadkin