feat(#275): bundle-size report + CI artifact on every PR#277
Merged
Conversation
Add `npm run size-report`: build the production artifact once via the shared `buildArtifact` (byte-for-byte the shipped dist/sql.html) and emit a machine-readable bundle-size-report.json, a human-readable bundle-size-report.md, and the raw esbuild-meta.json. The report records raw/gzip/Brotli sizes for the artifact, JS bundle, and minified CSS; attributes JS output bytes to input modules and npm packages (hand-written src/**, generated src/generated/**, and each external package separately); lists the top-30 modules and entry-point/chunk totals; and, given a base report (--base), appends absolute + percentage deltas. Pure attribution/formatting lives in build/size-report-lib.mjs, unit-tested in tests/unit/size-report.test.js. A new CI `size` job produces the report on every PR — with best-effort deltas vs. the PR base (base commit built in a worktree, tolerant of the tooling not existing on the base) — and uploads it as an artifact. Reporting only: no bundle-size budget fails the build yet. build.mjs is refactored to export `buildArtifact`/`esbuildOptions` (release output unchanged, verified byte-identical) and only runs the release build when invoked as a script — guarded with a realpath comparison so a symlinked checkout can't silently skip it. Closes #275 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XP1KN94N969SVMNFPdVtGg
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
Closes #275.
CI now reports what contributes to the single self-contained
dist/sql.htmlon every PR, so bundle growth is caught early instead of via occasional manual comparisons.npm run size-reportbuilds the production artifact once — through the samebuildArtifactthe release uses, so the measured bytes are byte-for-byte the shippeddist/sql.html— and emits:bundle-size-report.json— machine-readablebundle-size-report.md— human-readableesbuild-meta.json— raw esbuild metafileThe report includes:
src/**, generatedsrc/generated/**, and each external npm package (scoped and unscoped grouped correctly, nested deps attributed to the leaf package)--base)Honesty in the report: percentages are of raw contributed output bytes; gzip/Brotli are measured per whole artifact only, with an explicit note that compression is not additive across modules.
CI: a new
sizejob runs on every PR, best-effort-builds the PR base commit in a worktree to produce base deltas (fully tolerant — the base predates this tooling on the first PR, which just means "no deltas"), and uploads the report + metafile as an artifact. Reporting only — no bundle-size budget fails the build in this issue; thresholds are a follow-up once baseline variance is known.Refactor:
build.mjsnow exportsbuildArtifact/esbuildOptionsand only runs the release build when invoked as a script. Release output is unchanged — verified byte-identical (same sha256 asorigin/main's build) across direct, absolute-path (bundle.sh-style), andASB_VERSIONinvocations. The script-detection guard uses a realpath comparison so a symlinked checkout can't silently skip the release build (found and fixed in self-review).Pure attribution/formatting lives in
build/size-report-lib.mjs, unit-tested intests/unit/size-report.test.js(build tooling sits outside thesrc/**coverage gate, tested via the sametests/unitprecedent asschema-build.test.js).Checklist
npm testpasses (the per-file coverage gate is non-negotiable) — 2915 passingnpm run buildsucceeds (single-filedist/sql.html) — output byte-identical to mainbuild/size-report-lib.mjs, I/O in the runnermetafileis dev-only, pure metadata)CHANGELOG.md([Unreleased]) updated🤖 Generated with Claude Code
https://claude.ai/code/session_01XP1KN94N969SVMNFPdVtGg