-
Notifications
You must be signed in to change notification settings - Fork 12.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Module resolution: Module resolved to indirect dependency rather than direct local one when versions are the same #60556
Comments
Exactly; we deduplicate packages by name and version; a different symptom of the same cause was closed as a design limitation here: #51976. Iβm not sure what we could do about this. |
Just throwing out a couple of ideas...
|
We deduplicate packages for a reason, so defeating the deduplication is just trading one problem for another. Including the same code multiple times can cause bogus errors. While it would fix your specific use case here, it could just as easily create duplicate declaration errors for someone else. |
Isn't it the job of package manager to do that? If a package is unintentionally duplicated, then there can be many more problems than just duplicate declarations. To name a few that quickly come to mind: |
This hasn't always been the case; older versions of npm would not deduplicate when sub-dependencies needed to be nested, and it's a huge performance problem for TS if we need to e.g. resolve 30 copies of You can argue that an ideally set-up package manager wouldn't do this, but I'd also argue that a correctly set-up package manager can't produce two packages with the same version and the same name but with different contents, which is the setup your repro depends on. It doesn't really fly to say we should rely on one invariant while ignoring the other. |
This issue has been marked as "Duplicate" and has seen no recent activity. It has been automatically closed for house-keeping purposes. |
π Search Terms
"local module resolution", "module resolution same version"
π Version & Regression Information
5.6.3
, also reproduced withnext
,4.6
,4.8
,5.0
.β― Playground Link
https://github.com/grigasp/ts-deps-issue
π» Code
Package
[email protected]
is released with the following:Locally we have this package at the same version, but with an additional type:
Locally we also have a package
b
, that has a dependency on a released version of[email protected]
and exports the following type:Finally, locally we also have a package
c
, that has dependencies on local workspace versions of packagesb
anda
and imports types from them both:π Actual behavior
When building package
c
, the build fails with error:π Expected behavior
When building package
c
, TypeScript resolves packagea
to our local version which does have theA2
type, and the build succeeds.Additional information about the issue
I tried running
tsc -traceResolution
for packagec
and it seems that both - released package and the local one - are assigned the same Package ID:I suppose that could cause a cache collision or something like that.
The text was updated successfully, but these errors were encountered: