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

Decouple ssr context and rendering? #1314

Closed
CyberAP opened this issue Jun 7, 2020 · 1 comment
Closed

Decouple ssr context and rendering? #1314

CyberAP opened this issue Jun 7, 2020 · 1 comment

Comments

@CyberAP
Copy link
Contributor

CyberAP commented Jun 7, 2020

What problem does this feature solve?

Current server rendering is a bit limiting and difficult to extend because it does many things at once.
It creates a full VNode tree for an input, resolves teleports and returns a string.
In order to extend it (for example to await on special hook) you'll have to duplicate all that logic in your custom renderer.
Maybe it'll be beneficial to split resolving VNodes and rendering into separate actions?
This would also resolve an issue with runtime ssr helpers and renderToStream and allow both renderToStream and renderToString utilize the same buffer, resulting in a simpler code (rendering is bound to buffer constructor in renderToStream pull request).

What does the proposed API look like?

const ssrContext = getSSRcontext(input)
const { buffer } = ssrContext // async buffer, an array of nested buffers of strings and promises
const stream = bufferToStream(buffer)
const string = await bufferToString(buffer)

await resolveBuffer(buffer) // wait for VNode and Teleports to become ready
ssrContext.vnode // collect extra data from nodes
ssrContext.teleports // decide how to deal with teleports

Or alternatively pass an entire context for rendering to automatically resolve teleports:

const ssrContext = getSSRcontext(input)
const stream = contextToStream(ssrContext)
const string = await contextToString(ssrContext)
@CyberAP CyberAP closed this as completed Jun 7, 2020
@CyberAP CyberAP reopened this Jun 7, 2020
@yyx990803
Copy link
Member

This seems to have been resolved by #1197

@github-actions github-actions bot locked and limited conversation to collaborators Nov 10, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants