File tree Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ ' eslint-import-resolver-typescript ' : patch
3+ ---
4+
5+ 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.
Original file line number Diff line number Diff line change @@ -287,7 +287,26 @@ function getMappedPath(
287287 ] ) ,
288288 )
289289 . flat ( 2 )
290- . filter ( mappedPath => isFile ( mappedPath ) || isModule ( mappedPath ) )
290+ . filter ( mappedPath => {
291+ if ( mappedPath === undefined ) {
292+ return false
293+ }
294+
295+ try {
296+ const stat = fs . statSync ( mappedPath , { throwIfNoEntry : false } )
297+ if ( stat === undefined ) return false
298+ if ( stat . isFile ( ) ) return true
299+
300+ // Maybe this is a module dir?
301+ if ( stat . isDirectory ( ) ) {
302+ return isModule ( mappedPath )
303+ }
304+ } catch {
305+ return false
306+ }
307+
308+ return false
309+ } )
291310 }
292311
293312 if ( retry && paths . length === 0 ) {
You can’t perform that action at this time.
0 commit comments