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

chore(render): Use renderToPipeableStream instead of renderToStaticNodeStream #1443

Merged
merged 8 commits into from
May 13, 2024

Conversation

gabrielmfern
Copy link
Collaborator

@gabrielmfern gabrielmfern commented Apr 30, 2024

This is needed since React 18.3 deprecated renderToStaticNodeStream so they are going to remove it on React 19 meaning we need to move out of this function into something else.

From the actual warning given by react-dom ̇

Warning: ReactDOMServer.renderToStaticNodeStream() is deprecated. Use ReactDOMServer.renderToPipeableStream() and wait to pipe until the onAllReady callback has been called instead.

This PR does exactly as the warning recommends us to do, calling renderToPipeableStream and
piping the stream once the onAllReady callback is called. Only piping it once onAllReady
is called, makes it so that stuff like Suspense boundaries don't leave out trailing <script> tags.

Copy link

vercel bot commented Apr 30, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-email ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 9, 2024 2:18pm
react-email-demo ❌ Failed (Inspect) May 9, 2024 2:18pm

@gabrielmfern gabrielmfern merged commit 992cad0 into canary May 13, 2024
8 of 9 checks passed
@gabrielmfern gabrielmfern deleted the chore/update-render-async-to-use-pipeable-stream branch May 13, 2024 13:12
gabrielmfern added a commit to joscha0/react-email that referenced this pull request May 13, 2024
}
const {
default: { Writable },
} = await import("node:stream");
Copy link
Contributor

Choose a reason for hiding this comment

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

When this gets compiled to a require statement by the build, I get the following in my native ESM project:

Error: Dynamic require of "stream" is not supported

All server-side JavaScript environment support dynamic imports. Could we not transpile the dynamic import?

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

Successfully merging this pull request may close these issues.

3 participants