Conversation
patak-cat
commented
Nov 27, 2023
| server.use((req, res, next) => { | ||
| vite.middlewares.handle(req, res, next) | ||
| }) | ||
| parentServer.use(vite.middlewares) |
Member
Author
There was a problem hiding this comment.
This code snippet was wrong, server should be parentServer
Member
Author
|
/ecosystem-ci run |
|
📝 Ran ecosystem CI on
|
patak-cat
commented
Nov 27, 2023
Comment on lines
+960
to
+969
| const middlewares = server.middlewares | ||
| newServer._configServerPort = server._configServerPort | ||
| newServer._currentServerPort = server._currentServerPort | ||
| Object.assign(server, newServer) | ||
|
|
||
| // Keep the same connect instance so app.use(vite.middlewares) works | ||
| // after a restart in middlewareMode (.route is always '/') | ||
| middlewares.stack = newServer.middlewares.stack | ||
| server.middlewares = middlewares | ||
|
|
Member
Author
There was a problem hiding this comment.
For reference while reviewing the PR, this is the only code change in it. See the first commit: 0a9d8fb
bluwy
reviewed
Nov 29, 2023
Member
bluwy
left a comment
There was a problem hiding this comment.
I don't really have a big counter-argument for this, other than it's making a new property magical. If others are fine with this, I'm also good with it.
sapphi-red
approved these changes
Nov 29, 2023
Member
Author
|
We discussed this PR in today's team meeting and decided we should move forward with it. |
4 tasks
7 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Before releasing Vite 5, we decided to update our docs at:
This PR changed the backend integration handling of middlewares from
to
The rationale was that the Vite server instance is already too magical, and we didn't want to make it more magical by preserving the
vite.middlewaresinstance.We've been discussing how to update all the projects using the previous recommendation and it is going to be challenging, there may always be bugs. We could rework the old server middelwares connect
stackto log a warning but in that case, maybe better to just make the previous snippet work properly.This PR rebinds the
.stackof thenewServerto preserve the connect instance. In the end, this doesn't look complex to me. And given that at one point we may offer a non-connect-based API, probably better to avoid disruption if the old snippet is easy to fix internally.What is the purpose of this pull request?