Danielduel
Danielduel16mo ago

Peer dependency

Can I somehow mark a dependency as "peer"? So this dependency (which is known to shuffle typings between versions, but generally it is nonbreaking if you use it on highlevel) will not enforce a specific version onto a project? I depend on Pentagon and Zod Pentagon also depends on Zod While I initially wanted to use different version of Zod than pentagon's (using different versions of Zod makes some inner types clash) (I can switch zod version to pentagon's, but I feel not everybody would have the same luxury in the future) If possible - I would like to avoid this solution: https://github.com/denoland/deno/issues/10356#issuecomment-1580352563
GitHub
Peer dependencies · Issue #10356 · denoland/deno
Background I am the developer of an a new framework for writing Telegram bots (ref, but the purpose is irrelevant here). The core framework is extensible by plugins that can be published by other a...
3 Replies
Deno AI Helper
Deno AI Helper16mo ago
Based on the documentation, Deno does not have a concept of "peer dependencies" like in Node's npm. In Deno, modules are imported directly via URLs and there is no package manager. However, Deno does provide a way to manage dependencies through a deps.ts file. This file is used to import and re-export your dependencies. This way, you can manage all your dependencies in one place and avoid having multiple references to the same URL throughout your project. If you have a dependency that is used in several files, upgrading to a new version of this dependency is much simpler as this can be done just within deps.ts. In your case, you could import both Pentagon and Zod in your deps.ts file and re-export them for use in your project. However, if Pentagon and your project require different versions of Zod, this could lead to conflicts. The documentation also mentions the Duplicate Dependency Problem, which arises when a program contains similar yet slightly different modules. If another module imports a URL referencing a slightly different version, both module versions will be included in the module graph despite being almost the same code. Unfortunately, the documentation does not provide a clear solution to this problem. It does mention the use of import maps as a potential solution, but notes that import maps are not composable and cannot be used by a published library and an import map simultaneously. Therefore, based on the information provided in the documentation, it seems that there is no straightforward way to mark a dependency as "peer" in Deno.
ioB
ioB16mo ago
You could potentially use an import map to change Pentagon’s version of Zod to whatever you wanted?
Danielduel
DanielduelOP16mo ago
👀