Skip to content

Commit

Permalink
fix vite on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
patricklx committed Dec 21, 2023
1 parent 2a6775b commit b586311
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/shared-internals/src/package-cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Package from './package';
import { existsSync, realpathSync } from 'fs';
import { getOrCreate } from './get-or-create';
import resolvePackagePath from 'resolve-package-path';
import { dirname, sep } from 'path';
import { dirname, posix } from 'path';

const realpathSyncCache = new Map<string, string>();

Expand Down Expand Up @@ -67,7 +67,7 @@ export default class PackageCache {
}

ownerOfFile(filename: string): Package | undefined {
let segments = filename.split(sep);
let segments = filename.replace(/\\/g, '/').split(posix.sep);

// first we look through our cached packages for any that are rooted right
// at or above the file.
Expand All @@ -79,11 +79,11 @@ export default class PackageCache {
}

let usedSegments = segments.slice(0, length);
let candidate = usedSegments.join(sep);
let candidate = usedSegments.join(posix.sep);
if (this.rootCache.has(candidate)) {
return this.rootCache.get(candidate);
}
if (getCachedExists([...usedSegments, 'package.json'].join(sep))) {
if (getCachedExists([...usedSegments, 'package.json'].join(posix.sep))) {
return this.get(candidate);
}
}
Expand Down

0 comments on commit b586311

Please sign in to comment.