Using Lerna and Yarn Workspaces with Serverless

Link to chapter — https://serverless-stack.com/chapters/using-lerna-and-yarn-workspaces-with-serverless.html

I used this and managed to get through all of it working today. Super good, hit only one snag:

The individual services are using serverless-bundle. The documentation there shows support for aliases via custom:bundle:aliases in serverless.yml.

Adding that section in the serverless.yml for a service, I couldn’t come up with any combination that seems to properly resolve the alias. I’m pretty sure the aliasing is a pretty new feature of serverless-bundle, does it not yet work in the Lerna/Yarn starter? If it does, and /libs and /services are peer folders, what would you need in the aliases section to get it to work in this kind of monorepo?

I don’t know whether this is further complicated because I was trying it using serverless-offline and didn’t try it in an actual deploy, but I don’t think that should matter.

1 Like

Thanks!

Yeah it shouldn’t matter. Can you open an issue over on GitHub (if you haven’t already)?

I dug into the code and seem to have figured it out. You need to give the alias a relative path starting from the location of the serverless.yml file, such as:

bundle:
    aliases:
          - "Libs": ../../libs

That ended up working for me.

1 Like

Is there a way to ignore changes to some files when determining what to deploy?

For instance if a README.md is updated, this would trigger a redeployment of everything.

Hmm Lerna shouldn’t pick those up? Is that what you are using?