Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(rsc): Make RSAs work in dev #11729

Merged
merged 1 commit into from
Nov 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading