mirror of
https://github.com/oven-sh/bun
synced 2026-02-14 12:51:54 +00:00
Previously, importing '.' or './' from within a subdirectory would
incorrectly resolve to a file with the same name in the parent
directory, rather than the index file in the current directory.
For example, importing from 'lib/run.ts':
```ts
import { foo } from ".";
```
Would incorrectly resolve to the root 'lib.ts' instead of 'lib/index.ts'.
This fix adds a check in loadAsFile() to detect when the path being
resolved is actually a directory. If the basename has no extension
(indicating it's likely a directory reference), we check if it exists
as a directory before attempting file resolution. This ensures directory
imports correctly fall through to index file resolution.
Fixes #24449
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>