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

describe how npm 7 handles peer conflicts #239

Closed
wants to merge 0 commits into from

Conversation

isaacs
Copy link
Contributor

@isaacs isaacs commented Sep 23, 2020

rfc

Copy link
Contributor

@ljharb ljharb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like it would be more ideal to, when a dep graph would have passed with --strictPeerDeps, ensure that future installs operate with strictPeerDeps. That way, an invalid dep graph can still be installed as users migrate to npm 7, but a valid dep graph can't suddenly become invalid without failing the install.


When the `--legacy-peer-deps` flag is set, ignore `peerDependencies`
entirely. This makes npm v7 behave effectively the same as npm v3 through
v6. The `--legacy-peer-deps` flag is _never_ set for `npm ls`, so that npm
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so npm ls --legacy-peer-deps will have the flag as a noop, or will fail as an invalid flag?

Copy link
Contributor Author

@isaacs isaacs Sep 24, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ls passes legacyPeerDeps: false in the arborist options regardless of what the config says.

@isaacs
Copy link
Contributor Author

isaacs commented Sep 24, 2020

It seems like it would be more ideal to, when a dep graph would have passed with --strictPeerDeps, ensure that future installs operate with strictPeerDeps. That way, an invalid dep graph can still be installed as users migrate to npm 7, but a valid dep graph can't suddenly become invalid without failing the install.

This leaves you vulnerable to failing the install if a meta dep changes in such a way that the peer deps become invalid (but overrideably so).

Strict peer deps kind of has to be either the default always, or explicitly opt in, I think.

@isaacs isaacs added Agenda will be discussed at the Open RFC call Release 7.x labels Sep 28, 2020
```

In this example, the `z@1` dependency will be used in non-strict mode if
`x` is not the root project.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this sounds a little bit confusing to me, so if z@1 is picked for the current level it means that z@2 gets duped under x ? (might be worth adding that bit here if that's the case, just for the sake of clarity for future readers)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action: update to show tree in both scenarios.

the only place where its dependencies can be placed, causing the conflict.

- **Strict mode**: Raise an error and halt the ideal tree building process.
- **Force mode**: Warn about the conflict. Arbitrarily keep the first peer
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would this "first peer dependency" happen to be the first one declared in the package.json file? Otherwise if there's no way at all to define it, it seem to me it might be better to just raise an error here too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be the first one encountered in a breadth-first traversal through the dependency graph, ordered alphabetically.

@Christian24
Copy link

As I had mentioned on the call:

  • Where is the warning displayed? I guess the only warnings I only ever pay attention to is the audit output. So, maybe a summary below that would be nice?


  • Are there plans to become more strict in the future? Maybe it might be useful to print a warning this "might break in future major versions of npm". This might enforce package authors to fix issues.

@isaacs isaacs force-pushed the isaacs/handling-peer-conflicts branch from fd1bcbe to 7c67796 Compare October 13, 2020 04:36
@isaacs
Copy link
Contributor Author

isaacs commented Oct 13, 2020

@Christian24

Where is the warning displayed? I guess the only warnings I only ever pay attention to is the audit output. So, maybe a summary below that would be nice?


I agree, that would be nice. I'd rather keep this RFC more focused, and leave the position of warnings as a UI issue we can iterate on, since this is already quite long and dense. But I agree, printing it below any other install output would definitely be worthwhile. Since we're already doing some special treatment for ERESOLVE warnings (to turn the description object into a more human-readable form), it wouldn't be too hard to hold it and print below any other output. We can get that on a v7 patch release.

Are there plans to become more strict in the future? Maybe it might be useful to print a warning this "might break in future major versions of npm". This might enforce package authors to fix issues.

There's no plan to make --strict-peer-deps the default in the future, and it would have to be quite a long ways out in the future in any event, given the current state of peerDependencies usage in the registry today. I think it would not be a bad idea, but it would need another RFC, and some thorough investigation.

@ruyadorno
Copy link
Contributor

ruyadorno commented Oct 13, 2020

Are there any tweaks from the actual implementation that landed in arborist needed to be added/changed here @isaacs or should we just land this?

@isaacs isaacs closed this Oct 19, 2020
@isaacs isaacs force-pushed the isaacs/handling-peer-conflicts branch from 571b400 to 42ce99d Compare October 19, 2020 22:45
@isaacs isaacs deleted the isaacs/handling-peer-conflicts branch October 19, 2020 22:46
@darcyclarke darcyclarke removed the Agenda will be discussed at the Open RFC call label Oct 21, 2020
@Anticom
Copy link

Anticom commented Jun 14, 2021

FYI: For the people looking for the RFC, it's here now.

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.

6 participants