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

(docs): Improve clarity for watch. #8957

Merged
merged 3 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ turbo dev --filter=web

## Watch Mode

<LinkToDocumentation href="">`watch` reference</LinkToDocumentation>

Many tools have a built-in watcher, like [`tsc --watch`](https://www.typescriptlang.org/docs/handbook/compiler-options.html#compiler-options),
that will respond to changes in your source code. However, some don't.

Expand Down Expand Up @@ -137,6 +135,8 @@ When you run `turbo watch dev lint`, you'll see the `lint` scripts are re-run wh

The Next.js development server in `web` and the TypeScript Compiler's built-in watcher in `@repo/ui` will continue to work as usual, since they are marked with `persistent`.

For more information, [visit the `turbo watch` reference](/repo/docs/reference/watch).

## Limitations

### Teardown tasks
Expand Down
14 changes: 12 additions & 2 deletions docs/repo-docs/reference/watch.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,19 @@ turbo watch [tasks]

## Using `turbo watch` with persistent tasks

When your script has a built-in watcher, you likely don't need to use `turbo watch`. Instead, use your script's built-in watcher and mark the task as long-running using [`"persistent": true`](/repo/docs/reference/configuration#persistent).
Persistent tasks are marked with [`"persistent": true`](/repo/docs/reference/configuration#persistent), meaning they won't exit. Because of this, they cannot be depended on in your task graph.

Persistent tasks will continue to run as usual with `turbo watch`, allowing persistent and non-persistent tasks to be run at the same time.
This means that persistent tasks will be ignored when using `turbo watch`, working the same way they do with [`turbo run`](/repo/docs/reference/run), allowing persistent and non-persistent tasks to be run at the same time.

### Dependency-aware persistent tasks

When your script has a built-in watcher capable of detecting changes in dependencies, you don't need to use `turbo watch`. Instead, use your script's built-in watcher and mark the task as long-running using [`"persistent": true`](/repo/docs/reference/configuration#persistent).
anthonyshew marked this conversation as resolved.
Show resolved Hide resolved
anthonyshew marked this conversation as resolved.
Show resolved Hide resolved

### Persistent tasks without dependency awareness

Some tools aren't monorepo-friendly, and do not hot-reload modules in dependencies. While you may be tempted to use `turbo watch` with these tasks, they still won't be able to pick up on changes to dependencies.

Instead, you should make the task non-persistent and have `turbo watch` restart the task when changes to dependencies are detected.

## Limitations

Expand Down
Loading