Skip to content

Commit

Permalink
fix: properly handle postfix for getRealPath (#5149)
Browse files Browse the repository at this point in the history
  • Loading branch information
patak-dev committed Sep 30, 2021
1 parent 6f977a5 commit 7d257c3
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions packages/vite/src/node/plugins/resolve.ts
Expand Up @@ -382,7 +382,7 @@ function tryResolveFile(
} catch (e) {}
if (isReadable) {
if (!fs.statSync(file).isDirectory()) {
return normalizePath(ensureVolumeInPath(file)) + postfix
return getRealPath(file, preserveSymlinks) + postfix
} else if (tryIndex) {
if (!skipPackageJson) {
const pkgPath = file + '/package.json'
Expand All @@ -396,7 +396,7 @@ function tryResolveFile(
targetWeb,
preserveSymlinks
)
return resolved ? getRealPath(resolved, preserveSymlinks) : resolved
return resolved
}
}
const index = tryFsResolve(file + '/index', options, preserveSymlinks)
Expand Down Expand Up @@ -479,8 +479,6 @@ export function tryNodeResolve(
return
}

resolved = getRealPath(resolved, preserveSymlinks)

// link id to pkg for browser field mapping check
idToPkgMap.set(resolved, pkg)
if (isBuild) {
Expand Down Expand Up @@ -919,8 +917,9 @@ function equalWithoutSuffix(path: string, key: string, suffix: string) {
}

function getRealPath(resolved: string, preserveSymlinks?: boolean): string {
resolved = ensureVolumeInPath(resolved)
if (!preserveSymlinks && browserExternalId !== resolved) {
return normalizePath(fs.realpathSync(resolved))
resolved = fs.realpathSync(resolved)
}
return resolved
return normalizePath(resolved)
}

0 comments on commit 7d257c3

Please sign in to comment.