Skip to content

Commit

Permalink
fix: file dir resolve should prioritize package.json
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Jan 23, 2021
1 parent 80473c1 commit ce2d49a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/vite/src/node/plugins/resolve.ts
Expand Up @@ -252,16 +252,16 @@ function tryResolveFile(
if (fs.existsSync(file)) {
const isDir = fs.statSync(file).isDirectory()
if (isDir) {
if (tryIndex) {
const index = tryFsResolve(file + '/index', isProduction, false)
if (index) return normalizePath(index) + query
}
const pkgPath = file + '/package.json'
if (fs.existsSync(pkgPath)) {
// path points to a node package
const pkg = loadPackageData(pkgPath)
return resolvePackageEntry(file, pkg, isProduction)
}
if (tryIndex) {
const index = tryFsResolve(file + '/index', isProduction, false)
if (index) return normalizePath(index) + query
}
} else {
return normalizePath(file) + query
}
Expand Down

0 comments on commit ce2d49a

Please sign in to comment.