-
-
Notifications
You must be signed in to change notification settings - Fork 98
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
[@vitejs/plugin-react] React 18's bootstrapModules
option incompatible with Vite's React plugin
#14
Comments
It seems to work when I add the |
Do you know what i missed? Because i cant get SSR working with the Production build: https://github.com/Trackhe/Vite-React-SSR-HMR |
Doesn't seem to be working for me unfortunately. The workaround seems to be loading the script as part of the stream. |
I hit this same problem and managed to find a work around. I put together a demo below. Perhaps someone with more knowledge on Vite could derives a proper solution to make React SSR more straight forward with Vite. |
Hi everyone! I currently investigate open issues to work on a new API for the next major. I understand that there is an issue with Can someone provide a small reproduction of the issue? Thanks |
Hello @jplhomer. Please provide a minimal reproduction using a GitHub repository or StackBlitz. Issues marked with |
Describe the bug
React 18 introduces a new
renderToPipeableStream
pattern, which includes options for adding client entrypoints viabootstrapScripts
andbootstrapModules
:Script tags generated from these options include the
async
property. This allows React to progressively hydrate the document as it streams in.Unfortunately, this is incompatible with the React Refresh header added in
@vitejs/plugin-react
. I assume this is because the header code throws an Error if it cannot detect the preamble (which is still loaded eventually, just not asynchronously):It's odd that I cannot reproduce this behavior by simply adding
async
to the script tag in the React starter template: https://stackblitz.com/edit/vitejs-vite-fpvd7t?file=index.htmlBut I can when it's included via
bootstrapModules
: jplhomer/vite-streaming-ssr-demo#3Perhaps this means that the way React is injecting the script makes it execute earlier than it normally does? I'm kind of stumped.
Not sure what the best approach to solving this is! I think it's important that entrypoint scripts can be
async
to support streaming SSR in React 18.Should we to update the injected header to more gracefully wait for the RefreshRuntime to be available?
Reproduction
jplhomer/vite-streaming-ssr-demo#3
System Info
Used Package Manager
yarn
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: