-
-
Notifications
You must be signed in to change notification settings - Fork 10.7k
Support Vite middleware mode in RSC Framework Mode #14277
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
Support Vite middleware mode in RSC Framework Mode #14277
Conversation
|
? async (req, res) => { | ||
// In dev mode, ensure we load a fresh request handler every request | ||
const rscEntry = await viteDevServer.environments.rsc.runner.import( | ||
"virtual:react-router/unstable_rsc/rsc-entry", | ||
); | ||
return createRequestListener(rscEntry.default)(req, res); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
During dev, currently this does nothing since rsc plugin already includes the same handler in viteDevServer.middlewares
. I noticed that it isn't the case in non-rsc framework mode. Should rsc plugin align with it?
react-router/packages/react-router-dev/vite/plugin.ts
Lines 1623 to 1626 in e495e0e
// Let user servers handle SSR requests in middleware mode, | |
// otherwise the Vite plugin will handle the request | |
if (!viteDevServer.config.server.middlewareMode) { | |
viteDevServer.middlewares.use(async (req, res, next) => { |
(Btw, I noticed there's nothing specific about react router for this custom server setup and I'm thinking to add a same example on rsc plugin vitejs/vite-plugin-react#817)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I just realised this too. I've just pushed an update so we use your built-in dev request handler.
🤖 Hello there, We just published version Thanks! |
🤖 Hello there, We just published version Thanks! |
No description provided.