Skip to content

Commit

Permalink
CR
Browse files Browse the repository at this point in the history
  • Loading branch information
ArnaudBarre committed May 23, 2024
1 parent 7df24bc commit 0e6b6c1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
12 changes: 6 additions & 6 deletions packages/vite/src/node/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -401,12 +401,12 @@ export interface ResolvedServerUrls {
export function createServer(
inlineConfig: InlineConfig = {},
): Promise<ViteDevServer> {
return _createServer(inlineConfig, { wsListen: true })
return _createServer(inlineConfig, { hotListen: true })
}

export async function _createServer(
inlineConfig: InlineConfig = {},
options: { wsListen: boolean },
options: { hotListen: boolean },
): Promise<ViteDevServer> {
const config = await resolveConfig(inlineConfig, 'serve')

Expand Down Expand Up @@ -945,7 +945,7 @@ export async function _createServer(
httpServer.listen = (async (port: number, ...args: any[]) => {
try {
// ensure ws server started
ws.listen()
Object.values(environments).forEach((e) => e.hot.listen())
await initServer()
} catch (e) {
httpServer.emit('error', e)
Expand All @@ -954,8 +954,8 @@ export async function _createServer(
return listen(port, ...args)
}) as any
} else {
if (options.wsListen) {
ws.listen()
if (options.hotListen) {
Object.values(environments).forEach((e) => e.hot.listen())
}
await initServer()
}
Expand Down Expand Up @@ -1128,7 +1128,7 @@ async function restartServer(server: ViteDevServer) {
let newServer: ViteDevServer | null = null
try {
// delay ws server listen
newServer = await _createServer(inlineConfig, { wsListen: false })
newServer = await _createServer(inlineConfig, { hotListen: false })
} catch (err: any) {
server.config.logger.error(err.message, {
timestamp: true,
Expand Down
2 changes: 2 additions & 0 deletions packages/vite/types/hotPayload.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/** @deprecated use HotPayload */
export type HMRPayload = HotPayload
export type HotPayload =
| ConnectedPayload
| UpdatePayload
Expand Down

0 comments on commit 0e6b6c1

Please sign in to comment.