This week we've been going over multi-package repo tools. Today I want to share a workflow that is enabled by those tools, even across different tooling.
Some of the work I do on Gatsby
requires me to work on the core
gatsby package or a small
number of other packages. I don't need to bootstrap the
entire repo, but I do need specific packages.
When I work on
I usually use a repo called
This repo is set up as a multi-package repo using Yarn
gatsby-theme-examples includes a couple of
themes and a couple of usages of said themes, so when I work
on new functionality like
PR on gatsby-theme-examples
that uses that functionality.
I handle both of these PRs to separate repos in the same multi-package repo that spans two git repos. The setup looks like this
I clone the gatsby repo into a sub-directory of the examples
repo, then point the Yarn Workspaces config in the theme
package.json to include the packages I need. By
default the workspaces config looks like
When working with a forked Gatsby repo I add the packages I
need, so if all I need is
gatsby, it looks like
Then I run
yarn to install all dependencies in the
examples repo and
gatsby requires a
build, I then run
yarn workspace gatsby build to build the
package and it's already linked into my themes repo for
This is a really powerful workflow that allows me to reduce the expensiveness of working with multi-package repos I don't necessarily control. It is so useful to be able to mount repos into each other when developing that I've started starting all my new repositories as multi-package repos using Yarn Workspaces. I've been doing this workflow for awhile now and it makes the cost of migrating packages across repos, working on multiple repos, and modifying forked packages much simpler. If you plan on starting a new project this year, I'd suggest trying to start it using Yarn Workspaces as it doesn't require much overhead at all and it enables a lot of flexibility.