Skip to content

Commit

Permalink
always use resolve id and fallback to url
Browse files Browse the repository at this point in the history
  • Loading branch information
patricklx committed Dec 6, 2024
1 parent 6f18c1b commit c7d118a
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions packages/vite/src/node/plugins/importAnalysis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -754,15 +754,14 @@ export function importAnalysisPlugin(config: ResolvedConfig): Plugin {
const normalizedAcceptedUrls = new Set<string>()
for (const { url, start, end } of acceptedUrls) {
let normalized
if (url.startsWith('.')) {
const resolved = await this.resolve(url, importerModule.id || undefined)
if (resolved?.id) {
const mod = moduleGraph.getModuleById(resolved.id)
normalized = mod?.url
}
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)
Expand Down

0 comments on commit c7d118a

Please sign in to comment.