Package Exports
- size-limit
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (size-limit) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Size Limit
Show how many kilobytes your JS library will add to a user bundle.
You can add this tool to Travis CI and set the limit. If you accidentally add a very big dependency, Size Limit will throw an error.
Usage
Install size-limit:
$ npm install --save-dev size-limitGet current project size:
$ ./node_modules/bin/size-limit
Package size: 8.46 KB
With all dependencies, minifier and gzipped
If project size looks to big run Webpack Bundle Analyzer:
./node_modules/bin/size-limit --whyAdd some bytes to current size to get the limit
by adding npm run script to package.json:
"scripts": {
"test": "jest && eslint .",
+ "size": "size-limit 9KB"
}Add size script to tests:
"scripts": {
- "test": "jest && eslint .",
+ "test": "jest && eslint . && npm run size",
"size": "size-limit 9KB"
}Don’t forget to add Travis CI to your project.
JS API
const getSize = require('size-limit')
const index = path.join(__dirname, 'index.js')
const extra = path.join(__dirname, 'extra.js')
getSize([index, extra]).then(size => {
if (size > 1 * 1024 * 1024) {
console.error('Project become bigger than 1MB')
}
})