2024-02-16 04:30:21 +00:00
|
|
|
|
## Monorepo
|
|
|
|
|
|
|
|
|
|
The monorepo uses Yarn (classic) workspaces.
|
|
|
|
|
|
|
|
|
|
To run a command for a workspace `<ws>`, invoke `yarn workspace <ws> <cmd>` from
|
2024-02-17 03:41:53 +00:00
|
|
|
|
the root folder instead the the `yarn <cmd>` you’d have done otherwise. For
|
2024-02-21 11:40:31 +00:00
|
|
|
|
example, to start a development server for the `photos` app, we can do
|
2024-02-17 03:41:53 +00:00
|
|
|
|
|
|
|
|
|
```sh
|
2024-02-21 11:40:31 +00:00
|
|
|
|
yarn workspace photos next dev
|
2024-02-17 03:41:53 +00:00
|
|
|
|
```
|
2024-02-16 04:30:21 +00:00
|
|
|
|
|
2024-02-21 11:40:31 +00:00
|
|
|
|
There is also a convenience alias, `yarn dev:photos`. See `package.json` for the
|
2024-02-21 11:50:09 +00:00
|
|
|
|
full list of such aliases. The two common patterns are `dev:<app-name>` for
|
|
|
|
|
running a local development server, and `build:<app-name>` for creating a
|
|
|
|
|
production build.
|
2024-02-21 11:40:31 +00:00
|
|
|
|
|
2024-02-22 06:52:07 +00:00
|
|
|
|
> Tip: `yarn dev` is a shorcut for `yarn dev:photos`
|
|
|
|
|
|
2024-02-21 11:48:55 +00:00
|
|
|
|
Note that yarn does not automatically update `node_modules` if you switch to a
|
|
|
|
|
branch that has added or modified dependencies. So if you encounter unexpected
|
2024-02-21 13:59:22 +00:00
|
|
|
|
errors on switching branches, make sure that your `node_modules` is up to date
|
2024-02-22 06:52:07 +00:00
|
|
|
|
by running `yarn install` first.
|
|
|
|
|
|
|
|
|
|
> `yarn` is a shortcut for `yarn install`
|
2024-02-21 11:48:55 +00:00
|
|
|
|
|
2024-02-16 04:30:21 +00:00
|
|
|
|
To add a local package as a dependency, use `<package-name>@*`. The "*" here
|
|
|
|
|
denotes any version.
|
|
|
|
|
|
|
|
|
|
```sh
|
|
|
|
|
yarn workspace photos add '@/utils@*'
|
|
|
|
|
```
|
|
|
|
|
|
2024-02-24 05:51:37 +00:00
|
|
|
|
> Note: The yarn (classic) command above causes harmless but noisy diffs in
|
|
|
|
|
> `yarn.lock` when adding or removing dependencies to the workspaces. To fix
|
|
|
|
|
> them, run `yarn` again once to reset these unnecessary changes.
|
|
|
|
|
|
2024-02-16 04:30:21 +00:00
|
|
|
|
To see what packages depend on each other locally, use
|
|
|
|
|
|
|
|
|
|
```sh
|
|
|
|
|
yarn workspaces info
|
|
|
|
|
```
|