Difficulty with new monorepo deployment options

I’m having trouble with the new monorepo deployment options to the point that I can’t deploy a site that uses a standard monorepo setup with yarn workspace.

Netlify have the option to change the base directory for sites now which means I can built from multiple directories - which is great - but it only uses yarn if it finds a yarn.lock in the directory that sites are built from. In most monorepos I have multiple sites but also packages that are shared between sites. With a yarn workspaces setup you would not have a yarn.lock for each site or the package directory:

/site-a/ /* no yarn lock so will use npm */
/site-b/ /* no yarn lock so will use npm */
/packages/shared-module/  /* no yarn lock */

Since we don’t have lock files in package directories it will not install correctly because yarn workspaces is aware that /packages/shared-module/ is a local package but npm is not.

Sorry that is quite technical and very specific to monorepos but it really makes the new Netlify features difficult to use with real monorepos and it could possibly be “easily” fixed. Or perhaps you know a workaround?

I’m trying to write about this at the moment and I’d love to promote these features.

Hi @MadeByMike thanks for taking the time and opening the post. Our monorepo feature is built for repos that have their frontend in a subdirectory along with the yarn.lock. One of my peers has suggested some alternatives to this use case at Build monorepo project on netlify. We understand that the experience is not entirely optimal. We do look forward to releasing some more documentation around this support in the coming weeks. Hope that helps. Thanks!

Hmmm, this rules out many of the main use-cases for monorepos. I might even say that although you support multi-package repositories you can’t really support monorepos without being able to build from yarn workspaces or similar.

Maybe I can’t argue too strongly since definitions and people’s understanding of “monorepo” varies widely. But I can say it’s not going to match a lot of peoples expectations.

How hard would it be to detect a yarn workspace set-up (or allow a user to signal this) and change how the build works?

Any chance could get me an indication if this is going to be on the roadmap?

@MadeByMike Totally hear you on this. It is definitely top of our minds and something we are considering into the roadmap. I am unfortunately unable to give out a timeline yet. But, we definitely would love to have a seamless experience here.

1 Like