feat: implement bundle size budget enforcement for client app#749
Merged
Conversation
- Added `@next/bundle-analyzer` to devDependencies and integrated it into `next.config.mjs` for analyzing bundle sizes. - Created `client/bundle-size.json` to define size budgets for total, shared, per-route, and per-chunk JS sizes. - Developed `client/scripts/check-bundle-size.js` to measure actual bundle sizes against defined budgets and report violations. - Updated CI workflow to enforce bundle size checks on PRs to `main` and `develop`. - Added unit tests for the bundle size checking logic in `client/__tests__/lib/check-bundle-size.test.ts`. - Documented the bundle size budget enforcement process in `client/docs/TEST_INFRASTRUCTURE.md`. - Created JSON schema for bundle size configuration in `client/bundle-size.schema.json`.
|
@somotochukwu-dev Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
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.
Tighten bundle-size budgets for the client app
Closes #697
Summary
Replaces the broken, rudimentary bundle-size CI (pnpm-based
du -skmeasurement) with route-level and chunk-level budget enforcement for the client app.Changes
New files:
client/bundle-size.json— Budget definitions: total JS (800 KB), shared chunks (400 KB), per-route limits (150–350 KB), per-chunk limit (200 KB)client/bundle-size.schema.json— JSON Schema for IDE supportclient/scripts/check-bundle-size.js— Reads Next.js build manifest, resolves per-route JS chunks, measures actual file sizes, and compares against budgets. Exits 1 on violations. Supports--jsonand--root=flagsclient/__tests__/lib/check-bundle-size.test.ts— 19 unit tests covering core logicModified files:
client/package.json— Added@next/bundle-analyzerdevDep +check-bundle-sizenpm scriptclient/next.config.mjs— Conditionally wraps config with bundle analyzer whenANALYZE=true.github/workflows/bundle-size.yml— Rewrote to: build fromclient/withnpm ci, run check script, post per-route PR comment, fail CI on violationsclient/docs/TEST_INFRASTRUCTURE.md— Added bundle-size workflow docsdocs/repo-issue-backlog-2026-05.md— Added issue [P2] Tighten bundle-size budgets for the client app #697 resolution notesTesting
npm run check-bundle-sizeruns the checkerANALYZE=true npm run build && node scripts/check-bundle-size.jsruns full check locally__tests__/lib/check-bundle-size.test.ts)CI Behavior
main/develop: build withANALYZE=true, enforce budgets, post detailed comment with per-route breakdownbundle-size.jsonin a separate commit)