Home
Support Forums

Lerna monorepo & branch deploys

Hi! Do people have experience and best practices how to combine a Lerna monorepo with Netlifys branch-deploy feature, and according git strategies?

Let’s say we have a bunch of Packages like this. app has components as a dependency. Packages are not pushed to any registry, but just used as local workspaces:

| packages/
|   components/
|      src/
|      package.json
|   app/
|      src/
|      package.json
|  ... many other packages
| package.json

In Netlify, we made a project and connected it to app. app also is our base directory, so that now builds only get triggered if changes have been done to app. Hurray!

However, what if we do a change to components? Since it is a dependency of app, it should also trigger a branch deploy of the later. One option would be to manually manage all the netlify ignore options for all of our websites, making sure builds also get triggered by changes of dependency packages. But thats no fun when dealing with a lot of packages!

Another option is using versions - if components changes, we could use lerna to automatically bump versions. Now there actually is a change in app (package.json changed), and the branch deploy would trigger. However, branch-deploys should be triggered on a lot of secondary branches all the time, while bumping versions on any branches that are not the primary branch is seens as a bad practice.

I am still new to Lerna, so I am sure there are best practices on how to deal with setups like this. Would love to hear what those are!

Hi @andre-b,

This would be a tough call. I’d personally have advised to use the whole repo and configure ignore command as needed, but since you’ve already removed that as a possibility, I’m not sure what more to suggest. That was the only Netlify-specific feature that could have helped you achieve what you wanted.

The other way would be to build locally and publish via CLI or API. That way, you don’t have to worry about too many builds or no builds at all.