diff --git a/packages/vite/src/node/plugins/importAnalysis.ts b/packages/vite/src/node/plugins/importAnalysis.ts index ab404c285b59f2..b15cef105ba909 100644 --- a/packages/vite/src/node/plugins/importAnalysis.ts +++ b/packages/vite/src/node/plugins/importAnalysis.ts @@ -754,15 +754,11 @@ export function importAnalysisPlugin(config: ResolvedConfig): Plugin { const normalizedAcceptedUrls = new Set() for (const { url, start, end } of acceptedUrls) { let normalized - if (url.startsWith('.')) { + const resolved = await this.resolve(url, importerModule.id || undefined) + normalized = resolved?.id + if (!normalized) { const [resolved] = await moduleGraph.resolveUrl(toAbsoluteUrl(url)) normalized = resolved - } else { - const resolved = await this.resolve( - url, - importerModule.id || undefined, - ) - normalized = resolved?.id || url } normalizedAcceptedUrls.add(normalized) const hmrAccept = normalizeHmrUrl(normalized)