Peer dependency groups #440
Unanswered
Jamesernator
asked this question in
RRFC
Replies: 1 comment
-
We need something similar for Next.js which relies on SWC (native Also note, there is a proposal from Yarn to solve a similar problem: yarnpkg/berry#2751 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Currently peer dependencies are fairly limited, one can either require a dependency be present, or can make it optional. However in a number of cases it would be more desirable to have a list of alternative dependencies at least one of which must be present while also still automatically installing the first if none is provided.
The example that encouraged me to open this is this issue on StackBlitz. Essentially one cannot have
"esbuild"
and"esbuild-wasm"
both as potential options for a dependency, but require that at least one is a peer dependency (or automatically installed as per npm 7).Thinking about though there's actually quite a number of a cases where peer dependency groups would be desirable, as some examples
node-fetch
/undici
/etc)colors
/chalk
/etc)@babel/parser
/acorn
/shift
/typescript
/etc)As a simple idea for how this could look in
package.json
:The above proposal also integrates with older versions of
npm
in the same way that automatic installation of peerDependencies does, in that it won't break older versions ofnpm
. Older versions ofnpm
will simply ignore it and one will need to install at least one of the peer dependencies explictly.Beta Was this translation helpful? Give feedback.
All reactions