ci: enforce 500 kB gzip per-chunk budget on every PR#34
Closed
adm01-debug wants to merge 1 commit into
Closed
Conversation
Implements the CI gate suggested in docs/BUNDLE_ANALYSIS.md §'CI gate'
as a standalone workflow that runs on PRs touching src/, package.json,
the lockfile, or the Vite/TS configs. Push events to main also run it
so the main HEAD always has a green budget marker.
## Why a hard 500 kB gate
500 kB gzip is the threshold where mobile (4G) TTI starts to degrade
meaningfully (web.dev — Performance budgets 101). Single chunks above
that threshold are the kind of regression that warrants review before
merge, not a post-merge cleanup task. Hence: hard error, not warn.
## What the job does
1. npm ci + vite build
2. Walks dist/assets/*.js, computes gzip size of each chunk
3. Reports total, largest chunk, count
4. Exits 1 if any chunk > 500 kB gzip and prints fix strategies
(lazy-loading, manual chunks, lucide-react tree-shaking)
5. Always writes a step summary with the top 16 chunks by raw size,
so reviewers see the bundle shape in the PR Checks tab without
rerunning locally
## Self-contained
The check is inlined as a node --input-type=module script so this
workflow doesn't depend on scripts/bundle-analysis.mjs (which lives
in a separate PR — both can land in any order).
## Validation
Tested the inline script against the current dist/:
Total: 2971.9 kB gzip across 294 chunks
Largest chunk: export-vendor = 181.8 kB gzip
✅ all 294 chunks ≤ 500 kB gzip
Contributor
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Summary
Implements the CI gate suggested in
docs/BUNDLE_ANALYSIS.md(PR #31) as a standalone workflow. Enforces a hard upper bound of 500 kB gzip per chunk on every PR touchingsrc/,package.json, the lockfile, or the Vite/TS configs.Why hard 500 kB
500 kB gzip is the threshold where 4G mobile TTI starts to degrade meaningfully (web.dev — Performance budgets 101). Single chunks above that are the kind of regression that warrants review before merge, not a post-merge cleanup task. Hence hard error, not warn.
What the job does
npm ci+vite builddist/assets/*.js, computes gzip size of each chunkReact.lazy,manualChunksinvite.config.ts,lucide-reacttree-shaking)Self-contained
The check is inlined as a
node --input-type=modulescript so this workflow doesn't depend onscripts/bundle-analysis.mjs(which lives in PR #31). Either PR can land first.Triggers
pull_requestagainstmain— only when files that affect the bundle changepushtomain— so main HEAD always has a green budget marker visibleValidation
Tested the inline script against the current
dist/:YAML validates with
python -c 'import yaml; yaml.safe_load(...)'.Test plan
import lodash from 'lodash'); confirm the workflow fails with the expected messagehttps://claude.ai/code/session_01KWeDG
Generated by Claude Code