Analysis bundle cost for each export of a package
Analysis bundle cost for each export of a package
Analysis bundle cost for each export of an ESM package
npx export-size [package-name]Calculate local package
npx export-size .Calculate npm package
npx export-size @vueuse/coreMore options
npx export-size --help| Option | Description | Default |
|---|---|---|
--install, -i |
Extra dependencies to install alongside the package | [] |
--external, -x |
Packages to mark as external (excluded from the bundle) | [] |
--output, -o |
Emit the bundled and minified files to export-size-output/ |
false |
--report, -r |
Write a JSON report | false |
--output-file |
Path for the JSON report (implies --report) |
./export-size-report.json |
--bundler, -b |
Bundler to use, one of esbuild, rollup, rolldown |
esbuild |
export-size supports multiple bundlers under the hood to measure each export's cost:
esbuild (default) — fastest, minifies with esbuild's built-in minifierrollup — bundles with Rollup and minifies with terserrolldown — bundles and minifies with Rolldownnpx export-size @vueuse/core --bundler rollup
npx export-size @vueuse/core --bundler rolldownnpm i -D export-size…You can also pass a custom bundler instance instead of a bundler name, by extending the abstract Bundler class exported from export-size:
import { Bundler, getExportsSize } from 'export-size'
class MyBundler extends Bundler {
async start() { /* ... */ }
async stop() { /* ... */ }
async bundle(exportName: string, exportPath: string) {
return { bundled: '...', minified: '...' }
}
}
await getExportsSize({
pkg: '@vueuse/core',
bundler: new MyBundler(dir, external),
})Example output
…This project is part of my Sponsor Program
MIT
No open issues yet, or sync has not completed.