Skip to content

perf(client): code-split routes and reduce vendor preload#57

Merged
flesher merged 1 commit intomainfrom
issue-46
Apr 23, 2026
Merged

perf(client): code-split routes and reduce vendor preload#57
flesher merged 1 commit intomainfrom
issue-46

Conversation

@flesher
Copy link
Copy Markdown
Contributor

@flesher flesher commented Apr 22, 2026

Summary

  • Convert all protoFleet and protoOS routes to React.lazy and add a Suspense boundary in each App component, so each route ships in its own chunk.
  • Tighten manualChunks in vite.config.ts to only force-bucket entry-bundle deps (react, react-router, @bufbuild/@connectrpc); lazy-route deps like recharts, motion, and dnd-kit now land in route or shared chunks instead of being preloaded with the entry.
  • Result: initial JS drops ~43% on protoFleet (567 → 320 KB gz) and ~33% on protoOS (407 → 273 KB gz).

Refs #46

Test plan

  • npm run build produces both bundles without errors
  • Smoke test /, /miners, /groups, /racks, /activity, /settings/*, /auth, /welcome, /fleet-down
  • Smoke test single-miner routes /miners/:id/{hashrate,efficiency,power-usage,temperature,logs,diagnostics,settings/*}
  • No console errors during route transitions; Suspense fallback renders briefly on first visit

🤖 Generated with Claude Code

Convert all protoFleet and protoOS routes to React.lazy with a Suspense
boundary in each App component, and tighten manualChunks in vite.config
to only force-bucket entry-bundle deps so lazy-route deps land in their
own chunks. Cuts initial JS by ~43% on protoFleet (567 → 320 KB gz) and
~33% on protoOS (407 → 273 KB gz).

Refs #46

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings April 22, 2026 23:49
@flesher flesher requested a review from a team as a code owner April 22, 2026 23:49
@github-actions github-actions Bot added javascript Pull requests that update javascript code client labels Apr 22, 2026
@github-actions
Copy link
Copy Markdown

🔐 Codex Security Review

Note: This is an automated security-focused code review generated by Codex.
It should be used as a supplementary check alongside human review.
False positives are possible - use your judgment.

Scope summary

  • Reviewed pull request diff only (a3fbfee34a094472a1e78e21cfa9e626de48e441...88e183e96b7bc66f24469a4ee62cb3a11d88f179, exact PR three-dot diff)
  • Model: gpt-5.4

💡 Click "edited" above to see previous reviews for this PR.


Review Summary

Overall Risk: NONE

Findings

No security, correctness, or reliability findings identified in the reviewed diff.

Notes

  • Scope reviewed strictly from .git/codex-review.diff. The patch is limited to frontend route lazy-loading, Suspense boundaries, and Vite chunk-splitting changes.
  • I verified the newly lazy-loaded route targets resolve to default exports and did not find auth bypasses, token exposure, XSS paths, pool-address changes, or other trust-boundary regressions in the changed hunks.
  • I could not execute a production build or browser smoke test in this read-only environment, so the remaining residual risk is runtime-only chunk-loading behavior that is not statically visible in the patch.

Generated by Codex Security Review |
Triggered by: @flesher |
Review workflow run

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR reduces the initial JavaScript payload for both protoFleet and protoOS by code-splitting route components with React.lazy + Suspense, and by tightening Vite’s manualChunks so only true entry-bundle dependencies are force-bucketed.

Changes:

  • Converted protoFleet and protoOS route components to React.lazy so each route loads as its own chunk.
  • Added Suspense boundaries in both apps’ App components with a shared loading spinner fallback.
  • Updated vite.config.ts chunking rules to avoid preloading non-entry dependencies (e.g., route-only libraries).

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
client/vite.config.ts Restricts forced vendor chunking to core entry deps (React, router, buf/connect), allowing route deps to stay in lazy/shared chunks.
client/src/protoOS/router.tsx Lazifies protoOS route components so single-miner routes don’t inflate protoFleet’s entry bundle.
client/src/protoOS/components/App/App.tsx Adds a Suspense boundary to render a loading fallback while lazy route chunks load.
client/src/protoFleet/router.tsx Lazifies protoFleet route components and keeps route tree structure the same.
client/src/protoFleet/components/App/App.tsx Adds a Suspense boundary to render a loading fallback while lazy route chunks load.

@flesher flesher merged commit 62a7f3e into main Apr 23, 2026
66 checks passed
@flesher flesher deleted the issue-46 branch April 23, 2026 01:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

client javascript Pull requests that update javascript code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants