lacspace-size

Bundle size — gzip/brotli, budgets, treemap, PR table.

● Live · v0.2.0npm ↗Source ↗
terminal
npx lacspace-size dist
What it does

Everything, in one command

lacspace-size is a zero-dependency bundle/build-output analyzer. Point it at files, a directory, or globs and it compresses each file with Node's built-in zlib to report raw, gzip and brotli sizes, a per-file table (sorted largest-first with % of total) and a by-extension rollup. Its headline feature is CI gating: --max and repeatable --budget exit non-zero when a budget is breached, and --save-baseline/--baseline plus --max-increase fail a pull request that grows the bundle. Human output is colorized; --json and -f md feed dashboards and PR comments.

Features

What's inside

Raw + gzip + brotli

Every file compressed independently via node:zlib, exactly as a CDN serves it.

Budgets that gate CI

Global --max and repeatable per-pattern --budget, non-zero exit on breach.

Baseline diff

Snapshot a run, then report added/removed/grew/shrank files and total delta/%.

Regression gate

--max-increase <size|%> fails a PR that grows the bundle.

Clean reporting

Sorted table + by-extension rollup, colorized, plus --json and Markdown.

Zero deps, offline

Nothing is uploaded; no key, no telemetry.

CLI + library

A typed dual ESM/CJS library sharing one engine.

Composition breakdown

See where a bundle's bytes go: code vs strings vs comments vs whitespace, largest literals, module split.

Treemap JSON

--breakdown --json emits a nested, treemap-friendly structure ready to visualize.

PR-comment table

-f comment prints a tight Markdown table with a signed Δ-vs-baseline column and a Total row.

Summary line

--summary collapses the whole run into one CI-friendly status line.

Named regression gate

--fail-over <size|%> fails a PR when the bundle grows past a threshold.

Auto .sizerc.json

Commit your size policy once; it's picked up with no --config flag.

How to use

Copy, paste, done

Real commands and snippets — from a one-liner to the typed library.

Analyze a build dir
terminal
npx lacspace-size dist

Raw/gzip/brotli table + by-extension totals.

Enforce budgets in CI
terminal
npx lacspace-size "dist/**/*.js" --max 500kb --budget "*.css:50kb"

Exits non-zero if any budget is exceeded.

Save a baseline
terminal
npx lacspace-size dist --save-baseline .size.json

Commit it on main.

Fail a PR regression
terminal
npx lacspace-size dist --baseline .size.json --max-increase 5%

Fails if the total grew >5%.

Markdown PR comment
terminal
npx lacspace-size dist -f md > size-report.md

Drop into a PR.

Break a bundle down
terminal
npx lacspace-size dist/bundle.js --breakdown

Code/strings/comments/whitespace split + largest strings + module banners.

PR-comment table
terminal
npx lacspace-size dist --baseline .size.json -f comment

Markdown table with a signed Δ column, ready to paste into a PR.

One-line summary
terminal
npx lacspace-size dist --summary

files · raw · gzip · brotli · budgets · Δ — great as a CI step name.

Regression gate
terminal
npx lacspace-size dist --baseline .size.json --fail-over 5%

Exit non-zero if the total grew more than 5%.

Good for

What people build with it

✓ Gate PRs on bundle size in CI

✓ Track dist size over time with a committed baseline

✓ Audit which files/extensions dominate a build

✓ Produce a Markdown size report for review

Start now

Run lacspace-size today

Free, open-source, no API keys. It's a CLI and a typed library.

terminal
npx lacspace-size dist