Example repo on how to use yarn workspaces together with the serverless framework.
Example repo on how to use yarn workspaces together with the serverless framework. Utilizes Typescript references.
Simply create a new folder in packages
and run yarn init
. Prefix serverless services with the sls-
prefix, such that their dependencies will not be hoisted (the serverless framework doesn't support hoisted packages at the moment). Ensure that the package has a local tsconfig.json
. When your Typescript package depends on another typescript package within the mono repo, reference to it using the package's tsconfig.json
.
If your external packages does not have types available from the DefinitelyTypes project (e.g. @types/my-package
), you can easily define custom typings in the special packages/types
package.
To run tests in all packages, run yarn test
from the root folder.
To run tests in a specific package, run yarn test
from the package's folder.
To build all packages based on their dependency graph order, run yarn build
from the root folder
To build a specific package including the packages it references to, run yarn build
from the package folder.
To deploy a serverless service, run yarn deploy --stage=dev --aws-profile=profile-name
from the package folder. This will build the Typescript packages used by that serverless service.
To deploy all serverless services, run the same command from the root folder.
yarn install --production
, but this is a slow process and is therefore not yet integrated into the master branch.