Fighting chaos in a monorepo Monorepo is a good servant, but a bad master

Jakub Beneš Engineering Manager @ Productboard @jukben @jukben https://jukben.codes

Agenda • What is monorepo • What problems we faced at Productboard • What strategies we have deployed • Takeaways

What’s monorepo

fi Why and why not? Pros Cons • • • • • • Better visibility and collaboration across teams Simpli ed dependency management Easier large scale refactoring Build pipelines VSC Tooling Challenges Limitations Around Access Control

Throwback 85% bigger

Throwback

CI/CD Pipeline

Tooling is our friend We have conducted research for tooling which would help us to maintain the monorepo better. Manage a complex dependency graph • Build only a ected projects • Provide API sca old code ff • ff •

Tooling is our friend

Nx proven to be right choice • We started to break down our monolith into smaller chunks (Nx projects) • Possibility to run them separately (eslint, jest, build, deployment) • Isolation • Ownership https://medium.com/productboard-engineering/

Adoption 🚀

This is what we have got…

Bene t no. 1: Context Aware Pipeline • Nx has also support for distributed caching across all environments ff By using nx affected we were able to run only that code that changed or was a ected by dependency graph fi •

fi Bene t no. 1: Context Aware Pipeline

Bene t no. 1: Context Aware Pipeline 75% fi faster

Bene t no. 2: Consistence and ownership By default we push author to make entry into CODEOWNER le fi • fi Every lib is generated with sane default values and con guration fi •

Bene t no. 3: Migration framework Nx has support of “generators” to sca old tests, components and le structure in general Comes with opinionated structure but it’s extensible fi ff • fi •

Cherry on the top: Observability • Together with CODEOWNERS we are able to map Nx projects to ESlint issues, test coverage and more. https://medium.com/productboard-engineering/

Next, what else do we have…

Danger.js • Danger runs during your CI process, and gives teams the chance to automate common code review chores. • Make robots do chores! 🤖

Kodiak • Trunk based development • Integration on feature branch • Make robots do chores! 🤖 https://github.com/chdsbd/kodiak

Github Annotations Developers like to ignore CI outputs, bring it closer….

Bundle Size • Stay on top of bundle size • Bundle size budgets • Warn you in case you bundle something huge

Takeaways • Monorepos are not easy – at some scale you need dedicated team for it • If the setup is right, it speeds up things – especially if your codebase is interconnected. Tooling has great impact. Nx proven to be great for our use case. • You don’t need to be FAANG to have a swag.

Thank you!

Q&A • https://nx.dev • Scaling monorepo — to in nity and beyond! • How we measure adoption of a design system at Productboard https://danger.systems/js/ • https://github.com/chdsbd/kodiak fi • Jakub Beneš Engineering Manager @ Productboard @jukben @jukben https://jukben.codes