| 1 | import type * as EntrySsr from "./entry.ssr"; |
| 2 | import { fetchServer } from "./entry.rsc"; |
| 3 | |
| 4 | // The distilled Cloudflare worker wrapper expects a `{ fetch }` default export. |
| 5 | // The worker runs in the `rsc` environment and loads the `ssr` environment at |
| 6 | // runtime to render HTML from the RSC payload. |
| 7 | export default { |
| 8 | async fetch(request: Request): Promise<Response> { |
| 9 | const ssr = await import.meta.viteRsc.loadModule<typeof EntrySsr>( |
| 10 | "ssr", |
| 11 | "index", |
| 12 | ); |
| 13 | return ssr.default(request, await fetchServer(request)); |
| 14 | }, |
| 15 | }; |