pbs

package-build-stats

This is the cloud function that powers the core of building, minifying and gzipping of packages in bundlephobia

Showing:

Popularity

Downloads/wk

378

GitHub Stars

60

Maintenance

Last Commit

3mos ago

Contributors

5

Package

Dependencies

49

License

MIT

Type Definitions

Tree-Shakeable

No?

Categories

Readme

This is the function that powers the core of building, minifying and gzipping of packages in bundlephobia.

Usage

const { getPackageStats } = require('package-build-stats')

Building packages from npm

Building the latest stable version
const results = await getPackageStats('moment')
Building a specific version / tag
const results = await getPackageStats('moment@2.24.0')
Building local packages (beta)
const results = await getPackageStats('~/dev/my-npm-package') // must have a package.json

Passing options to the build

const results = await getBuiltPackageStats('moment', options)
Options
OptionValuesDefaultDescription
clientnpm or yarnnpmWhich client to use to install package for building
limitConcurrencytrue or falsefalseWhen using yarn as the client, use the network mutex to limit concurrency
networkConcurrencynumberfalseWhen using yarn as client, limit simultaneous installs to this number.
customImportsArray<string>nullBy default, the default export is used for calculating sizes. Setting this option allows calculation of package stats based on more granular top-level exports.
minifierterser or esbuildterserESbuild is faster, albeit with marginally larger file sizes

Listening to events

package-build-stats emits various lifecycle events when building a package. You can listen to these events by subscribing to the event emitter (based on mitt).

import { eventQueue } from 'package-build-stats'

// Listen to all events
eventQueue.on('*', callback)

// Listen to specific events
eventQueue.on('TASK_PACKAGE_BUILD', callback)

For a list of all events, see this.

Contributing

See contributing guide.

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100