Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/TrySound/rollup-plugin-size-snapshot
Track your library bundles size and its treeshakability with less effort
https://github.com/TrySound/rollup-plugin-size-snapshot
Last synced: about 1 month ago
JSON representation
Track your library bundles size and its treeshakability with less effort
- Host: GitHub
- URL: https://github.com/TrySound/rollup-plugin-size-snapshot
- Owner: TrySound
- License: mit
- Created: 2018-03-20T11:05:06.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-01-06T01:51:42.000Z (almost 2 years ago)
- Last Synced: 2024-05-14T14:41:43.926Z (7 months ago)
- Language: JavaScript
- Homepage:
- Size: 1.17 MB
- Stars: 162
- Watchers: 5
- Forks: 14
- Open Issues: 28
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome - size-snapshot - Track bundle size and treeshakability with ease. (Plugins / All-Purpose Awesome)
README
# rollup-plugin-size-snapshot [![Build Status][travis-img]][travis]
[travis-img]: https://travis-ci.org/TrySound/rollup-plugin-size-snapshot.svg
[travis]: https://travis-ci.org/TrySound/rollup-plugin-size-snapshotThis plugin provides details about
- actual bundle size (bundler parsing size)
- minified bundle size (browser parsing size)
- gzipped bundle size (download size)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
```js
// nothing is imported here so nothing should go in user bundle
import {} from "library";
```## Why bundle with rollup
- internals are hidden so you shouldn't worry that user reuses your frequently updated modules
- faster user bundling if library has a lot of modules
- predictable and more efficient scope hoisting and as a result more predictable size
- easier to work without sourcemaps with vendors since development bundlers add a lot of unreadable stuff in module definition## Usage
```js
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.
```js
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 })],
};
```## Options
### snapshotPath
type: `string`
default: `'.size-snapshot.json'`### matchSnapshot
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](https://github.com/TrySound/rollup-plugin-size-snapshot/issues/33).
type: `boolean`
default: `false`### threshold
Possible difference between sizes in actual snapshot and generated one.
Note: Make sense only when `matchSnapshot` is `true`.
type: `number`
default: `0`### printInfo
Allows you to disable log to terminal.
type: `boolean`
default: `true`# License
MIT © [Bogdan Chadkin](mailto:[email protected])