All Projects → pastelsky → package-build-stats

pastelsky / package-build-stats

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

Programming Languages

javascript
184084 projects - #8 most used programming language
typescript
32286 projects
shell
77523 projects

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('[email protected]')
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
Option Values Default Description
client npm or yarn npm Which client to use to install package for building
limitConcurrency true or false false When using yarn as the client, use the network mutex to limit concurrency
networkConcurrency number false When using yarn as client, limit simultaneous installs to this number.
customImports Array<string> null By default, the default export is used for calculating sizes. Setting this option allows calculation of package stats based on more granular top-level exports.
minifier terser or esbuild terser ESbuild is faster, albeit with marginally larger file sizes
installTimeout number (ms) 30000 Timeout for package install

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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].