Skip to content

test(scripts): guard dashboard chunk size regression - #525

Merged
jo-duchan merged 1 commit into
jo-duchan:mainfrom
Fhatu12:test/dashboard-chunk-size-guard-524
Aug 12, 2026
Merged

jo-duchan merged 1 commit into
jo-duchan:mainfrom
Fhatu12:test/dashboard-chunk-size-guard-524

Conversation

@Fhatu12

@Fhatu12 Fhatu12 commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Closes #524

Extends the dashboard build regression guard added in #520 with a second, independent assertion for emitted JavaScript chunk size.

The existing check protects first-load Brotli bytes, but removing manualChunks lowers that metric while restoring the 541.99 kB application chunk and Vite warning. This adds a raw-size guard so the two failure modes are covered separately.

What changed

  • scan emitted packages/dashboard/dist/assets/*.js files dynamically
  • fail if any JavaScript chunk exceeds 500,000 B raw
  • include the offending chunk name and byte size in the failure message
  • keep the existing 155,000 B first-load Brotli budget unchanged

Validation

Healthy configuration:

  • first-load Brotli: 147,129 B / 155,000 B
  • largest JS chunk: 285,077 B / 500,000 B
  • targeted guard: 2 tests passed

Negative checks:

  • removing manualChunks

    • first-load Brotli guard still passes
    • raw chunk guard fails at 541,990 B as expected
  • restoring the rejected eager UI/forms split

    • existing first-load Brotli guard fails at 159,602 B as expected
    • confirms the two guards protect different regressions

Full validation:

  • pnpm exec vitest run --config scripts/vitest.config.mjs dashboardFirstLoadBudget
  • pnpm test — 180 files passed / 1 skipped; 2370 tests passed / 1 skipped
  • pnpm typecheck
  • pnpm lint
  • git diff --check

The existing unrelated lint warnings remain unchanged.

Scope

Only:

  • scripts/__tests__/dashboardFirstLoadBudget.test.mjs

No production configuration or dependency changes.

Summary by CodeRabbit

  • Tests
    • Added validation to ensure dashboard JavaScript assets stay within a 500,000-byte size limit.
    • Added checks that the dashboard assets directory exists and reports details for oversized chunks.
    • Preserved the existing Brotli-compressed first-load budget validation.

@vercel

vercel Bot commented Aug 11, 2026

Copy link
Copy Markdown

@Fhatu12 is attempting to deploy a commit to the jo-duchan's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Aug 11, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: c6d3b84d-bdbb-485f-a2c7-a21219ad8a22

📥 Commits

Reviewing files that changed from the base of the PR and between 12a3c61 and 543b0bc.

📒 Files selected for processing (1)
  • scripts/__tests__/dashboardFirstLoadBudget.test.mjs

📝 Walkthrough

Walkthrough

The dashboard first-load budget test now checks that emitted JavaScript chunks stay below 500,000 raw bytes. It validates the assets directory and reports oversized chunks with their names and sizes.

Changes

Dashboard budget validation

Layer / File(s) Summary
Raw JavaScript chunk budget
scripts/__tests__/dashboardFirstLoadBudget.test.mjs
The test enumerates dashboard .js assets, applies a 500,000-byte limit, and fails with sorted oversized chunk details. The existing Brotli budget check remains unchanged.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description check ✅ Passed The description clearly explains the raw chunk-size guard, validation results, scope, and linked issue, although it omits the template checklist.
Linked Issues check ✅ Passed The test adds the 500,000-byte JavaScript chunk guard, preserves the Brotli guard, reports offending chunks, and validates both regression cases from issue #524.
Out of Scope Changes check ✅ Passed The changes are limited to the dashboard budget test and directly support the linked issue without production or dependency changes.
Title check ✅ Passed The title clearly identifies the dashboard chunk-size regression guard, which is the primary change in the pull request.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@jo-duchan

Copy link
Copy Markdown
Owner

Ran all three acceptance criteria from #524 against your branch instead of reading them off the diff:

scenario first-load budget raw chunk guard result
current main pass pass 2 passed
manualChunks removed pass fail — index-YWsnsJWL.js: 541990 B caught by the new assertion only
@radix-ui / react-hook-form re-split eagerly fail — 159,621 B pass caught by the existing assertion only

The middle row is really the point of this PR, and it behaves exactly as intended. First-load drops to 145,320 B and comfortably clears the budget, while a 541.99 kB chunk comes back. Neither guard would have caught that on its own, and the third row shows that isn't just an accident of ordering—each one is blind to exactly what the other catches. That's what makes keeping both necessary rather than redundant.

My negative-case numbers match yours to the byte on the removal case and are within 19 B on the eager-split case, which looks like normal source drift between our checkouts rather than any disagreement.

A few things I checked specifically:

  • MAX_RAW_JS_CHUNK_SIZE = 500_000 lines up with Vite's default chunkSizeWarningLimit, so the test fails at the same point the warning appears instead of at an arbitrary nearby value.
  • Walking the emitted assets with readdirSync instead of relying on a hardcoded chunk list means any new oversized chunk gets caught automatically.
  • Throwing when dist/assets is missing instead of treating that as "no oversized chunks." Same discipline as the guard you added in perf(dashboard): split large vendor bundles #520, and exactly the failure mode that would have made this test decorative.
  • The failure message includes both the chunk name and its size, so whoever breaks it knows where to look without reproducing it locally.

CI is green across both Node versions and both build architectures. The only red is the Vercel check, an unrelated authorization issue on this repo.

Nothing to change here. Thanks for turning the follow-up around so quickly, and for checking both negative cases yourself before pushing. That made this a one-round review.

@jo-duchan
jo-duchan merged commit ec46402 into jo-duchan:main Aug 12, 2026
7 checks passed
@Fhatu12

Fhatu12 commented Aug 12, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for merging this one! Nice to close the loop from #520 and get both regression cases covered properly. Appreciate it.

@Fhatu12
Fhatu12 deleted the test/dashboard-chunk-size-guard-524 branch August 12, 2026 08:14
@jo-duchan jo-duchan mentioned this pull request Aug 16, 2026
4 tasks done
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.

test(scripts): first-load budget guard misses manualChunks being removed

2 participants