feat(napi): expose resolve_file API as resolveFileSync and resolveFileAsync #900
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Exposes the Rust
resolve_fileAPI to NAPI asresolveFileSyncandresolveFileAsyncmethods on theResolverFactoryclass.What's New
resolveFileSync(file: string, request: string)- Synchronous file-based resolutionresolveFileAsync(file: string, request: string)- Asynchronous file-based resolutionKey Difference from
sync()sync(directory, specifier)- Takes a directory path, uses manually configured tsconfig if providedresolveFileSync(file, specifier)- Takes a file path, automatically discovers tsconfig.json by traversing parent directoriesWhy This Matters
When resolving from a specific file (e.g., in bundlers, linters, or language servers),
resolveFileSyncautomatically finds the correcttsconfig.jsonby:include,exclude, andfilesfields to determine which tsconfig appliespathsaliases work correctly based on the file's contextChanges
Core Implementation (
napi/src/lib.rs)resolve_file()helper function (mirrors existingresolve()pattern)ResolveFileTaskstruct for async operationsresolve_file_sync()method toResolverFactoryresolve_file_async()method toResolverFactoryTypeScript Definitions (
napi/index.d.ts)resolveFileSync()andresolveFileAsync()Tests (
napi/tests/file-resolve.test.mjs- NEW FILE)Documentation (
README.md)Test Plan
Test Results
🤖 Generated with Claude Code