[Case Study] Peer dependencies for one-library-to-rule-them-all packages #3037
brandonchinn178
started this conversation in
General
Replies: 1 comment 1 reply
-
This is exactly what optional peer dependencies is for https://yarnpkg.com/configuration/manifest#peerDependenciesMeta |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Example discussion: typeorm/typeorm#7135
Typeorm has multiple drivers it has compatability with, which requires the user to install the package they whose driver they want to use. Barring splitting up the package into typeorm-core/typeorm-postgres/typeorm-mysql/etc, there doesnt seem to be a good way to specify these peer dependencies, as peerDependencies (and also optionalDependencies) are always installed, they just wont error if theyre not found. And someone using the postgres driver for typeorm shouldnt install the mysql package as well.
This is an issue with Yarn 2, with its stricter peerDependency requirement. It seems like packageExtensions is actually required in this case, instead of being a temporary workaround for packages not configured to use PnP yet (if this "temporary" characterization of packageExtensions is incorrect, this discussion is mostly moot, and typeorm will just have to tell users to edit yarnrc.yml in their docs).
In lieu of having permanent config in packageExtensions, should we maybe add some spec like "yarn 2 will also look for a 'pnpDependencies' key in package.json to specify dependencies pnp should be aware of that npm/yarn shouldnt be aware of when installing deps"?
Beta Was this translation helpful? Give feedback.
All reactions