Skip to content

feat(vite): extract @typeway/vite so app servers shrink to a few lines - #14

Open
k1eu wants to merge 3 commits into
mainfrom
cursor/extract-typeway-vite-ddff
Open

k1eu wants to merge 3 commits into
mainfrom
cursor/extract-typeway-vite-ddff

Conversation

@k1eu

@k1eu k1eu commented Aug 26, 2026

Copy link
Copy Markdown
Owner

Plans 01–03 (integration smoke, TanStack feature coverage, benches) are already on main. The root README’s named next step after those was extracting the host glue so app servers are a few lines, not 50+ of Vite-under-Elysia copied between two apps.

This adds @typeway/vite:

  • viteDev() from @typeway/vite/dev — Vite middlewareMode through @typeway/connect, TanStack SSR via environments.ssr.runner.import() (not ssrLoadModule). Extra Connect middleware (e2e bridge probes) and HMR_PORT are options.
  • viteProd({ handler }) from @typeway/vite/prod — boot-time dist/client manifest as real Elysia routes (including clean URLs for prerendered index.html), then .mount() of the built fetch handler. Missing dist/client fails at boot.

The two entry points are load-bearing. A shared barrel re-export of viteDev pulls vite (and rolldown native bindings) into the prod bun build of dist/app. The prod handler import stays a literal ./dist/server/server.js so that build can inline it. src/server.ts remains the SSR entry name.

Both apps/playground-with-tanstack and apps/e2e-tanstack now compose as .use(backend).use(await viteDev()) / .use(await viteProd({ handler })). The connect package stays the eject hatch.

Tests (local)

  • bun test packages/ — 22 pass (connect + viteProd routing + a bun build guard that the prod entry mentions neither createServer nor rolldown)
  • bun run test:integration — 20 pass (dev + prod, including SSG clean URLs and Better Auth)
  • bun run test:e2e-tanstack — 26 pass (dev + prod)
import { viteDev } from "@typeway/vite/dev";
import { viteProd } from "@typeway/vite/prod";
Open in Web Open in Cursor 

Move the duplicated Vite-under-Elysia host out of both TanStack apps.
viteDev() is middlewareMode through connect with SSR via the environment
runner; viteProd() walks dist/client once and mounts the built handler.
The prod handler import stays a literal path so bun build can inline it.

Co-authored-by: Tomasz Kielar <k1eu@users.noreply.github.com>
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Aug 26, 2026

Copy link
Copy Markdown

Deploying typeway with  Cloudflare Pages  Cloudflare Pages

Latest commit: 44fb5e4
Status: ✅  Deploy successful!
Preview URL: https://0b635be4.typeway.pages.dev
Branch Preview URL: https://cursor-extract-typeway-vite.typeway.pages.dev

View logs

cursoragent and others added 2 commits August 26, 2026 19:35
Bun.file MIME and HEAD body stripping show up on the real socket, not
through Elysia's app.handle(). Unit tests keep the routing contract;
integration covers Content-Type on hashed assets and prerendered HTML.

Co-authored-by: Tomasz Kielar <k1eu@users.noreply.github.com>
Re-exporting viteDev from the package root pulled Vite (and rolldown
native bindings) into dist/app. Prod boots import @typeway/vite/prod;
dev boots import @typeway/vite/dev. A unit test builds the prod entry
and asserts the bundle mentions neither createServer nor rolldown.

Co-authored-by: Tomasz Kielar <k1eu@users.noreply.github.com>
@k1eu
k1eu marked this pull request as ready for review August 26, 2026 19:37
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.

2 participants