Skip to content

Commit 6559fc7

Browse files
authoredMar 21, 2023
perf(resolve): support # in path only for dependencies (#12469)
1 parent 2fb8527 commit 6559fc7

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed
 

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

+7-4
Original file line numberDiff line numberDiff line change
@@ -485,11 +485,14 @@ function tryFsResolve(
485485
): string | undefined {
486486
const { file, postfix } = splitFileAndPostfix(fsPath)
487487

488+
// Dependencies like es5-ext use `#` in their paths. We don't support `#` in user
489+
// source code so we only need to perform the check for dependencies.
490+
const tryUnsplitted = fsPath.includes('#') && fsPath.includes('node_modules')
491+
488492
let res: string | undefined
489493

490-
// if there is a postfix, try resolving it as a complete path first (#4703)
491494
if (
492-
postfix &&
495+
tryUnsplitted &&
493496
(res = tryResolveFile(
494497
fsPath,
495498
'',
@@ -519,7 +522,7 @@ function tryFsResolve(
519522

520523
for (const ext of options.extensions) {
521524
if (
522-
postfix &&
525+
tryUnsplitted &&
523526
(res = tryResolveFile(
524527
fsPath + ext,
525528
'',
@@ -554,7 +557,7 @@ function tryFsResolve(
554557
if (!tryIndex) return
555558

556559
if (
557-
postfix &&
560+
tryUnsplitted &&
558561
(res = tryResolveFile(
559562
fsPath,
560563
'',

0 commit comments

Comments
 (0)
Please sign in to comment.