perf(dashmint-lab): strip SDK modulepreload + parallelize fonts#73
perf(dashmint-lab): strip SDK modulepreload + parallelize fonts#73
Conversation
Lighthouse FCP/LCP were 5.1s/5.8s because the ~8MB evo-sdk WASM bundle loaded synchronously at app boot. Switch SessionContext to a dynamic import for createClient + IdentityKeyManager so Vite splits the SDK into its own chunk that fetches after the shell paints. Auto-browse is also deferred via requestAnimationFrame. Split contract.ts: storage helpers (loadStoredContractId, fetchContractOwnerId, ...) move to contractStorage.ts so SessionContext can import them without dragging @dashevo/evo-sdk into the entry chunk. Entry chunk drops from a single ~6MB-gzip bundle to 89KB gzip. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Vite auto-injects <link rel="modulepreload"> for every dynamic-import chunk it discovers. For the ~8MB Evo SDK that defeated the previous deferral commit — the browser raced to fetch the SDK in parallel with the entry chunk, blocking FCP. Filter it out via build.modulePreload.resolveDependencies. Also move the Google Fonts URL out of CSS @import (which serializes the font fetch behind the stylesheet parse) and into <link> tags in index.html with preconnect to fonts.googleapis.com / fonts.gstatic.com, so the font fetch parallelizes with the JS download. Together with the prior dynamic-import commit, FCP drops from 5.1s to 2.7s on a localhost preview Lighthouse run. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Warning Rate limit exceeded
To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThis PR refactors contract persistence logic into a dedicated module, optimizes font loading with preconnection headers, defers browser auto-connect execution using Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~30 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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. Review rate limit: 0/1 reviews remaining, refill in 47 minutes and 25 seconds.Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
example-apps/dashmint-lab/src/dash/contractStorage.ts (1)
33-46: ⚡ Quick winAdd function-level JSDoc for
fetchContractOwnerId.
fetchContractOwnerIdis an exported async SDK operation but currently has no leading JSDoc block.As per coding guidelines: “Dash SDK operations in src/dash/ should export async functions with leading JSDoc blocks, not hooks or wrappers — the SDK call is the function itself.”Proposed update
+/** + * Fetch the data contract and return its owner identity ID. + * + * SDK method: sdk.contracts.fetch(...) + */ export async function fetchContractOwnerId({ sdk, contractId, }: {🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@example-apps/dashmint-lab/src/dash/contractStorage.ts` around lines 33 - 46, Add a function-level JSDoc block immediately above fetchContractOwnerId describing its purpose (fetching and normalizing a contract owner id), parameters (sdk: DashSdk, contractId: string) and the returned value (Promise<string | null>), and include any relevant notes about how it handles contract.toJSON and fallback keys ($ownerId/ownerId). Ensure the JSDoc uses standard tags (`@param`, `@returns`) and clearly states that it returns null when the contract or owner id is not found.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@example-apps/dashmint-lab/src/session/SessionContext.tsx`:
- Around line 43-48: The dynamic import promise cached by sdkModulePromise (in
loadSdkModule) is never cleared on rejection, causing subsequent
connect()/login() attempts to immediately fail; update loadSdkModule so that
when the import promise rejects it clears sdkModulePromise (e.g., attach a
.catch handler that sets sdkModulePromise = undefined and rethrows the error) so
retries can attempt the import again.
---
Nitpick comments:
In `@example-apps/dashmint-lab/src/dash/contractStorage.ts`:
- Around line 33-46: Add a function-level JSDoc block immediately above
fetchContractOwnerId describing its purpose (fetching and normalizing a contract
owner id), parameters (sdk: DashSdk, contractId: string) and the returned value
(Promise<string | null>), and include any relevant notes about how it handles
contract.toJSON and fallback keys ($ownerId/ownerId). Ensure the JSDoc uses
standard tags (`@param`, `@returns`) and clearly states that it returns null when
the contract or owner id is not found.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 4b866c2e-4943-4085-b3ac-5c8d491be53d
📒 Files selected for processing (8)
example-apps/dashmint-lab/index.htmlexample-apps/dashmint-lab/src/App.tsxexample-apps/dashmint-lab/src/dash/contract.tsexample-apps/dashmint-lab/src/dash/contractStorage.tsexample-apps/dashmint-lab/src/session/SessionContext.tsxexample-apps/dashmint-lab/src/styles/globals.cssexample-apps/dashmint-lab/test/SessionContext.test.tsxexample-apps/dashmint-lab/vite.config.ts
If the dynamic import of setupDashClient-core fails (e.g., a transient chunk fetch failure), the rejected promise stayed cached, so every subsequent connect/login attempt would await the same rejected promise and fail immediately. Clear the cache on rejection so retries can re-attempt the import. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Vite auto-injects for every dynamic-import chunk it discovers. For the ~8MB Evo SDK that defeated the previous deferral commit — the browser raced to fetch the SDK in parallel with the entry chunk, blocking FCP. Filter it out via build.modulePreload.resolveDependencies.
Also move the Google Fonts URL out of CSS @import (which serializes the font fetch behind the stylesheet parse) and into tags in index.html with preconnect to fonts.googleapis.com / fonts.gstatic.com, so the font fetch parallelizes with the JS download.
Together with the prior dynamic-import commit, FCP drops from 5.1s to 2.7s on a localhost preview Lighthouse run.
Co-Authored-By: Claude Opus 4.7 (1M context) noreply@anthropic.com
Summary by CodeRabbit
Release Notes