bundle-pulse

Pulse · web performance

bundle-pulse

A CI gate for JavaScript and CSS bundle size: budgets on raw, gzip and brotli sizes, and a diff against your base branch.

npm i -D @mrlouiswright/bundle-pulse

Published to GitHub Packages: add @mrlouiswright:registry=https://npm.pkg.github.com to .npmrc first (installing needs a token with read:packages).

What it checks

  • Three sizesraw, gzip (level 9) and brotli (quality 11) for every .js, .mjs, .cjs and .css file; source maps are skipped.
  • Budgetsper-glob budgets on any of the three sizes, total JS and total CSS budgets, and a warning when a file passes 90% of its budget.
  • Base diff--snapshot writes sizes to JSON; --base compares against it and reports files that grew more than --max-growth percent (default 10%, ignoring changes under 1 kB) and new large chunks.
  • Hygieneunminified files, identical files shipped under two names, budgets that match nothing (renamed entries), and large files with no budget.
  • Works with any bundlerVite, webpack, Rollup, esbuild, Parcel, Next.js static output, or plain files.

Quick usage

CLI

npx bundle-pulse dist
npx bundle-pulse dist -b 'assets/index-*.js=60KB' -b 'assets/*.css=brotli:15KB' --total-js 200KB
npx bundle-pulse dist --snapshot bundle-base.json   # on main
npx bundle-pulse dist --base bundle-base.json --max-growth 5 --format markdown

API

import { scan, analyze, normaliseBudgets } from "bundle-pulse";
const files = scan("dist");
const findings = analyze(files, { budgets: normaliseBudgets({ "assets/index-*.js": "60 KB" }) });

Every option is documented in the bundle-pulse docs.

CI / GitHub Action

permissions:
  contents: read
  security-events: write   # only needed for the SARIF upload
jobs:
  bundle-pulse:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
        with: { persist-credentials: false }
      - uses: MrLouisWright/bundle-pulse@v1
        with:
          path: dist
          fail-on: high
          sarif: bundle-pulse.sarif
      - uses: github/codeql-action/upload-sarif@v3
        if: always()
        with: { sarif_file: bundle-pulse.sarif }