Skip to content

perf: lazy-load sentry in auth forms to reduce first-load JS (#951)#954

Merged
sw-factory-automations merged 1 commit intomainfrom
feat/951-auth-bundle-size
May 8, 2026
Merged

perf: lazy-load sentry in auth forms to reduce first-load JS (#951)#954
sw-factory-automations merged 1 commit intomainfrom
feat/951-auth-bundle-size

Conversation

@sw-factory-automations
Copy link
Copy Markdown
Collaborator

Closes #951

What

Lazy-load @/lib/sentry in auth form components to keep the sentry error classification module (~22kB source) out of the initial page JS for auth routes.

How

Replaced static import { captureSupabaseError } from "@/lib/sentry" with dynamic import("@/lib/sentry").then(...) in three files:

  • forgot-password-form.tsx — only loads sentry when resetPasswordForEmail fails
  • reset-password-form.tsx — only loads sentry when updateUser fails
  • oauth-buttons.tsx — already dynamically imported itself, but its static sentry import was pulling the module into the dynamic chunk

This follows the same lazy-loading pattern used by @/lib/capture.ts and @/lib/toast.ts.

Updated oauth-buttons.test.tsx to wrap the captureSupabaseError assertion inside waitFor since the dynamic import makes the call asynchronous.

Bundle sizes (gzipped first-load JS)

Route Before After Budget
/sign-in 186.9 kB 186.9 kB 200 kB ✅
/sign-up 187.0 kB 187.0 kB 200 kB ✅
/forgot-password 188.1 kB 186.6 kB 200 kB ✅
/reset-password 188.0 kB 186.6 kB 200 kB ✅

The framework baseline (Next.js + React runtime shared by all routes) accounts for ~160 kB. The remaining ~27 kB is auth-specific UI components and form code.

Testing

  • pnpm lint — 0 errors
  • pnpm typecheck — passes
  • pnpm test — 133 files, 1818 tests passed
  • Auth E2E (auth.spec.ts, password-reset.spec.ts, public-routes.spec.ts) — 36 tests passed
  • pnpm build — all auth routes under 200 kB budget

@vercel
Copy link
Copy Markdown

vercel Bot commented May 8, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
memo Ready Ready Preview, Comment May 8, 2026 2:55am

Request Review

@sw-factory-automations sw-factory-automations merged commit 62e1137 into main May 8, 2026
6 checks passed
@sw-factory-automations sw-factory-automations deleted the feat/951-auth-bundle-size branch May 8, 2026 03:03
@sw-factory-automations
Copy link
Copy Markdown
Collaborator Author

✅ UI verification passed — design spec compliance confirmed.

All changes are limited to import statements (static → dynamic import()) for @/lib/sentry in error-handling code paths. No JSX, CSS classes, component props, or rendered output were modified. No design spec checks are applicable.

@sw-factory-automations
Copy link
Copy Markdown
Collaborator Author

✅ Post-merge verification passed.

E2E tests (auth suite against live site): 36/36 passed — auth.spec.ts, password-reset.spec.ts, public-routes.spec.ts

Ad-hoc smoke tests:

  • ✅ Landing page — loads, has title
  • /sign-in — renders email input
  • /api/health — returns healthy status
  • ✅ Authenticated login flow — sign-in redirects to workspace
  • ✅ No console errors (unauthenticated or authenticated)

Skipped:

  • /dashboard (route does not exist — 404)
  • Editor navigation (no page buttons found in test workspace)

No interaction smoke test needed — this is a perf: PR (lazy-load change), not a feat: PR.

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.

perf: reduce first-load JS on auth pages below 200kB budget

1 participant