package-size
Install
yarn global add package-size
Usage
The package is bundled with Webpack.
# get the size of vue bundle
package-size vue
# get the size of react+react-dom bundle
package-size react,react-dom
# get the size of vue react+react-dom preact bundles
package-size vue react,react-dom preact
# get the size of file in current working directory
package-size ./dist/index.js
# or a package in current working directory, explictly using `--cwd` flag
package-size vue --cwd
# or event multiple versions for the same package!
package-size [email protected] [email protected] [email protected]
If the package contains ES6 code, please use --es6
option, otherwise it will throw error (uglifyjs can't parse ES6 code).
API
const getSizes = require('package-size')
getSizes('react,react-dom', options)
.then(data => {
console.log(data)
//=>
{
name: 'react,react-dom',
size: 12023, // in bytes
minified: 2342,
gzipped: 534
}
})
options
es6
Type: boolean
Default: false
Respect module
field in package.json
and compile ES6 to ES5 using buble.
sort
Type: boolean
Default: false
Sort packages in size (from small to large).
cwd
Type: boolean
Default: false
Resolve modules in current working directory instead of a cache folder. Relative path will set cwd
to true
by default.
externals
Type: string
or Array<string|RegExp>
Default: undefined
The package to exclude from bundled file, for example, to get the bundle size of styled-jsx/style
we need to exclude react
:
package-size styled-jsx/style --externals react
Note that if some item in externals
is provided as string, it will be wrapped in a regular expression. For example: react
is treated as /^react$/
Contributing
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request :D
Author
package-size © EGOIST, Released under the MIT License.
Authored and maintained by EGOIST with help from contributors (list).
egoistian.com · GitHub @egoist · Twitter @rem_rin_rin