Skip to content

Commit

Permalink
wip: implement hot
Browse files Browse the repository at this point in the history
  • Loading branch information
hi-ogawa committed Apr 8, 2024
1 parent 0aa2703 commit 0d843ff
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions examples/workerd/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,30 @@ export function vitePluginWorkerd(pluginOptions: WorkerdPluginOptions): Plugin {
dev: {
createEnvironment(server, name) {
globalServer = server;
webSocket;

return new DevEnvironment(server, name, {
// TODO
hot: false,
hot: {
name,
close() {},
listen() {},
// cf. createServerHMRChannel
send(...args: any[]) {
let payload: any;
if (typeof args[0] === "string") {
payload = {
type: "custom",
event: args[0],
data: args[1],
};
} else {
payload = args[0];
}
webSocket.send(JSON.stringify(payload));
},
// TODO: for custom event e.g. vite:invalidate
on() {},
off() {},
},
});
},
},
Expand Down

0 comments on commit 0d843ff

Please sign in to comment.