4 ms·
Pay attention to cargo features for crates. (Those are flags for crates, which also affect the dependency set needed by the crate affected.) A lot of crates ha
by krom 5y ago
Pay attention to cargo features for crates. (Those are flags for crates, which also affect the dependency set needed by the crate affected.)
A lot of crates have a bunch of selectable features. Their defaults usually lead to many dependencies needed. If you carefully select those, you can cut down on dependencies a lot.
https://doc.rust-lang.org/cargo/reference/features.html https://doc.rust-lang.org/cargo/reference/features.html
- deleted 5y ago[deleted]
- fhd2 5y agoGreat tip! I wasn't quite aware, basically like compile flags with C/C++ deps (implemented somewhat similar to Cargo in Gentoo, I'd say).
- eska 5y agoA recent update also made the resolution of such features smarter in the case that the same dependency is used by multiple dependencies, so the size has been reduced. There's also tooling for investigating your dependencies, automatic git bots to make suggestions, etc.
- jamwaffles 5y agoBuilt into `cargo`, I'd recommend `cargo tree`, `cargo tree -i` and/or `cargo tree --duplicates` to figure out where certain types of dependency tree bloat are.