-
-
Notifications
You must be signed in to change notification settings - Fork 27
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
Add fastify to peerDependencies #165
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Paulius Valiūnas <[email protected]>
Signed-off-by: Paulius Valiūnas <[email protected]>
Hi! Why is this needed? Is there any problems without it? |
yes, see the linked issue. It simply doesn't work with pnpm. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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/[email protected]":
peerDependencies:
"fastify": "5.x"
package.json
Outdated
@@ -18,7 +18,8 @@ | |||
} | |||
}, | |||
"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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, I changed it to standard semver notation.
Signed-off-by: Paulius Valiūnas <[email protected]>
Fixes #114