Skip to content

Commit 49674b5

Browse files
chenfan0bluwy
andauthoredMar 30, 2023
fix: throws error when plugin tries to resolve ID to external URL (#11731)
Co-authored-by: bluwy <bjornlu.dev@gmail.com>
1 parent 82137d6 commit 49674b5

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed
 

‎packages/vite/src/node/plugins/importAnalysis.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,10 @@ export function importAnalysisPlugin(config: ResolvedConfig): Plugin {
601601
// record for HMR import chain analysis
602602
// make sure to unwrap and normalize away base
603603
const hmrUrl = unwrapId(stripBase(url, base))
604-
importedUrls.add(hmrUrl)
604+
const isLocalImport = !isExternalUrl(hmrUrl) && !isDataUrl(hmrUrl)
605+
if (isLocalImport) {
606+
importedUrls.add(hmrUrl)
607+
}
605608

606609
if (enablePartialAccept && importedBindings) {
607610
extractImportedBindings(
@@ -612,7 +615,7 @@ export function importAnalysisPlugin(config: ResolvedConfig): Plugin {
612615
)
613616
}
614617

615-
if (!isDynamicImport) {
618+
if (!isDynamicImport && isLocalImport) {
616619
// for pre-transforming
617620
staticImportedUrls.add({ url: hmrUrl, id: resolvedId })
618621
}

0 commit comments

Comments
 (0)
Please sign in to comment.