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
feat(dev): expose APIs for client-server communication #7437
Conversation
+1, vite-plugin-terminal would also benefit from this feature. About |
|
Yes, probably some events could also be exposed in |
Guess we could discuss the general idea of |
For reference, we talked about the proposal and we are going to move forward with |
Working on the server api |
hot.send
api for client server communication
I'm wondering if the hot.send({ type?, event?, data })
I saw that you already added the 'custom' type in the |
Co-authored-by: patak <matias.capeletto@gmail.com>
Great improvement! I've been thinking of a Vite-based CMS for years and this makes it much more real! |
Description
Vite as a server really opens up a lot of DX improvements we could make. However, currently, it only allows clients to receive updates from the server but not another way around. To let the client communicate with the server, plugins often need to register a custom middleware to handle the messages as HTTP requests. Which requires quite some effort and could break with various
base
,port
configs with a different environment.For examples:
vite-plugin-inspect
needs to send invalidation events from the client:Adding this
import.meta.hot.send()
API allows plugins and libraries to communicate with the server much easier.Additional context
What is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes #123
).