Skip to content

Commit

Permalink
fix: esbuildOutputFromId for symlinked root (#10154)
Browse files Browse the repository at this point in the history
  • Loading branch information
patak-dev committed Sep 18, 2022
1 parent aebfd9c commit fc5310f
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions packages/vite/src/node/optimizer/index.ts
Expand Up @@ -911,12 +911,22 @@ function esbuildOutputFromId(
id: string,
cacheDirOutputPath: string
): any {
const cwd = process.cwd()
const flatId = flattenId(id) + '.js'
return outputs[
normalizePath(
path.relative(process.cwd(), path.join(cacheDirOutputPath, flatId))
)
]
const normalizedOutputPath = normalizePath(
path.relative(cwd, path.join(cacheDirOutputPath, flatId))
)
const output = outputs[normalizedOutputPath]
if (output) {
return output
}
// If the root dir was symlinked, esbuild could return output keys as `../cwd/`
// Normalize keys to support this case too
for (const [key, value] of Object.entries(outputs)) {
if (normalizePath(path.relative(cwd, key)) === normalizedOutputPath) {
return value
}
}
}

export async function extractExportsData(
Expand Down

0 comments on commit fc5310f

Please sign in to comment.