How to use Gatsby with Redwood in a monorepo setup?

I wanted to add a sister package to my redwood app, and my search led me to this thread. In case anyone is reading this who normally uses Lerna, you should know you can just use yarn workspaces now and it works well with the existing redwood setup. I’ll post my details here in case it helps others.

root package.json. Add your new package (eg. "contracts’) to the Workspaces list.

{
  "private": true,
  "workspaces": {
    "packages": [
      "api",
      "web",
      "contracts"
    ]
  },
  "devDependencies": {
    "@redwoodjs/core": "^0.20.0"
  },
  "eslintConfig": {
    "extends": "@redwoodjs/eslint-config"
  },
  "engines": {
    "node": ">=12",
    "yarn": ">=1.15"
  }
}

Remove lerna config, since yarn workspaces satisfies my needs.

Then in web I can install my new package normally. Note if you have issues installing try adding the version eg. yarn add emanator-contracts@1.0.0

  "dependencies": {
    "emanator-contracts": "1.0.0",
  }

Full repo can be found https://github.com/emaNaFTe/monorepo

2 Likes