← Back to archive

Repo of the Day

styfle/packagephobia

Published: Dec 13, 2021

Open repository ↗

Summary

Package Phobia is a web app and API that reports the install size of an npm package before you add it to your project, and tracks that size over time. It is written in TypeScript, released under the MIT license, and is used to compare real-world cost between competing packages (for example, express vs micro, webpack vs rollup, eslint vs jslint). The hosted service caches results, so the first request for a package can be slow while subsequent visitors see the data instantly.

What it is useful for

  • Pre-install cost checks: see how much disk space a candidate dependency will use before running npm install locally.
  • Side-by-side comparisons of tools in the same category. The README links curated examples such as tap vs tape, gatsby vs next, chalk vs picocolors, request vs node-fetch, and puppeteer vs chrome-aws-lambda.
  • Tracking bloat over time. The size chart helps surface regressions, and the README lists concrete cases it has flagged, such as TypeScript roughly doubling since v2.0.0 and [email protected] accidentally pulling in around 300 transitive dependencies.
  • Embedding size information in documentation, READMEs, or other tools via the JSON API or a badge/shield.

How engineers can use it

  • Visit https://packagephobia.com and enter a package name to view its install size and the historical chart.
  • Use the result URL pattern shown in the README to share a specific package, e.g. https://packagephobia.com/result?p=tap.
  • Call the JSON API for programmatic use. The README points to API.md for full details and asks API consumers to add themselves to the "API Users" list via pull request.
  • Add a size badge to a project's README to surface install cost to downstream users.
  • Contribute by following the project's CONTRIBUTING.md and CODE_OF_CONDUCT.md. The README does not document local build or run commands itself, so refer to CONTRIBUTING.md for setup steps.

Documented limitations to keep in mind:

  • Reported size can differ from actual on-disk usage because Package Phobia cannot predict how a filesystem allocates blocks, and packages made up of many small files can take more space than the raw byte count suggests.
  • New packages may not yet have a result; the first request triggers a measurement, which can be slow before the data is cached.