Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify how task skipping works when scripts are not implemented #4851

Merged
merged 3 commits into from May 5, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
73 changes: 68 additions & 5 deletions docs/pages/repo/docs/core-concepts/monorepos/running-tasks.mdx
Expand Up @@ -5,6 +5,7 @@ description: Turborepo helps you specify task dependencies declaratively.

import Callout from "../../../../../components/Callout";
import HeartIcon from "@heroicons/react/solid/HeartIcon";
import { Tabs, Tab } from '../../../../../components/Tabs'

# Running Tasks in a Monorepo

Expand Down Expand Up @@ -304,12 +305,74 @@ In this pipeline, we create an intermediary placeholder `topo` task. Since we do
fanning out tasks in such a concise and elegant way.
</Callout>

### Tips
### Incremental Adoption

#### Tasks that are in the `pipeline` but not in SOME `package.json`
After you've declared a task in `turbo.json`, it's up to you to implement it in
your `package.json` manifests. You can add scripts all at once, or one workspace
at at a time. Turborepo will gracefully skip workspaces that don't include the
task in their respective package.json manifest. We think this is a great way to
try out Turborepo without making large changes to your codebase.
mehulkar marked this conversation as resolved.
Show resolved Hide resolved
mehulkar marked this conversation as resolved.
Show resolved Hide resolved

Sometimes tasks declared in the `pipeline` are not present in all workspaces' `package.json` files. `turbo` will gracefully ignore those. No problem!
For example, if your repository has three workspaces:

#### `pipeline` tasks are the only ones that `turbo` knows about
```bash
apps/
web/package.json
docs/package.json
packages/
ui/package.json
turbo.json
package.json
```

where `turbo.json` declares a `build` task, but only two `package.json`'s implement that `build`
task:

<Tabs items={['turbo.json', 'web', 'docs', 'ui']} storageKey="skipped-tasks-example">
<Tab>
```jsonc filename="turbo.json"
{
"$schema": "https://turbo.build/schema.json",
"pipeline": {
"build": {}
}
}
```
</Tab>
<Tab>
```jsonc filename="apps/web/package.json"
{
"name": "web",
"scripts": {
"build": "next build"
}
}
```
</Tab>
<Tab>
```jsonc filename="apps/docs/package.json"
{
"name": "docs",
"scripts": {
"build": "vite build"
}
}
```
</Tab>
<Tab>
⚠️ Note the missing `build` script!
```jsonc filename="packages/ui/package.json"
{
"name": "ui",
"scripts": {}
}
```
</Tab>
</Tabs>

```bash
turbo run build
```

`turbo` will only account for tasks declared in the `pipeline` configuration. If it's not listed there, `turbo` will not know how to run them.
A turbo build will only execute the `build` script for the `web` and `docs` workspaces. The
`ui` package will still be in the task graph, but will gracefully be skipped.