CoSpace
February 4, 2022
CoSpace, a thin cli wrapper around pnpm workspaces to help link multiple (mono)repos together.
While working across multiple monorepos I found myself wanting to quickly test out changes I was making in my platform's sdk with one of our products. I was never satisifed with npm link
or yalc
or other solutions; and there were way too many packages to link together. I wished there was an easy way to build a monorepo consisting of other monorepos, a megarepo if you will, and link everything together. That way I could quickly prototype and test changes seamlessly. And that's how CoSpace
was born.
Powered by
stats
Fetching stats...
Create a new CoSpace
Initialize
npx cospace@latest init my-cospace
Link your (mono)repos
cd my-cospace
-
Clone all the repos you want to link together under the
repos
sub directory. -
Update the
pnpm-workspace.yaml
file with all the packages you want to add to yourCoSpace
. By default all packages under therepos
sub directory will be added to yourCoSpace
; you will probably want to be more specific and build/link only what you need. -
Update the
cospace.code-workspace
file with all the repos you want to add to your vscode multi-root workspace. -
Run
pnpm exec cospace override
to automatically update thepnpm.overrides
section of theCoSpace
'spackage.json
, to link all the dependencies together with the copy found in the workspace. This will ignore semver and always use the local package version from the workspace, very useful for when you have pre-release versions of packages in your workspace. -
Run
pnpm install
to install all the packages you've added to yourCoSpace
. -
Run
pnpm build
to build all the packages you've added to yourCoSpace
using your monorepo task runner. By default we use lage, but turborepo should work as well.
For more information visit the docs site.
example usage
- itwin-cospace, an example of a
CoSpace
to help develop with the iTwin Platform.