-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
fix: resolve peer of peer from the deps of direct dependent package #7606
Conversation
@@ -143,7 +143,7 @@ test('don\'t install the same missing peer dependency twice', async () => { | |||
const lockfile = await project.readLockfile() | |||
expect(Object.keys(lockfile.packages).sort()).toStrictEqual([ | |||
'/@pnpm/y@1.0.0', | |||
`/@pnpm.e2e/has-has-y-peer-peer@1.0.0${createPeersFolderSuffix([{ name: '@pnpm/y', version: '1.0.0' }, { name: '@pnpm.e2e/has-y-peer', version: '1.0.0' }])}`, | |||
'/@pnpm.e2e/has-has-y-peer-peer@1.0.0(@pnpm.e2e/has-y-peer@1.0.0(@pnpm/y@1.0.0))(@pnpm/y@1.0.0)', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the nested syntax here is pretty interesting—that's new, right? is it representing a small subtree of peer dep resolutions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, if a peer dependency has peer dependencies of its own, they will be nested. The nesting may be deep if there is a long chain of peer dependency peer dependencies.
'@pnpm.e2e/has-say-hi-peer': '1.0.0(hi@1.0.0)', | ||
'@pnpm.e2e/has-say-hi-peer': '1.0.0(github.com/zkochan/hi/4cdebec76b7b9d1f6e219e06c42d92a6b8ea60cd)', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh awesome, this seems like it would fix #7393 wouldn't it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure. It was a byproduct of my changes. I'll be happy if it fixes more issues.
This might be annoying to mention if this PR is still quite early on, but when I try out this branch locally on Discord I get the following error (enabled sourcemaps with Stacktrace
|
Actually the PR is ready. I only need to add changesets and a description. So, it is not good that it failed for you. But I think I know how to fix the issue. |
This is a breaking change but it is a very important fix, so I will probably add this change to v8 as well (as an opt-in). |
This reverts commit 6dc1284.
Steven has found a scenario in which these changes make pnpm hang: {
"devDependencies": {
"webpack-cli": "^5.1.4",
"webpack-dev-server": "^4.0.0"
}
} I'll try to fix this. |
@stevenpetryk you can try it again. I have fixed the issue. |
Seems fixed on our end! |
I'm currently running a test locally with this PR for DT, just to see. It's caused a few failures so far, so I need to try and narrow this down to understand what differed. Mainly, it looks like certain packages used to have access to |
Before these changes, the resolution algorithm was somewhat undeterministic. There was a possibility that, before the change, a peer dependency would have access to That might be the cause of the issue. |
@jakebailey let me know what you find out and whether we should wait with merging this. |
I haven't had time to analyze it yet, but https://gist.github.com/jakebailey/d4ac5d357dcf84dd6ef8fd265264be00 contains the raw output of running tsc on every DT project when installed using this branch. I suspect that a lot of these are "okay" in that they represent more packages that need a |
This will only be released in v9. We will fix any issues that you find before the first stable version. |
Thankfully, most of the errors were my mistake (running the wrong typescript version on typesVersions dirs). The rest are all places where we could add deps on |
I did notice that one of the paths mentioned has an unmatched closing paren:
Which may be a bug in this PR. |
I see, I already started the release of v9.0.0-alpha.2. We can create an issue about this issue that you have found. |
It probably makes sense to bump the lockfile version to v7 with this change. As it appears that pnpm v8 fails with the new nested brackets syntax. I have backported a fix but I don't think it will be enough to avoid confusion. |
close #7444
Peer dependencies of peer dependencies are now resolved correctly. When peer dependencies have peer dependencies of their own, the peer dependencies are grouped with their own peer dependencies before being linked to their dependents.
For instance, if
card
hasreact
in peer dependencies andreact
hastypescript
in its peer dependencies, then the same version ofreact
may be linked from different places if there are multiple versions oftypescript
. For instance:In the above example, both projects have
card
in dependencies but the projects use different versions oftypescript
. Hence, even though the same version ofcard
is used,card
inproject1
will referencereact
from a directory where it is placed withtypescript@7.0.0
(because it resolvestypescript
from the dependencies ofproject1
), whilecard
inproject2
will referencereact
withtypescript@8.0.0
.