Skip to content

fix: resolve symlinks in directory cache lookups#215

Open
benpsnyder wants to merge 1 commit into
aleclarson:v7from
benpsnyder:fix/macos-symlink
Open

fix: resolve symlinks in directory cache lookups#215
benpsnyder wants to merge 1 commit into
aleclarson:v7from
benpsnyder:fix/macos-symlink

Conversation

@benpsnyder

@benpsnyder benpsnyder commented Mar 29, 2026

Copy link
Copy Markdown
Contributor

Fixes #138. Also includes test fixtures for #130 (rootDirs) and #210 (explicit .d.ts imports).

Symlink resolution (#138)

Root cause: directoryCache keys and the importer directory walk both used path.normalize(), which does not resolve symlinks. On macOS, /tmp/private/tmp, so tsconfck discovers configs under /tmp/... while Vite reports importers under /private/tmp/... — the cache lookup never matches.

Fix: Added path.realpath() (wraps fs.realpathSync + normalize, with graceful fallback) at three entry points:

Location Purpose
addProject Canonical directory key when storing in cache
getResolvers Canonical importer path when walking up directories
watchProjects Canonical path for watcher events

Test: symlink-resolve fixture — project root accessed through a symlink (link → real). tsconfck discovers via the symlink path; Vite reports the real path. Resolution succeeds.

Also included

  • rootDirs test fixture (rootDirs support? #130)root-dirs fixture confirms oxc-resolver handles rootDirs natively (no code change needed)
  • Explicit .d.ts guard (Cannot import from .d.ts files #210) — same explicit-vs-implicit pattern as the .json guard: dtsPattern.test(resolvedId) && !dtsPattern.test(id)

@benpsnyder benpsnyder changed the title fix: symlinks on macOS fix: resolve symlinks, support rootDirs, allow explicit .d.ts imports Mar 29, 2026
@benpsnyder benpsnyder changed the title fix: resolve symlinks, support rootDirs, allow explicit .d.ts imports fix: resolve symlinks in directory cache lookups Mar 29, 2026
- Updated the `bundle` script in `package.json` to use `node --import tsx/esm` for better compatibility.
- Introduced a new `realpath` function in `src/path.ts` to resolve symlinks and normalize paths.
- Refactored the resolver to utilize `path.realpath` for improved directory handling.
- Added new test fixtures for symlink resolution and directory structure validation.
- Created example files to demonstrate the new functionality in the `test/__fixtures__` directory.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant