@@ -5,7 +5,7 @@ import colors from 'picocolors'
55import type { Update } from 'types/hmrPayload'
66import type { RollupError } from 'rollup'
77import { CLIENT_DIR } from '../constants'
8- import { createDebugger , normalizePath , unique } from '../utils'
8+ import { createDebugger , normalizePath , unique , wrapId } from '../utils'
99import type { ViteDevServer } from '..'
1010import { isCSSRequest } from '../plugins/css'
1111import { getAffectedGlobModules } from '../plugins/importMetaGlob'
@@ -154,12 +154,12 @@ export function updateModules(
154154 ...[ ...boundaries ] . map ( ( { boundary, acceptedVia } ) => ( {
155155 type : `${ boundary . type } -update` as const ,
156156 timestamp,
157- path : boundary . url ,
157+ path : normalizeHmrUrl ( boundary . url ) ,
158158 explicitImportRequired :
159159 boundary . type === 'js'
160160 ? isExplicitImportRequired ( acceptedVia . url )
161161 : undefined ,
162- acceptedPath : acceptedVia . url
162+ acceptedPath : normalizeHmrUrl ( acceptedVia . url )
163163 } ) )
164164 )
165165 }
@@ -484,6 +484,13 @@ export function lexAcceptedHmrExports(
484484 return urls . size > 0
485485}
486486
487+ export function normalizeHmrUrl ( url : string ) : string {
488+ if ( ! url . startsWith ( '.' ) && ! url . startsWith ( '/' ) ) {
489+ url = wrapId ( url )
490+ }
491+ return url
492+ }
493+
487494function error ( pos : number ) {
488495 const err = new Error (
489496 `import.meta.hot.accept() can only accept string literals or an ` +
0 commit comments