fix(TsconfigPathsPlugin): give references priority over main paths#552
Conversation
When the main tsconfig defines an alias that is also declared by a referenced project, the reference's mapping should win. Previously `_selectPathsDataForContext` returned only the main context's own paths for requests against the main context, so referenced aliases were never consulted in the conflict case. Now, when refs exist, the main context's alias list is materialised as `[...refAliases, ...mainOwnAliases]`. `forEachBail` in `aliasResolveHandler` therefore checks references first and only falls back to main paths when no reference alias matches. Modules (baseUrl candidates) stay scoped to each context so per-reference baseUrl resolution is unaffected.
…paths" This reverts commit e1a9244.
Adds a conflict fixture where main and a referenced project both declare "@lib/*" but point at different targets. The new tests assert: - Resolving @lib/foo from the main context uses main's target. - Resolving @lib/foo from the reference's directory uses the reference's target. - The reference's target does not leak into main-context lookups. This matches how tsc resolves paths — strictly through the tsconfig that owns the importing file, with no merging across a references edge.
|
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #552 +/- ##
==========================================
+ Coverage 96.57% 96.60% +0.03%
==========================================
Files 50 50
Lines 2800 2800
Branches 863 863
==========================================
+ Hits 2704 2705 +1
+ Misses 80 79 -1
Partials 16 16
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
When the main tsconfig defines an alias that is also declared by a
referenced project, the reference's mapping should win. Previously
_selectPathsDataForContextreturned only the main context's ownpaths for requests against the main context, so referenced aliases
were never consulted in the conflict case.
Now, when refs exist, the main context's alias list is materialised
as
[...refAliases, ...mainOwnAliases].forEachBailinaliasResolveHandlertherefore checks references first and onlyfalls back to main paths when no reference alias matches. Modules
(baseUrl candidates) stay scoped to each context so per-reference
baseUrl resolution is unaffected.