Skip to content

Commit

Permalink
docs: Task outputs clarifications (#9185)
Browse files Browse the repository at this point in the history
To avoid the impression that cache is disabled when Task `outputs` key
is ommitted.

`API reference` was more accurate for that behavior, than `Crafting your
repository`.

### Description

I'm new to Turborepo, and was reading [Crafting your
repository](https://turbo.build/repo/docs/crafting-your-repository). Two
sections lead me to conclude that when there is no `outputs` key in a
Task, then caching is disabled. I think the wording in `API reference`
is better.

We have to account for Logs output even if there are no file outputs
(which is really nice for linters).

### Testing Instructions

* Review the modified documentations.
* Take into account that I'm not a native english speaker (you probably
notice already ;) )
  • Loading branch information
boutchitos authored Sep 28, 2024
1 parent cd86f80 commit cc473cb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions docs/repo-docs/crafting-your-repository/caching.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,14 @@ For information on how to connect your CI machines to Remote Cache, visit [the C

## What gets cached?

Turborepo caches two types of outputs: Task outputs and Logs.

### Task outputs

Turborepo caches the file outputs of a task that are defined in [the `outputs` key](/repo/docs/reference/configuration#outputs) of `turbo.json`. When there's a cache hit, Turborepo will restore the files from the cache.

The `outputs` key is optional, see [the API reference](/repo/docs/reference/configuration#outputs) for how Turborepo behaves in this case.

<Callout type="warn" title="Providing file outputs">
If you do not declare file outputs for a task, Turborepo will not cache them. This might be okay for some tasks (like linters) - but many tasks produce files that you will want to be cached.

Expand Down
4 changes: 2 additions & 2 deletions docs/repo-docs/reference/configuration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -339,8 +339,6 @@ An allowlist of environment variables that should be made available to this task

A list of file glob patterns relative to the package's `package.json` to cache when the task is successfully completed.

Omitting this key or passing an empty array tells `turbo` to cache nothing (except logs, which are always cached when caching is enabled).

```jsonc title="./turbo.json"
{
"tasks": {
Expand All @@ -352,6 +350,8 @@ Omitting this key or passing an empty array tells `turbo` to cache nothing (exce
}
```

Omitting this key or passing an empty array tells `turbo` to cache nothing (except logs, which are always cached when caching is enabled).

### `cache`

Default: `true`
Expand Down

0 comments on commit cc473cb

Please sign in to comment.