Skip to content
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

[rush] Don't install peerDependencies if the autoInstallPeers setting isn't true #4845

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

davemyersworld
Copy link
Contributor

Summary

Fixes #4843

When a rush monorepo is configured to use pnpm with useWorkspaces:false, and autoInstallPeers:false (the default), peerDependencies of monorepo packages are incorrectly installed.

Details

I fixed the problem by testing for this exact case.

I'm not sure if other package managers should be considered as well (thus far, I have not).

How it was tested

By running testrush update such that the code in this PR executed against my repro-repository and confirming no react-router in the node_modules directory

Impacted documentation

none

@iclanton
Copy link
Member

What about optional peer dependencies? Is that case missing here?

@davemyersworld
Copy link
Contributor Author

What about optional peer dependencies? Is that case missing here?

@iclanton Good question. I looked at how PackageJsonEditor organizes dependencies, and it looks like it doesn't distinguish between normal peerDependencies and ones with a peerDependenciesMeta entry.

According to the PNPM docs, auto-install-peers: true is not supposed to install the optional peerDependencies.

So, I think an appropriate fix would be to add a further conditional to ensure that optionalPeers never get added to the tempDependencies map.

I'll take a look at that tomorrow, thanks.

@davemyersworld
Copy link
Contributor Author

What about optional peer dependencies? Is that case missing here?

@iclanton Good question. I looked at how PackageJsonEditor organizes dependencies, and it looks like it doesn't distinguish between normal peerDependencies and ones with a peerDependenciesMeta entry.

According to the PNPM docs, auto-install-peers: true is not supposed to install the optional peerDependencies.

So, I think an appropriate fix would be to add a further conditional to ensure that optionalPeers never get added to the tempDependencies map.

I'll take a look at that tomorrow, thanks.

Update: Having looked at it, it appears that PackageJsonEditor.ts doesn't account for peerDependenciesMeta (though it does have a field for dependenciesMeta. So, this will take a bit more to incorporate than I expected, it'll have to wait for next week as I'm traveling for a bit.

@iclanton
Copy link
Member

@davemyersworld - did you get a chance to address the optional peers issue?

@davemyersworld
Copy link
Contributor Author

@iclanton Thanks for checking in.

For reasons unrelated to this PR, the project I was working became blocked, so my effort on this PR did as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

[rush] RushInstallManager ignores autoInstallPeers:false (and npmrc auto-install-peers=false) configuration
2 participants