Skip to content

Support peer dependencies #1837

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

Closed
matanlurey opened this issue Mar 21, 2018 · 11 comments
Closed

Support peer dependencies #1837

matanlurey opened this issue Mar 21, 2018 · 11 comments
Labels
needs-info Additional information needed from the issue author type-enhancement A request for a change that isn't a bug

Comments

@matanlurey
Copy link
Contributor

matanlurey commented Mar 21, 2018

From NPM: https://nodejs.org/en/blog/npm/peer-dependencies/

There is an increasing number of packages (built_*, json_*, angular, so others for Flutter) that require a specific dev_dependency range for compatible tooling/code generation. For example, the json_annotation package is platform agnostic, but requires the json_serializable package for code generation.

It would be nice to be able to write, in pubspec.yaml:

name: json_annotation

peer_dependencies:
  json_serializable: ^1.0.0

... so that, dev_dependencies on json_serializable are validated against this range.

/cc @kevmoo @mit-mit

@kevmoo
Copy link
Member

kevmoo commented Mar 21, 2018

Yes, please!

@kevmoo kevmoo added the type-enhancement A request for a change that isn't a bug label Mar 21, 2018
@cah4a
Copy link

cah4a commented Mar 5, 2021

Hey,

I'm developing nock package.
I think the correct way to describe the dependencies of such packages is to make a peer dependency to test package.

Is there any plans to implement peer dependencies support?

@sigurdm
Copy link
Contributor

sigurdm commented Jan 17, 2023

... looking through old issues.

A peer_dependency is a constraint on another package but doesn't require that other package to be included in the resolution?

Am I understanding this right?

What happens if you just make a regular dependency? Don't you always need json_serializable when you use json_annotation?

@cah4a
Copy link

cah4a commented Jan 17, 2023

Peer dependency is a dependency that a user should explicitly specify in a pubspec.

A good article about the corresponding npm feature here.

@kevmoo
Copy link
Member

kevmoo commented Jan 17, 2023

@sigurdm – you are correct. If you have a dependency on json_annotation you almost certainly want/need a dev_dependency on json_serializable

@sigurdm
Copy link
Contributor

sigurdm commented Jan 19, 2023

Peer dependency is a dependency that a user should explicitly specify in a pubspec.

Sorry I don't get this (might need more coffee). Can you spell out a scenario where a peer dependency solves a problem that a regular dependency wont (in the pub model where all dependencies are shared in a resolution).

@kevmoo
Copy link
Member

kevmoo commented Jan 19, 2023

@matanlurey was the original idea maker here. I may have lost the thread....

@uvlek
Copy link

uvlek commented Jan 30, 2023

It would be nice to have implementation of peer dependencies in flutter pubspec

@sigurdm
Copy link
Contributor

sigurdm commented Jan 31, 2023

@uvlek can you explain some scenarios where you would use them? I'm still unsure about what they exactly can help us with.

@sigurdm sigurdm added the needs-info Additional information needed from the issue author label Apr 17, 2023
@github-actions
Copy link

github-actions bot commented May 2, 2023

Without additional information we're not able to resolve this issue, so it will be closed at this time. You're still free to add more info and respond to any questions above, though. We'll reopen the issue if you do. Thanks for your contribution!

@github-actions github-actions bot closed this as completed May 2, 2023
@ZimboPro
Copy link

ZimboPro commented Mar 1, 2024

One way that I can think, working on a large project, having the project's features in there own packages to make the app more modular but 2 packages might depend on each other. This will cause a cyclic dependency which could be fixed by having the 2 features in the same package but then the issue is that both features need to be stable before release a new version of the package. Peer packages will allow the features to be in its own packages and allow for stability in the app.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-info Additional information needed from the issue author type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

6 participants