Skip to content

Commit

Permalink
fix(hmr): __HMR_PORT__ should not be 'undefined' (#8761)
Browse files Browse the repository at this point in the history
  • Loading branch information
sapphi-red authored Jun 24, 2022
1 parent cd59ee4 commit 3271266
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/vite/src/client/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import '@vite/env'
declare const __BASE__: string
declare const __HMR_PROTOCOL__: string | null
declare const __HMR_HOSTNAME__: string | null
declare const __HMR_PORT__: string | null
declare const __HMR_PORT__: number | null
declare const __HMR_DIRECT_TARGET__: string
declare const __HMR_BASE__: string
declare const __HMR_TIMEOUT__: number
Expand Down
6 changes: 2 additions & 4 deletions packages/vite/src/node/plugins/clientInjections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,9 @@ export function clientInjectionsPlugin(config: ResolvedConfig): Plugin {

// hmr.clientPort -> hmr.port
// -> (24678 if middleware mode) -> new URL(import.meta.url).port
let port = hmrConfig
? String(hmrConfig.clientPort || hmrConfig.port)
: null
let port = hmrConfig?.clientPort || hmrConfig?.port || null
if (config.server.middlewareMode) {
port ||= '24678'
port ||= 24678
}

const devBase = config.base
Expand Down

0 comments on commit 3271266

Please sign in to comment.