Hi!
I'm working on a library that getting quite large with lots of included data, but when using the library in projects I'm noticing that the library takes quite a bit to compile. To solve this I would like to split the library in a way so that if you don't need everything you don't need to compile everything with the added benefit that you can pick only the parts that you need, but I'm not sure what the best approach for this is.
How I see it there are two ways to do this: either split the library through feature flags or split the library into multiple crates.
Splitting the library using feature flags has the advantage of keeping it one thing on crates.io and keeps it simple, but after some testing I'm not noticing that much improvement in compilation time even if I were to only enable some small part of the library and nothing else.
Splitting the library into different crates has the advantage of allowing the user to just pick a single crate if they don't need anything else, but that would require that some of the crates require the others as dependencies and I'm not experienced with how that would work with versioning. For example in the following example:
- Installed crate A which depends on crate B with version 1.0.0
- Manually also install crate B with version 1.1.0
I'm not sure what kind of issues would arise from this. Also this would mean that I would have three crates on crates.io which feels a bit excessive.
To put all of the above into two concrete questions:
- Is it possible to improve the compile time through feature flags and if so what are some things to take into account?
- Does splitting the library into multiple create issues with how versions are handled?
I did found this topic but it hasn't received a reply.
Any input on this greatly appriciated. Thanks in advance!