{"id":28486054,"url":"https://github.com/sst/lerna-yarn-starter","last_synced_at":"2025-07-02T09:31:46.190Z","repository":{"id":45698341,"uuid":"379416084","full_name":"sst/lerna-yarn-starter","owner":"sst","description":"SST monorepo starter that uses Lerna and Yarn Workspaces.","archived":false,"fork":false,"pushed_at":"2021-08-13T11:39:36.000Z","size":286,"stargazers_count":23,"open_issues_count":1,"forks_count":3,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-06-08T01:10:32.639Z","etag":null,"topics":["lerna","monorepo","sst","yarn","yarn-workspaces"],"latest_commit_sha":null,"homepage":"https://serverless-stack.com/chapters/using-lerna-and-yarn-workspaces-with-serverless.html","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sst.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-06-22T22:29:11.000Z","updated_at":"2024-04-23T17:15:52.000Z","dependencies_parsed_at":"2022-08-30T14:10:30.426Z","dependency_job_id":null,"html_url":"https://github.com/sst/lerna-yarn-starter","commit_stats":null,"previous_names":["sst/lerna-yarn-starter","serverless-stack/lerna-yarn-starter"],"tags_count":0,"template":true,"template_full_name":null,"purl":"pkg:github/sst/lerna-yarn-starter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sst%2Flerna-yarn-starter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sst%2Flerna-yarn-starter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sst%2Flerna-yarn-starter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sst%2Flerna-yarn-starter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sst","download_url":"https://codeload.github.com/sst/lerna-yarn-starter/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sst%2Flerna-yarn-starter/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263111469,"owners_count":23415463,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["lerna","monorepo","sst","yarn","yarn-workspaces"],"created_at":"2025-06-08T01:10:08.343Z","updated_at":"2025-07-02T09:31:46.168Z","avatar_url":"https://github.com/sst.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SST Lerna + Yarn Workspaces Starter [![Seed Status](https://api.seed.run/serverless-stack/lerna-yarn-starter/stages/dev/build_badge)](https://console.seed.run/serverless-stack/lerna-yarn-starter)\n\nA [Serverless Stack Framework (SST)](https://github.com/serverless-stack/serverless-stack) monorepo starter that uses [Lerna](https://lerna.js.org) and [Yarn Workspaces](https://classic.yarnpkg.com/en/docs/workspaces/).\n\n- A full-stack serverless app\n- Designed to scale for larger teams\n- Maintains internal dependencies as packages\n- Supports publishing dependencies as private NPM packages\n- Uses Yarn Workspaces to hoist packages to the root `node_modules/` directory\n\n-----\n\n## Installation\n\nStart by cloning this repo\n\n``` bash\n$ git clone https://github.com/serverless-stack/lerna-yarn-starter my-project\n```\n\nEnter the new directory\n\n``` bash\n$ cd my-project\n```\n\nInstall npm packages for the entire project\n\n``` bash\n$ yarn\n```\n\n## How It Works\n\nThe directory structure roughly looks like:\n\n```\npackage.json\n/lib\n/frontend\n  package.json\n/src\n  /services\n    /service1\n      handler.js\n      package.json\n    /service2\n      handler.js\n      package.json\n  /packages\n    /sample-package\n      index.js\n      package.json\n  /util\n```\n\nThis repo is split into a few parts. Each with a different purpose:\n\n- `lib/`\n\n  This is where the CDK code for your app lives. It defines the infrastructure of your serverless app.\n\n- `src/`\n\n  This is where the code for your Lambda function are. It is further organized into services. Where each service is a collection of Lambda functions.\n\n- `src/services/`\n\n  These are services that are deployed as Lambda functions. Has a `package.json` and an entry point. There are two sample services.\n\n  1. `service1`: Depends on the `sample-package`.\n  2. `service2`: Does not depend on any internal packages.\n\n- `src/packages/`\n\n  These are internal packages that are used in our services. Each contains a `package.json` and can be optionally published to npm.\n\n- `src/util/`\n\n  Any common code that you might not want to maintain as a package. Does NOT have a `package.json`.\n\n- `frontend/`\n\n  A sample frontend React app that is a part of our serverless app.\n\nThe `src/packages/`, `src/services/`, and `frontend/` directories are Yarn Workspaces.\n\n### Services\n\nEach service is a collection of Lambda functions with a similar purpose. They are meant to be managed on their own. They each have their own `package.json` and the versions of the dependencies should be kept separate from the other services. SST internally uses [esbuild](https://github.com/evanw/esbuild) to optimally package each Lambda function in a service.\n\nThis is good for keeping your Lambda packages small. But Yarn Workspaces also ensures that it hoists all your npm packages to the project root.\n\n### Packages\n\nSince each package has its own `package.json`, you can manage it just like you would any other npm package.\n\nTo add a new package:\n\n``` bash\n$ mkdir src/packages/new-package\n$ yarn init\n```\n\nPackages can also be optionally published to npm.\n\nTo use a package:\n\n```bash\n$ yarn add new-package@1.0.0\n```\n\nNote that packages should be added by specifying the version number declared in their `package.json`. Otherwise, Yarn tries to find the dependency in the registry.\n\n### Util\n\nIf you need to add any other common code in your repo that won't be maintained as a package, add it to the util directory. It does not contain a `package.json`. This means that you'll need to install any npm packages as dependencies in the root.\n\nTo install an npm package at the root.\n\n``` bash\n$ yarn add -W some-npm-package\n```\n\nWhile it's convenient to add all the common code to the util, it has a downside. If a team updates the util, all the services that are dependent on it will need to test this change before deploying. In contrast, a package can be locked to a specific version and can be upgraded when the team chooses to.\n\n## Deployment\n\nSST will handle all the dependencies internally and deploy all the services (and the frontend) in order.\n\n## Deploying Through Seed\n\n[Seed](https://seed.run) supports deploying SST monorepo projects that use Lerna and Yarn Workspaces out of the box.\n\n-------\n\nThis repo is maintained by [Serverless Stack](https://serverless-stack.com/).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsst%2Flerna-yarn-starter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsst%2Flerna-yarn-starter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsst%2Flerna-yarn-starter/lists"}