package-build-stats-local

6.2.0 • Public • Published

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.

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

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

Option Values Description
client 'npm' or 'yarn' Which client to use to install package for building
limitConcurrency true or false When using yarn as the client, use the network mutex to limit concurrency
networkConcurrency number When using yarn as client, limit simultaneous installs to this number.
customImports Array<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

/package-build-stats-local/

    Package Sidebar

    Install

    npm i package-build-stats-local

    Weekly Downloads

    11

    Version

    6.2.0

    License

    MIT

    Unpacked Size

    125 kB

    Total Files

    24

    Last publish

    Collaborators

    • cgat