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,portconfigs with a different environment.For examples:
vite-plugin-inspectneeds 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).