I had a similar problem in TableIO.
In the end, I did the following:
- With Requires.jl, the code parts of my package depending on the optional dependencies are only loaded if they are imported.
- If a method needs an optional dependency, it imports the corresponding package dynamically (see https://github.com/lungben/TableIO.jl/blob/175a12394d743d302ac53cb0b38bdafbcbe08d29/src/TableIO.jl#L50).
This is a bit “hacky” but works.
Long term, this would be great: Proposal for first class support of conditional dependencies in Pkg · Issue #1285 · JuliaLang/Pkg.jl · GitHub