npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

import-cost-enforcer

v0.1.1

Published

CLI to enforce bundle size budgets and prevent bloat in CI/CD.

Readme

import-cost-enforcer

Enforce bundle size budgets and stop accidental bloat in CI/CD. The CLI scans your built assets (raw/gzip/brotli), compares them to a baseline and budgets, prints a clear report, and exits non‑zero on violations.

Install

npm i -D import-cost-enforcer

Quick start

  1. Build your app to dist (or any output dir).
  2. Create an initial baseline from your current main build.
npx import-cost-enforcer \
  --dist dist \
  --write-baseline .cache/baseline.json
  1. In PRs/CI, compare the current build against the baseline and fail on regressions.
npx import-cost-enforcer \
  --dist dist \
  --baseline .cache/baseline.json \
  --metrics gzip,brotli

CLI

npx import-cost-enforcer --dist <dir> [options]
  • --dist <dir>: directory to scan (default: dist)
  • --config <file>: JSON config path (default: import-cost.enforcer.json if present)
  • --baseline <file>: baseline JSON to compare against (created from a previous run)
  • --write-baseline <file>: write the current measurement as a new baseline (only written when this flag is provided)
  • --threshold <n>: percent threshold for total increase (default: 30)
  • --metrics <list>: comma list of raw,gzip,brotli (default: gzip,brotli)
  • --json-out <file>: write a JSON report artifact
  • --ignore <globs>: comma list of file globs to ignore (default includes **/*.map)

Exit codes:

  • 0: no violations
  • 1: violations detected (threshold/budgets)
  • 2: unexpected error

Configuration

Place an optional import-cost.enforcer.json in your repo or point to a custom path via --config.

{
  "distDir": "dist",
  "threshold": { "type": "percent", "limit": 30 },
  "metrics": ["brotli", "gzip"],
  "budgets": [
    { "target": "total", "maxKB": 800, "metric": "brotli" },
    { "target": "file:assets/*.js", "maxKB": 200, "metric": "gzip" }
  ],
  "ignore": ["**/*.map"],
  "report": { "jsonOut": "reports/import-cost.json" },
  "baselineIn": ".cache/baseline.json"
}

Notes:

  • target supports total and file:<glob>.
  • Thresholds are checked per selected metric; any metric exceeding the limit triggers a violation.
  • Baseline writing only occurs with --write-baseline (CLI flag). This prevents accidental overwrites from config.

GitHub Actions example

- name: Build
  run: npm run build

- name: Enforce import costs
  run: |
    npx import-cost-enforcer \
      --dist dist \
      --baseline .cache/baseline.json \
      --metrics gzip,brotli \
      --json-out reports/import-cost.json

To refresh the baseline on main (after an intentional change), run the CLI with --write-baseline and commit/upload the updated baseline file or artifact.

Why this tool?

  • Catch accidental bloat early with a simple, bundler-agnostic check.
  • Enforce both relative regressions (percent threshold) and absolute budgets (per total or file patterns).
  • Human‑readable report + optional JSON artifact for CI.

License

MIT