Skip to content

Commit

Permalink
perf: move up external condition before path related conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
suguanYang committed Jun 26, 2023
1 parent 92e5c5d commit 1a815c4
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions packages/vite/src/node/plugins/importAnalysis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,12 @@ export function importAnalysisPlugin(config: ResolvedConfig): Plugin {
)
}

url = resolved.id;

if (isExternalUrl(url)) {
return [url, url]
}

const isRelative = url[0] === '.'
const isSelfImport = !isRelative && cleanUrl(url) === cleanUrl(importer)

Expand All @@ -345,12 +351,6 @@ export function importAnalysisPlugin(config: ResolvedConfig): Plugin {
// an optimized deps may not yet exists in the filesystem, or
// a regular file exists but is out of root: rewrite to absolute /@fs/ paths
url = path.posix.join(FS_PREFIX, resolved.id)
} else {
url = resolved.id
}

if (isExternalUrl(url)) {
return [url, url]
}

// if the resolved id is not a valid browser import specifier,
Expand Down

0 comments on commit 1a815c4

Please sign in to comment.