Alright,
I understand that this might be a bit of a corner case, but I have a fast growing mono-repo with over 100 crates. In the last 6 months, the number of crates have already doubled, and there is no sign this trend will end any time soon. Bazel does the primary build and all CI stuff for obvious reasons, but I also maintain a Cargo config to preserve the rich Cargo tooling i.e. linting, checking, formatting, security scans etc. that Bazel either cannot run or are fairly complicated to setup. If anything, Cargo has become a really good ecosystem for dev tooling, hence I have strong reason to keep Cargo for as long as it is practical.
However, my main problem, though, comes down to the workspace Cargo.toml growing so large that it is a bit of an issue now, but most likely become a bigger problem when the number of crates double again.
In the repo, each crate has its own Cargo.toml file, but for managing dependencies, internal and external, each crate references the workspace Cargo.toml file.
External deps refers to every crate from Crates.io whereas internal dependencies refers to an alias to an internal crate. The later means that every internal crate that references another internal crate only by alias instead of its path. Using an alias has the implication that refactoring a crate location boils down to just updating the path in the alias defined in the workspace Cargo.toml. The alternative would be that you would have to search and update the path across the entire mono-repo, therefore aliasing is a meaningful time saver.
The workspace Cargo.toml file contains three sections that all grow really fast:
- The list of workspace members
- Internal aliases.
- External crates from Cargo.io
Therefore, I wonder, is there a way I can split the workspace Cargo.toml into multiple smaller files, such as:
- Sub-config file for general settings i.e. metadata plus profiles
- Sub-config file of all workspace members
- Sub-config file of all dependencies?
I did some online search and could not find any meaningful answer.
Also, I don't think that just a 100 crates is exactly large compared to what's out there in the industry, but I wonder what else can be done to maintain Cargo.toml as the monorepo grows further?