-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Unstable Vite: support for custom servers #7682
Conversation
|
c0b7dfa
to
ab776d0
Compare
server: { | ||
...viteUserConfig.server, | ||
// when parent compiler runs in middleware mode to support | ||
// custom servers, we don't want the child compiler also | ||
// run in middleware mode as that will cause websocket port conflicts | ||
middlewareMode: false, | ||
}, |
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.
@markdalgleish maybe we just want to unset all server
options for child compiler since we don't want to use it as a server at all?
|
||
return async function requestHandler( | ||
request, | ||
loadContext = {}, | ||
{ criticalCss } = {} | ||
) { | ||
_build = typeof build === "function" ? await build() : build; |
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.
purposefully placing the await
within requestHandler
so that createRequestHandler
doesn't need to change to async
which would be breaking change.
}; | ||
|
||
export const unstable_loadViteServerBuild = async (vite: ViteDevServer) => { | ||
return vite.ssrLoadModule(id("server-entry")); |
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.
note: duplicated "server-entry"
literal from plugin.ts
since creating an abstraction on our virtual modules seemed unnecessary so far. might revisit this.
33a9798
to
4c38ceb
Compare
Windows CI is failing. Going to investigate/resolve this with a Windows VM next week. |
```ts let vite = createViteServer() // assets app.use(vite.middlewares) // ssr app.use('*', createRequestHandler(loadViteServerBuild(vite))) ```
14f5fd3
to
cd4809c
Compare
cd4809c
to
c91dde0
Compare
🤖 Hello there, We just published version Thanks! |
🤖 Hello there, We just published version Thanks! |
Expanded
createRequestHandler
to accept a function forbuild
that acts as a dynamic way to get the latest build during dev. Then added APIs for custom server to delegate asset handling and SSR to Vite in dev:Names prefixed with
unstable_
for nowExample usage
Testing Strategy
Integration tests
TODO
.ts
for vite config