Request for Peer Dependency Support in Deno
I am currently developing a framework in Deno and noticed that Deno lacks the peerDependency feature, which is available in Node.js.
I would like to request supporting peer dependency in Deno, specifically allowing the specification of peer dependencies in the deno.json configuration file, similar to how it is handled in package.json in Node.js.
While I implement a custom solution by reading the deno.json file and checking if the user installed a package with a specific version, a built-in, native implementation would be far more cleaner.
Is this a feature that Deno is considering, or are there any plans to add support for peer dependencies in future releases?
Thank you
While I implement a custom solution by reading the deno.json file and checking if the user installed a package with a specific version
Although not directly related to the topic, I think that this might be a use case for the patch feature.
- https://github.com/denoland/deno/issues/25110
hi @Hajime-san. thanks for the response can you elaborate more? how is the patch feature related to the peerDependency feature?
This was a misinterpretation on my part. The patch feature was intended to allow users to transparently resolve library versions or fixing codes, and was not something that library developers were involved in.🙏
This is just my personal opinion, but I think Node.js's fooDependencies made package.json too complicated.
On the other hand, I can understand that this problem could also occur in Deno.
I'd like to hear the team's opinions on this.
@maliknajjar I don't understand - do you want peerDependencies or optionalPeerDependencies?
I actually want peerDependencies in my case, but having an optional argument wouldn’t be a bad idea either. This feature exists in npm too, and you can see it here: https://docs.npmjs.com/cli/v7/configuring-npm/package-json#peerdependenciesmeta.
When a user is going to use package A, and package A requires package B as a peerDependency, the user has to install package B themselves. If the user doesn’t install it, and Deno can’t find it in deno.json with the correct semver, Deno will throw an error.
bringing more context to this suggested feature
I asked this question in Discussions: How to Ensure Library B Uses the Same Version of Library C as My App
and this was a discution I had with @marvinhagemeister
pnpm has auto-install-peers flag. I think it might be a good idea to add deno add --auto-install-peers.
https://pnpm.io/next/npmrc#peer-dependency-settings
pnpm has
auto-install-peersflag. I think it might be a good idea to adddeno add --auto-install-peers.
It would be good as well if deno could also just read this option from .npmrc like it already does for private registry support.
Just ran into this in Fresh. We were initializing new projects with @preact/signals version 2.x but Fresh depends on 1.x. There should only ever be one version, but because we only support peerDependencies for npm packages I got no warning and this flew under the radar.