Skip to content

feat: migrate frontend from React 19 to Svelte 5 + SvelteKit#85

Open
droarty wants to merge 3 commits into
mainfrom
issue-82-svelte-migration
Open

feat: migrate frontend from React 19 to Svelte 5 + SvelteKit#85
droarty wants to merge 3 commits into
mainfrom
issue-82-svelte-migration

Conversation

@droarty

@droarty droarty commented Jun 16, 2026

Copy link
Copy Markdown
Owner

Summary

This PR is attempting to replace React with Svelte to see if the size of the output shrinks...


After asking claude to compare outputs from the react version and the svelte version, this is what it came up with:
React wins on total size — barely:

  ┌──────────────────────────────────┬──────────┐
  │                                  │ Total JS │
  ├──────────────────────────────────┼──────────┤
  │ React (esbuild, single bundle)   │ 339 KB   │
  ├──────────────────────────────────┼──────────┤
  │ Svelte (Vite/Rollup, ~48 chunks) │ 340 KB   │
  └──────────────────────────────────┴──────────┘

They're essentially identical — within 1 KB of each other. The difference is that React ships one large file (339 KB), while Svelte code-splits into ~48 small chunks that load lazily per route. In practice Svelte will often send less to the browser on first load because it only downloads the chunks needed for the current page — the full 340 KB is only reached if you visit every route.

The React bundle is also slightly inflated here because it includes react-dom (the full runtime) and several Radix UI components, while Svelte's runtime is much smaller and Vite tree-shook more aggressively.

So I am sitting on this PR for now... we an look into it again down the road.

  • Rename apps/webapps/web-react (React 19 app preserved as reference)
  • Scaffold apps/web as SvelteKit 2 SPA (adapter-static, port 4200, Vite 6)
  • Port all three pure-JS services verbatim (EventManager, documentModelStore, api)
  • Replace AuthContext with a Svelte writable store (auth.ts)
  • Replace React Router v6 with SvelteKit file-based routing (8 page routes)
  • Port all layout components to Svelte 5 runes (no afterUpdate, no <svelte:component>, no <svelte:self>)
  • Implement recursive LayoutNode/LayoutRenderer for workflow-driven UI using dynamic imports + {#await} pattern
  • Replace Radix UI with native Svelte implementations for accordion and tabs
  • Port TreeView using <details>/<summary> native elements
  • Replace useSyncExternalStore with $effect + manual subscription to documentModelStore
  • Build confirmed: 251 modules transformed, adapter-static output clean

Closes #82

Test plan

  • npm run restart:web — dev server starts on :4200 ✅
  • Navigate to /login — form renders, login works, redirects to dashboard
  • Google OAuth flow completes end-to-end
  • User dashboard loads layout from workflow JSON (LayoutRenderer renders components)
  • Chat sends and receives messages via WebSocket
  • Admin page lists users, role update works
  • Settings page saves email/password changes
  • npx nx test api — backend tests still pass

🤖 Generated with Claude Code

droarty and others added 3 commits June 16, 2026 14:56
- Rename apps/web → apps/web-react (preserved as reference)
- Scaffold apps/web as SvelteKit SPA (adapter-static, port 4200)
- Port all services verbatim: EventManager, documentModelStore, api
- Replace AuthContext with Svelte writable store (auth.ts)
- Replace React Router with SvelteKit file-based routes (8 pages)
- Port all layout components to Svelte 5 runes
- Implement recursive LayoutNode/LayoutRenderer for workflow-driven UI
- Replace Radix UI with native Svelte implementations (accordion, tabs)
- Port TreeView to Svelte using <details>/<summary> pattern
- Replace useSyncExternalStore with $effect + subscribeToModel
- Build succeeds: 251 modules transformed, adapter-static output clean

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… project

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.

Migrate frontend from React to Svelte

1 participant