Skip to content

Commit

Permalink
feat(rsc): Make RSAs work in dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobbe committed Nov 20, 2024
1 parent f1f05ce commit 1a1b7f3
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions packages/vite/src/rsc/rscRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ export async function renderRscToStream(

async function loadServerFile(filePath: string) {
console.log('rscRenderer.ts loadServerFile filePath', filePath)

if (globalThis.__rwjs__vite_rsc_runtime) {
const serverMod =
await globalThis.__rwjs__vite_rsc_runtime.executeUrl(filePath)
return serverMod.default ? serverMod.default : serverMod
}

return import(`file://${filePath}`)
}

Expand Down Expand Up @@ -203,12 +210,10 @@ async function executeRsa(input: RenderInput): Promise<ReadableStream> {
const data = await method(...input.args)
console.log('rscRenderer.ts rsa return data', data)

// TODO (RSC): This is currently duplicated in renderRsc. See further comments
// there. Do we also need to use the importXyz() helper methods here?
const { createElement } = await import('react')
const { renderToReadableStream } = await import(
'react-server-dom-webpack/server.edge'
)
// TODO (RSC): This is currently duplicated in renderRsc. See further
// comments there
const { createElement } = await importRscReact()
const { renderToReadableStream } = await importRsdwServer()

const serverRoutes = await getRoutesComponent()
console.log('rscRenderer.ts executeRsa serverRoutes', serverRoutes)
Expand Down

0 comments on commit 1a1b7f3

Please sign in to comment.