Skip to content

Exposes peer dependencies#560

Merged
arcanis merged 3 commits intomasterfrom
mael/package-peers
Nov 1, 2019
Merged

Exposes peer dependencies#560
arcanis merged 3 commits intomasterfrom
mael/package-peers

Conversation

@arcanis
Copy link
Copy Markdown
Member

@arcanis arcanis commented Oct 31, 2019

What's the problem this PR addresses?

In the context of the compatibility work ongoing at #500 and #470, we need to figure out how to detect which dependencies have a stricter contract than others regarding multiple instantiations. This isn't a problem for PnP because package instantiations follow predictable rules, but with the classic Node resolution it's a different story and we need to know it explicitly.

The initial approach used an heuristic which tried to figure out whether a package had a peer dependency by checking the version used by its parent (and assume it's a peer dep if they matched), but in practice it caused too many false positives to be viable.

How did you fix it?

This diff exposes the peer dependencies through a new packagePeers field returned by getPackageInformation. The field will only be stored in the PnP map if the package actually has peer dependencies, but will always be returned by getPackageInformation.

Incidently it might also prove useful for tree traversals as you will be able to shortcut many paths that you would have crossed otherwise.

| Package name | Version |
| --- | --- |
| `@yarnpkg/plugin-essentials` | `2.0.0-rc.9` |
| `@yarnpkg/plugin-exec` | `2.0.0-rc.6` |
| `@yarnpkg/plugin-git` | `2.0.0-rc.6` |
| `@yarnpkg/plugin-init` | `2.0.0-rc.2` |
| `@yarnpkg/plugin-stage` | `2.0.0-rc.5` |
| `@yarnpkg/builder` | `2.0.0-rc.9` |
| `@yarnpkg/cli` | `2.0.0-rc.11` |
| `@yarnpkg/core` | `2.0.0-rc.11` |
| `@yarnpkg/fslib` | `2.0.0-rc.7` |
| `@yarnpkg/pnp` | `2.0.0-rc.7` |
| `@yarnpkg/pnpify` | `2.0.0-rc.8` |
@arcanis arcanis merged commit ef6434a into master Nov 1, 2019
@arcanis arcanis deleted the mael/package-peers branch November 1, 2019 17:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant