Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/mean-seals-tease.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'eslint-import-resolver-typescript': patch
---

Only try to resolve a module directory when we know that the path is a directory. This can lead to a 15% speedup on projects with many files.
21 changes: 20 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,26 @@ function getMappedPath(
]),
)
.flat(2)
.filter(mappedPath => isFile(mappedPath) || isModule(mappedPath))
.filter(mappedPath => {
if (mappedPath === undefined) {
return false
}

try {
const stat = fs.statSync(mappedPath, { throwIfNoEntry: false })
if (stat === undefined) return false
if (stat.isFile()) return true

// Maybe this is a module dir?
if (stat.isDirectory()) {
return isModule(mappedPath)
}
} catch {
return false
}

return false
})
}

if (retry && paths.length === 0) {
Expand Down