Skip to content

Commit

Permalink
fix: throws error when plugin tries to resolve ID to external URL (#1…
Browse files Browse the repository at this point in the history
…1731)

Co-authored-by: bluwy <bjornlu.dev@gmail.com>
  • Loading branch information
chenfan0 and bluwy committed Mar 30, 2023
1 parent 82137d6 commit 49674b5
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/vite/src/node/plugins/importAnalysis.ts
Expand Up @@ -601,7 +601,10 @@ export function importAnalysisPlugin(config: ResolvedConfig): Plugin {
// record for HMR import chain analysis
// make sure to unwrap and normalize away base
const hmrUrl = unwrapId(stripBase(url, base))
importedUrls.add(hmrUrl)
const isLocalImport = !isExternalUrl(hmrUrl) && !isDataUrl(hmrUrl)
if (isLocalImport) {
importedUrls.add(hmrUrl)
}

if (enablePartialAccept && importedBindings) {
extractImportedBindings(
Expand All @@ -612,7 +615,7 @@ export function importAnalysisPlugin(config: ResolvedConfig): Plugin {
)
}

if (!isDynamicImport) {
if (!isDynamicImport && isLocalImport) {
// for pre-transforming
staticImportedUrls.add({ url: hmrUrl, id: resolvedId })
}
Expand Down

0 comments on commit 49674b5

Please sign in to comment.