Skip to content

Commit

Permalink
perf: don't recalculate path.dirname(mod.file) (#15623)
Browse files Browse the repository at this point in the history
  • Loading branch information
patak-dev authored Jan 19, 2024
1 parent f08a037 commit e459be4
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/vite/src/node/server/transformRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@ async function loadAndTransform(
)

if (path.isAbsolute(mod.file)) {
let modDirname
for (
let sourcesIndex = 0;
sourcesIndex < normalizedMap.sources.length;
Expand All @@ -338,8 +339,9 @@ async function loadAndTransform(
// to resolve and display them in a meaningful way (rather than
// with absolute paths).
if (path.isAbsolute(sourcePath)) {
modDirname ??= path.dirname(mod.file)
normalizedMap.sources[sourcesIndex] = path.relative(
path.dirname(mod.file),
modDirname,
sourcePath,
)
}
Expand Down

0 comments on commit e459be4

Please sign in to comment.