fix: check tsconfig matching before using resolver
This PR fixes an issue where the resolver was using a cached resolver before determining which tsconfig file actually includes the current file when multiple tsconfig files are specified for the same directory path.
**Problem:**
When multiple tsconfig files (e.g., `tsconfig.node.json` and `tsconfig.web.json`) exist in the same directory with different `include` patterns, the cached resolver was used before matching which tsconfig includes the current file. This caused incorrect tsconfig settings to be applied.
**Solution:**
Reorder the resolver cache check to occur after tsconfig matching. This ensures the correct tsconfig configuration is identified before attempting to use a cached resolver.
**Changes:**
- Modified `src/index.ts` to move resolver cache check from lines 101-107 to after tsconfig matching (now at lines 133-139)
- Added e2e test case `multipleTsconfigsWithReferences`:
- Backend files (`backend/**/*`) correctly use `tsconfig.node.json` with `@backend/*` paths
- Frontend files (`frontend/**/*`) correctly use `tsconfig.web.json` with `@frontend/*` paths
- Both configurations properly resolve shared utilities via `@shared/*` paths
- Updated test snapshots
<!-- ELLIPSIS_HIDDEN -->
----
> [!IMPORTANT]
> Fix resolver cache check order in `src/index.ts` to ensure correct tsconfig is identified before using cached resolver, with new e2e test added.
>
> - **Behavior**:
> - Reorder resolver cache check in `resolve()` in `src/index.ts` to occur after tsconfig matching, ensuring correct tsconfig is identified before using cached resolver.
> - **Tests**:
> - Add e2e test `multipleTsconfigsWithReferences` to verify correct tsconfig usage for backend and frontend files.
> - Backend files use `tsconfig.node.json` and frontend files use `tsconfig.web.json`, both resolving shared utilities via `@shared/*` paths.
> - **Misc**:
> - Update test snapshots to reflect new test case.
>
> <sup>This description was created by </sup>[<img alt="Ellipsis" src="https://img.shields.io/badge/Ellipsis-blue?color=175173">](https://www.ellipsis.dev?ref=import-js%2Feslint-import-resolver-typescript&utm_source=github&utm_medium=referral)<sup> for 6697e04dcebea6aa36cb90eb35e5c80d08a1f1a5. You can [customize](https://app.ellipsis.dev/import-js/settings/summaries) this summary. It will automatically update as commits are pushed.</sup>
<!-- ELLIPSIS_HIDDEN -->
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit
* **Performance Improvements**
* Optimized resolver cache lookup efficiency by deferring cache checks to occur after configuration matching.
* **Tests**
* Added comprehensive end-to-end test coverage for TypeScript multi-configuration projects with path aliases and project references.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
合并状态:未合并 4 条评论