package-build-stats is a JavaScript/TypeScript library designed to analyze the build size and performance metrics of npm packages. It simulates a package build process, including installation, minification (with Terser or esbuild), and gzipping, to provide detailed statistics such as gzipped size, uncompressed size, and bundle composition. The library is currently at version 8.2.7 and demonstrates an active release cadence with frequent updates and improvements. A key differentiator is its ability to utilize various package managers like Bun, pnpm, or Yarn for faster installations, and its beta support for analyzing local packages during development. It also allows for granular analysis by specifying custom top-level exports, beyond just the default export, and exposes a comprehensive event queue for monitoring build lifecycle events. This tool is the robust backend engine behind services like Bundlephobia, making it suitable for production use cases requiring accurate package size insights.
npm install package-build-statsVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to import and utilize the `getPackageStats` function with various options, including custom package managers and specific imports, while also showing how to subscribe to lifecycle events for real-time feedback during package analysis.
Upgrade your Node.js installation to v20.0.0+ and npm to v10.0.0+ before using package-build-stats v8 or newer.
Migrate your import statements from 'const { symbol } = require("package-build-stats")' to 'import { symbol } from "package-build-stats"'.Ensure you are using v8.0.1 or a newer version to benefit from the bug fixes addressing these missing dependencies.
Update to `package-build-stats` v8.0.3 or higher, which includes a fix to correctly prioritize ESM exports.
Increase the `installTimeout` option in `getPackageStats` (e.g., `installTimeout: 60000`). For faster installs, consider using `client: 'bun'` or `client: 'pnpm'`.
Change your import from `const { getPackageStats } = require('package-build-stats');` to `import { getPackageStats } from 'package-build-stats';`.Increase the `installTimeout` option in `getPackageStats` (e.g., `{ installTimeout: 90000 }`). Consider using a faster package client like `client: 'bun'` or `client: 'pnpm'`.Ensure `package-build-stats` is updated to at least v8.0.1, which patched these missing dependencies.
Update to `package-build-stats` v8.0.3 or higher. This version includes a fix for resolving ESM exports correctly when 'node' condition is present.
No dependency data recorded yet.