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

RSC: vite/clientSsr #10238

Merged
merged 105 commits into from
Apr 18, 2024
Merged

RSC: vite/clientSsr #10238

merged 105 commits into from
Apr 18, 2024

Conversation

Tobbe
Copy link
Member

@Tobbe Tobbe commented Mar 16, 2024

This PR introduces a new function called renderFromDist that is ment to be used during SSR. It's supposed to do what renderFromRscServer does during normal browsing.

renderFromDist internally will directly read files out of the dist/rsc/ directory (hence the name). During normal browsing the RSC server would read those files and construct a flight stream using them. During SSR we can directly read them and use renderToReadableStream to build that flight stream. And then use createFromReadableStream instead of createFromFetch to create a React Component from that flight data.

@Tobbe Tobbe force-pushed the tobbe-rsc-vite-ssr branch 3 times, most recently from b1e88c1 to 163d02b Compare March 16, 2024 15:25
@Tobbe Tobbe force-pushed the tobbe-rsc-vite-ssr branch 6 times, most recently from d3a8f4d to 1e8f9cf Compare March 16, 2024 16:05
@Tobbe Tobbe force-pushed the tobbe-rsc-vite-ssr branch 2 times, most recently from 6e1ff6b to d47d3b4 Compare March 16, 2024 16:18
@Tobbe Tobbe added changesets-ok Override the changesets check release:feature This PR introduces a new feature labels Mar 16, 2024
@Tobbe Tobbe added this to the RSC milestone Mar 16, 2024
@Tobbe
Copy link
Member Author

Tobbe commented Apr 17, 2024

Nice work guys! Question re: react and rsdw - is there a reason putting it in the output is better than just externalising?

It's not really about external/noExternal here. It's about only using one version of the library, and one that's built with the right conditions. rsdw will import React, so it's important that it imports the same version of React as we are. If we're pulling rsdw from node_modules (which we would if we didn't get it from the dist folder) we'd also get the node_modules version of React. But the app itself already uses the bundled version of React, so we can't do that, because then we'd have to different Reacts where one isn't initialized properly

@Tobbe Tobbe merged commit eaeb70e into redwoodjs:main Apr 18, 2024
46 checks passed
@Tobbe Tobbe deleted the tobbe-rsc-vite-ssr branch April 18, 2024 14:11
@Josh-Walker-GM Josh-Walker-GM modified the milestones: RSC, v8.0.0 Sep 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changesets-ok Override the changesets check release:feature This PR introduces a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants