Skip to content

Commit

Permalink
chore: update server hmr connector
Browse files Browse the repository at this point in the history
  • Loading branch information
sheremet-va committed Jan 17, 2024
1 parent 5985b90 commit 68a01aa
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/vite/src/node/ssr/runtime/hmrHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export async function handleHMRUpdate(
switch (payload.type) {
case 'connected':
hmrClient.logger.debug(`[vite] connected.`)
hmrClient.sendBuffer()
hmrClient.messenger.flush()
break
case 'update':
await hmrClient.notifyListeners('vite:beforeUpdate', payload)
Expand Down
8 changes: 6 additions & 2 deletions packages/vite/src/node/ssr/runtime/node/serverHmrConnector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,12 @@ export class ServerHMRConnector implements HMRConnection {
}
}

sendBuffer(buffer: string[]): void {
buffer.forEach((message) => this.emitMessage(message))
isReady(): boolean {
return true
}

send(buffer: string): void {
this.emitMessage(buffer)
}

onUpdate(handler: (payload: HMRPayload) => void): () => void {
Expand Down
1 change: 0 additions & 1 deletion packages/vite/src/shared/hmr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,6 @@ export class HMRClient {
this.dataMap.clear()
this.customListenersMap.clear()
this.ctxToListenersMap.clear()
this.buffer = []
}

// After an HMR update, some modules are no longer imported on the page
Expand Down

0 comments on commit 68a01aa

Please sign in to comment.