The trend of using monorepos makes a lot of things easier to manage. However, when you want to fork a single package inside a monorepo, you'll have to chose one of two options:
- Fork the entire monorepo (meaning you get all those extra boilerplate you don't really care about)
- Manually copying the package files into a new git repo (meaning you'll loose all git history and have a lot of work to do when there's a new version of your base package)
The good news: There's a solution for this! And it's actually built in to git.
One of the lesser-known (and vaguely documented) features of git is subtree
. It's intended for this purpose, working as a great alternative to the criticized submodules
.
There are very few resources about using this in practice, so here's a guide for this specific use case.