esy-issues
esy-issues copied to clipboard
Optional dependencies
We need to model optional dependencies in Esy.
Motivation
cohttp
has backends both for async
and lwt
concurrency libraries but most apps are built around either one or another.
Currently cohttp
has lwt
and async
listed in its depopts
in the opam
file. That means that with opam you don't get both lwt
and async
pulled and built when you use cohttp
— you need to specify either lwt
or async
in your own dependencies to have one of them ready to use.
Proposal
I propose to add conditionalDependencies
(optionalDependencies
name is already taken by npm and doesn't have the needed mechanics behind it).
The suggestion is to use the same semantics as for peerDependencies
but not fail if those packages mentioned in conditionalDependencies
are absent from installation.
If package optdep
is listed in conditionalDependencies
for the package pkg
:
-
optdep
is not being installed automatically (same as withpeerDependencies
) for thepkg
- Unlike with
peerDependencies
it is not an error to have nooptdep
installed at all. - If
optdep
is present in the installation (required by some of packages above) then it's being pulled intopkg
's env.
I prototyped this and it works for the case with cohttp
+ lwt
!
It seems like this approach doesn't require any modification to the package installer/resolver - it only requires that esy
set up the environment correctly, right?
Right. Check if a conditional dep package is present and pull its env.