6.2.0 • Published 4 years ago

package-build-stats-local v6.2.0

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

Fork

This is a fork of package-build-stats that adds support for building stats locally. When this PR (hopefully) is merged, this repo will no longer be needed.

Installation

npm i package-build-stats-local

Usage (Fork)

const getBuiltPackageStats = require('package-build-stats-local')

getBuiltPackageStats('packageName|pathToLocalPackage', {
  options,
}).then(result => console.log(result))

Options

OptionValuesDescription
client'npm' or 'yarn'Which client to use to install package for building
limitConcurrencytrue or falseWhen using yarn as the client, use the network mutex to limit concurrency
networkConcurrencynumberWhen using yarn as client, limit simultaneous installs to this number.
customImportsArray<string>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.

Testing results using in-built server in development

Commands

To start an local server that builds packages, run -

yarn run start

The server runs at port 3000.

Making requests

To build a package and get it's stats, run a curl request like so -

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

eg.

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

Contributing

Clone the repo, npm install, and run the server. The file you're probably looking for is getPackageStats.js