-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
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
fix: require serialization for HMRConnection.send
on implementation side
#18186
fix: require serialization for HMRConnection.send
on implementation side
#18186
Conversation
Run & review this pull request in StackBlitz Codeflow. |
Looks good to me! Funny how we missed it 😄 |
*/ | ||
isReady(): boolean | ||
/** | ||
* Send a message to the client. | ||
* Send a message to the server. |
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.
Also I remembered this one was saying the opposite, so updated it as well.
HMRConnection.send
implementationHMRConnection.send
implementation
HMRConnection.send
implementationHMRConnection.send
on implementation side
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.
Thanks for making these changes. Looks great to me!
HMRConnection.send
on implementation sideHMRConnection.send
on implementation side
Description
This is brought up by @jamesopstad (Also thanks for spotting the bug on my
HMRConnection
implementation!).Currently
HMRConnection.send
andHMRConnection.onUpdate
interfaces are unbalanced asHMRConnection.send: (message: string) => void
receives already serializedstring
ofHotPayload
. Custom webSocket based implementation would require something like this:https://github.com/hi-ogawa/vite-environment-examples/blob/edf04cf23fb472a9d085e1a424ae7543164b98f8/packages/workerd/src/worker.ts#L95-L107
This PR changes it to
HMRConnection.send: (payload: HotPayload) => void
, soHMRConnection
implementation will become like below:I think this will make interfaces more uniform since
HotChannel
on server side also assumes (de)serialization to be taken care by implementations. Also in case ofServerHMRConnector / ServerHotChannel
, this removes unnecessary serialization since they can pass payload object directly.