Skip to content

Commit

Permalink
perf(resolve): support # in path only for dependencies (#12469)
Browse files Browse the repository at this point in the history
  • Loading branch information
patak-dev committed Mar 21, 2023
1 parent 2fb8527 commit 6559fc7
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions packages/vite/src/node/plugins/resolve.ts
Expand Up @@ -485,11 +485,14 @@ function tryFsResolve(
): string | undefined {
const { file, postfix } = splitFileAndPostfix(fsPath)

// Dependencies like es5-ext use `#` in their paths. We don't support `#` in user
// source code so we only need to perform the check for dependencies.
const tryUnsplitted = fsPath.includes('#') && fsPath.includes('node_modules')

let res: string | undefined

// if there is a postfix, try resolving it as a complete path first (#4703)
if (
postfix &&
tryUnsplitted &&
(res = tryResolveFile(
fsPath,
'',
Expand Down Expand Up @@ -519,7 +522,7 @@ function tryFsResolve(

for (const ext of options.extensions) {
if (
postfix &&
tryUnsplitted &&
(res = tryResolveFile(
fsPath + ext,
'',
Expand Down Expand Up @@ -554,7 +557,7 @@ function tryFsResolve(
if (!tryIndex) return

if (
postfix &&
tryUnsplitted &&
(res = tryResolveFile(
fsPath,
'',
Expand Down

0 comments on commit 6559fc7

Please sign in to comment.