Skip to content

Conversation

hi-ogawa
Copy link
Contributor

@hi-ogawa hi-ogawa commented Apr 29, 2025

Description

I was revising React streaming and also the discussion of whether we should add async: true to preamble script #352.

My conclusion is that it's fine to always add async: true since otherwise inline module script <script type="module">console.log("foo")</script> is always blocked until full html load and React preamble script doesn't need to wait. (For this one, I'll raise a separate PR.)

However, regardless of having async or not, relying on transformIndexHtml for ssr streaming is likely not a good idea because in order to fully utilize streaming feature, bootstrapModules of streaming API is recommended, but then, to avoid race condition of execution order between react hmr injectIntoGlobalHook and bootstrapModules, it's required to have an additional logic around it. In this PR, I added playground test as a demo to show one way to achieve this (which is using virtual client entry as wrapper). It's rather verbose, so maybe not necessary to have it here (and it's more of SSR framework territory), but I can show it as a reference to close the issue at least 🙂

@hi-ogawa hi-ogawa marked this pull request as ready for review April 30, 2025 02:34
Copy link
Member

@ArnaudBarre ArnaudBarre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have zero knowledge of how React works with streaming so I can't provide a good review but it's seems good for me to have an example like this in the repo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use renderToPipeableStream instead of renderToString in ssr-react playground
2 participants