Skip to content

aruniverse/cospace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 

Repository files navigation

CoSpace

Setup a CoSpace to link multiple (mono)repos together!

Powered by

Getting started

  1. Install create-cospace, then run npx cospace init

  2. Clone all the repos you want to link together under the repos directory. You can use sparse checkouts to only clone the directories you need.

  3. Update the pnpm-workspace.yaml file with all the packages you want to add to your CoSpace.

  4. Update the cospace.code-workspace file with all the repos you want to add to your VsCode multi root workspace.

  5. (Optional) Run pnpm setOverrides to automatically update the pnpm.overrides section of the CoSpace's package.json, to use the local package version from the workspace, disregarding semver. Useful for when you have pre-release versions of packages in your workspace.

  6. Run pnpm install to install all the packages you've added to your CoSpace.

  7. Run pnpm build to build all the packages you've added to your CoSpace using your monorepo task runner. I'm using lage, but turborepo should theoretically work.

Notes

Additional Reading

sparse-checkouts

git clone --filter=blob:none --no-checkout {repo}
cd {repo}
git checkout {branchName}
git sparse-checkout init --cone
git sparse-checkout set [...allSubDirs]

pnpm

  • "If you need local packages to also be linked to subdependencies, you can use the deep setting"

    "pnpm": {
        "link-workspace-packages": "deep"
    }
  • pros: don't have to explicitly list all packages in the pnpm.overrides section.

  • cons: if you're linking a repo with HEAD pointing to pre-release packages, those won't be used/linked due to semver 😕

    "pnpm": {
        "prefer-workspace-packages": true
    }