Skip to content

Commit

Permalink
perf: support # in path only for dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
patak-dev committed Mar 17, 2023
1 parent 1a8af8d commit 4c111af
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions packages/vite/src/node/plugins/resolve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -474,11 +474,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 trySharp = 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 &&
trySharp &&
(res = tryResolveFile(
fsPath,
'',
Expand Down Expand Up @@ -508,7 +511,7 @@ function tryFsResolve(

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

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

0 comments on commit 4c111af

Please sign in to comment.