feat!: appType (spa, mpa, custom), boolean middlewareMode#8452
feat!: appType (spa, mpa, custom), boolean middlewareMode#8452
Conversation
packages/vite/src/node/config.ts
Outdated
| worker: resolvedWorkerOptions, | ||
| spa: config.spa ?? true | ||
| appType: | ||
| config.appType ?? config?.server?.middlewareMode === 'ssr' |
There was a problem hiding this comment.
middlewareMode is a boolean now
There was a problem hiding this comment.
This is for backward compat. We can break it directly for v3 thought
There was a problem hiding this comment.
I think they are only a handful of frameworks out there using middlewareMode: 'ssr' now that it should be safe to break. Otherwise another option is to log a warning, but framework authors would likely fix it right away so that end-users don't see it.
Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com>
Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com>
Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com>
Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com>
Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com>
Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com>
Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com>
Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com>
How about we make only While we keep So that SvelteKit (and others) can still use (Btw. I really like replacing CC @aleclarson. |
I actually like that |
|
Actually, how about a Before: if (process.env.NODE_ENV === 'production') {
app.use(sirv(`./dist/client/`))
} else {
const vite = await import('vite')
viteDevServer = await vite.createServer({
server: { middlewareMode: true },
})
app.use(viteDevServer.middlewares)
}After: if (process.env.NODE_ENV === 'production') {
app.use(sirv(`./dist/client/`))
} else {
app.use((await import('vite')).createDevMiddleware())
}It's low priority and I'm personally fine with the current API. But I can see many to welcome such aesthetic improvement and Vite 3 is a nice opportunity for that. |
Co-authored-by: Shinigami <chrissi92@hotmail.de>
Co-authored-by: Shinigami <chrissi92@hotmail.de>
Co-authored-by: Shinigami <chrissi92@hotmail.de>
That sounds confusing to me. I think it's better if it just always have the same value. I don't mind overriding the default value if needed. The question to me though is what is the better default and I think that generally
It's not a compelling need, but it might be slightly nicer. I wouldn't be opposed to it as a follow-up |
👍 Ok that makes sense. You're right, it's clearer to separate both. Sorry for the noise. As for Anyways, LGTM; green-check-marking this. |
|
I agree with you @brillout, it feels strange to use a |
👍 Although I have a slight preference for |
Co-authored-by: Bjorn Lu <bjornlu.dev@gmail.com>
Co-authored-by: Bjorn Lu <bjornlu.dev@gmail.com>
Co-authored-by: Bjorn Lu <bjornlu.dev@gmail.com>
Co-authored-by: Bjorn Lu <bjornlu.dev@gmail.com>
Description
Close #8438
Context:
previewanddevfor MPA and SSR apps #8217This PR implements:
appType: 'spa' | 'mpa' | 'custom'server.middlewareMode: 'ssr'appType: 'custom'+server.middlewareMode: trueserver.middlewareMode: 'html'appType: 'spa' | 'mpa'+server.middlewareMode: trueserver.middlewareModewas originally abooleanand we extended it to be'ssr' | 'html'once people wanted control over the included middlewares.#8217 introduced a
spa: booleanoption, but we found out while discussing in #8438 that it isn't enough and that there is overlap between this new option and the extensions previously added tomiddlewareModeThis PR reverts
middlewareModeto a boolean, that now only controls if there is a server managed by Vite and has no effect on what middlewares are included. A newappTypeoption allows us to define at a high level the different sets of middlewares (and options like sirvsingle: truein preview).I think that
'custom'is less confusing than'ssr'for the option that removes all the HTML middlewares and leaves the HTML handling to the framework.What is the purpose of this pull request?