deno icon indicating copy to clipboard operation
deno copied to clipboard

Request for Peer Dependency Support in Deno

Open maliknajjar opened this issue 1 year ago • 5 comments

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

maliknajjar avatar Oct 13 '24 04:10 maliknajjar

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

Hajime-san avatar Oct 13 '24 04:10 Hajime-san

hi @Hajime-san. thanks for the response can you elaborate more? how is the patch feature related to the peerDependency feature?

maliknajjar avatar Oct 13 '24 20:10 maliknajjar

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.

Hajime-san avatar Oct 15 '24 04:10 Hajime-san

@maliknajjar I don't understand - do you want peerDependencies or optionalPeerDependencies?

lucacasonato avatar Oct 21 '24 09:10 lucacasonato

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.

maliknajjar avatar Oct 21 '24 10:10 maliknajjar

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


image


and this was a discution I had with @marvinhagemeister


image

image

maliknajjar avatar Dec 24 '24 22:12 maliknajjar

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

petamoriken avatar Feb 18 '25 07:02 petamoriken

pnpm has auto-install-peers flag. I think it might be a good idea to add deno 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.

Jamesernator avatar Apr 18 '25 15:04 Jamesernator

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.

marvinhagemeister avatar May 16 '25 19:05 marvinhagemeister