Add fastify to peerDependencies#165
Conversation
Signed-off-by: Paulius Valiūnas <66480813+paulius-valiunas@users.noreply.github.com>
Signed-off-by: Paulius Valiūnas <66480813+paulius-valiunas@users.noreply.github.com>
|
Hi! Why is this needed? Is there any problems without it? |
yes, see the linked issue. It simply doesn't work with pnpm. |
gurgunday
left a comment
There was a problem hiding this comment.
Can you delete it from devDependencies then?
I'm not sure about this just because we only use peerDeps as a last resort, let me verify it with others
No, it has to be in both. Everything that you declare in peerDependencies should also be a devDependency, otherwise you won't be able to build your package. And to make it clear, your package absolutely needs fastify to be installed alongside it, it doesn't make any sense without fastify, so not declaring it as either a dependency or a peerDependency is a bug. If you declare it as a direct dependency, that will probably work but might cause similar errors when the user installs a different version than what you have declared. Honestly, I think this is a textbook example of the kind of problems peerDependencies were designed to solve. |
This is what I'm saying, we might prefer a direct dependency here |
As TypeScript perspective, I would avoid a direct dependency only for types. As a maintainer of fastify, I would avoid using peerDependices as possible. Adding in one packages will spread the request to all others plugin. |
|
But please also consider the "but" part 😅 I'm not saying it won't work at all, but it will most probably cause someone problems with incompatible versions being installed. For example, if fastify 5.0 changes the type definition of |
@climba03003 In that case, how do you propose pnpm users should consume plugins? |
|
@climba03003 Could you elaborate on why you think declaring fastify as a peerDependency (in every plugin) is bad? Here's my reasoning in favor of peerDependencies: A fastify plugin is not a standalone package, it extends a fastify instance that's already declared somewhere in your project. It makes no sense for it to bring its own version of fastify. When a user installs a fastify plugin, he does not expect to get a brand new fastify object, potentially from a different version of the package than the one he's using, he just wants the plugin to extend what he already has installed. If you declare fastify as a direct dependency, you're very likely to get two distinct instances of the package in the dependency tree, which will cause type mismatches, failed |
Not going to debate, but you can see the reason why we do not accept |
And what exactly is the reason? I see a bunch of unrelated issues mostly caused by incorrectly declared version ranges. |
|
is there any hope this could still be merged? |
|
I'm personally only concerned with npm, and I think in general we should prioritize npm, but maybe we can make an exception for the type providers Unfortunately I can't move the ball on this though |
|
This will not break npm though. |
markandrus
left a comment
There was a problem hiding this comment.
The same issue occurs in recent versions of Yarn. For now, the problem can be worked around by adding the following to .yarnrc.yml in a Yarn project's root:
packageExtensions:
"@fastify/type-provider-typebox@5.x":
peerDependencies:
"fastify": "5.x"
| "peerDependencies": { | ||
| "@sinclair/typebox": ">=0.26 <=0.33" | ||
| "@sinclair/typebox": ">=0.26 <=0.33", | ||
| "fastify": "^5.0.0-alpha.3" |
There was a problem hiding this comment.
I suppose this can be changed to 5.x now?
| "fastify": "^5.0.0-alpha.3" | |
| "fastify": "5.x" |
There was a problem hiding this comment.
Thank you, I changed it to standard semver notation.
Signed-off-by: Paulius Valiūnas <66480813+paulius-valiunas@users.noreply.github.com>
Signed-off-by: Paulius Valiūnas <66480813+paulius-valiunas@users.noreply.github.com>
|
@Fdawgs since I see you're the main contributor to this repo, I would appreciate your opinion on this, so that we could either merge or close the PR. |
|
The conversation in fastify/fastify-mongodb#209 still stands. |
You are doing exactly that by not having a peerDependency. If you have a peerDependency, you can specify the version range you want people to use. If you don't... well, npm will make it work with any ancient version because it doesn't do any checks, and pnpm will just not work at all. |
Fixes #114