1.0.1 • Published 3 years ago

@openbaseio/package-build-stats v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

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.

Contributing

  1. Clone this repo, run yarn install
  2. To make it easier to test changes when develop, you can start an HTTP server that uses REST APIs to report size of packages.

To start the server, run –

yarn dev

The server runs at port 3000.

To build a package and get its build stats, run a curl request like so -

curl 'localhost:3000/size?p=<package-name>'

eg.

curl 'localhost:3000/size?p=react'

To build a package and get stats about exports that are exposed out of the package –

curl 'localhost:3000/exports?p=<package-name>'

To build a package and get stats about size of various exports that are exposed out of the package –

curl 'localhost:3000/export-sizes?p=<package-name>'