Skip to content

Commit

Permalink
refactor: normalize cache package dir (#15546)
Browse files Browse the repository at this point in the history
  • Loading branch information
btea committed Mar 12, 2024
1 parent b10d162 commit e030f4b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/vite/src/node/packages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { createRequire } from 'node:module'
import {
createFilter,
isInNodeModules,
normalizePath,
safeRealpathSync,
tryStatSync,
} from './utils'
Expand Down Expand Up @@ -44,7 +45,7 @@ function invalidatePackageData(
packageCache: PackageCache,
pkgPath: string,
): void {
const pkgDir = path.dirname(pkgPath)
const pkgDir = normalizePath(path.dirname(pkgPath))
packageCache.forEach((pkg, cacheKey) => {
if (pkg.dir === pkgDir) {
packageCache.delete(cacheKey)
Expand Down Expand Up @@ -169,7 +170,7 @@ export function findNearestMainPackageData(

export function loadPackageData(pkgPath: string): PackageData {
const data = JSON.parse(fs.readFileSync(pkgPath, 'utf-8'))
const pkgDir = path.dirname(pkgPath)
const pkgDir = normalizePath(path.dirname(pkgPath))
const { sideEffects } = data
let hasSideEffects: (id: string) => boolean | null
if (typeof sideEffects === 'boolean') {
Expand Down

0 comments on commit e030f4b

Please sign in to comment.