Skip to content

ci: enforce 500 kB gzip per-chunk budget on every PR#34

Closed
adm01-debug wants to merge 1 commit into
mainfrom
claude/workflow-bundle-size-budget
Closed

ci: enforce 500 kB gzip per-chunk budget on every PR#34
adm01-debug wants to merge 1 commit into
mainfrom
claude/workflow-bundle-size-budget

Conversation

@adm01-debug
Copy link
Copy Markdown
Owner

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 touching src/, 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

  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 via React.lazy, manualChunks in vite.config.ts, lucide-react tree-shaking)
  5. Always writes a step summary with the top 16 chunks by raw size — 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 PR #31). Either PR can land first.

Triggers

  • pull_request against main — only when files that affect the bundle change
  • push to main — so main HEAD always has a green budget marker visible

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

YAML validates with python -c 'import yaml; yaml.safe_load(...)'.

Test plan

  • After merge: open a test PR that adds a 600 kB import (e.g., import lodash from 'lodash'); confirm the workflow fails with the expected message
  • Confirm the step summary populates in the PR Actions tab

https://claude.ai/code/session_01KWeDG


Generated by Claude Code

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
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 27, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d0b775a3-9397-4d51-9f04-8ec07e1f5198

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/workflow-bundle-size-budget

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@adm01-debug adm01-debug deleted the claude/workflow-bundle-size-budget branch May 9, 2026 21:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants