I have run into issues with long loading times for using some of my custom packages, and it appears to be because those packages load a lot of dependencies (as suggested here). But often my packages only need some small subset of the functionality provided by another package (e.g., I only need gradient from ForwardDiff).
So, I have two questions:
Is there a way to only load a subset of a package? (I.e., something like using ForwardDiff: gradient, but only load code related to gradient instead of loading everything in ForwardDiff.)
If so, how can I structure my package code to enable users to only load a subset of the functionality? Submodules?
I think we can write a macro that includes that subset of the code. Some kind of intelligent macro that parses the source code of the package and finds the dependencies of that subset and includes and evaluates it.
It is hard though
Another approach is to make dynamic dlls using PackageCompiler.
Yes, exactly this. I think developing multiple packages in one repository is the best solution. Packages are the mechanism for identifying/naming a chunk of code to either load or not. In that sense loading part of a package is kind of a contradiction in terms — the part you’re loading is itself a package by definition.