Back to Turborepo

Turborepo 1.7

apps/docs/content/blog/turbo-1-7-0.mdx

2.9.97.2 KB
Original Source

import { Tabs, Tab } from "fumadocs-ui/components/tabs";

import TurboInferenceImage from "../../public/images/blog/turbo-1-7-0/turbo-inference.png";

Turborepo 1.7

import { Badge } from "@/components/ui/badge"; import { Authors } from "@/components/blog/authors"; import { Date } from "@/components/blog/date";

<Date>Wednesday, January 11th, 2023</Date>

<Authors authors={[ "gregsoltis", "nathanhammond", "tomknickman", "anthonyshew", "jaredpalmer", "mehulkar", "chrisolszewski", "nicholasyang", ]} />

Turborepo 1.7 focuses on improving developer experience by bringing more clarity to your tasks:

Update today by running npm install turbo@latest, or by installing globally <Badge>NEW</Badge> and running the set-default-outputs codemod.

Schedule your long-running tasks with confidence

To avoid misconfigurations that could result in tasks that never run, you can now tell Turborepo about tasks that won't exit on their own (like dev scripts) with a persistent: true configuration option. When this config is set on a task, Turborepo will ensure no other task can depend on this task. This is useful for dev tasks or test runners with --watch flags.

diff
{
	"pipeline": {
		"dev": {
+			"persistent": true
		}
	}
}

Previously, if Task B depended on a persistent Task A, Task B would never execute, because Task A never exited. By declaring Task A as persistent, Turborepo will prevent this error scenario from happening.

Before this release, we had been recommending the use of turbo run <task> --parallel for persistent tasks. With --parallel, turbo would ignore your dependency graph and execute all your tasks at once.

While --parallel did provide a helpful escape hatch, it meant that users had to tell Turborepo how to run their tasks rather than declaring what a task is.

Rather than throwing away your entire topological dependency graph, it's much more precise for Turborepo to keep your dependency graph while guaranteeing that you don't depend on a process that won't exit with persistent: true.

Global turbo

You can now run your Turborepo tasks from anywhere in your project once you've installed turbo globally. To do so, use:

<Tabs items={["npm", "yarn", "pnpm"]} storageKey="selected-pkg-manager"> <Tab value="npm">

bash
npm install turbo --global
</Tab> <Tab value="yarn"> ```bash title="Terminal" yarn global add turbo ``` </Tab> <Tab value="pnpm"> ```bash title="Terminal" pnpm add turbo --global ``` </Tab> </Tabs>

turbo will now work in any project. To find your local turbo version, turbo will walk through a few steps, always looking upward from your current directory:

  1. Find the nearest turbo.json.
  2. If one is not found, find the first package.json with a workspaces property.
  3. If one is not found, find the first package.json.

Your globally installed version of turbo will only be used when a locally installed version of turbo does not exist or cannot be found.

<ThemeAwareImage light={{ alt: "Turborepo inference diagram showing how turbo finds your local turbo version", src: TurboInferenceImage, props: { width: 800, height: 400 }, }} dark={{ alt: "Turborepo inference diagram showing how turbo finds your local turbo version", src: TurboInferenceImage, props: { width: 800, height: 400 }, }} />

turbo --version and turbo bin will show you the version and binary location, respectively, of the copy of turbo that will execute your tasks. Additionally, running with -vv or --verbosity=2 will always show if your local, or global turbo is being used.

bash
turbo --version --verbosity=2
2023-01-11T10:49:04.042-0500 [DEBUG] turborepo_lib::shim: No local turbo binary found at: /Users/knickman/Developer/vercel/my-awesome-monorepo/node_modules/.bin/turbo
2023-01-11T10:49:04.042-0500 [DEBUG] turborepo_lib::shim: Running command as global turbo
1.7.0

Declare your outputs for improved clarity

Previously, if you did not specify an outputs key for a task, Turborepo would automatically attempt to cache all files in the dist/ and build/ directories.

This worked well for build tasks of specific frameworks, but this implicit behavior did not scale well as it applied to all tasks. We've found that, across the many developers, teams, projects, and codebases using Turborepo, the assumption to automatically cache dist/ and build/ directories was causing problems for users.

In version 1.7, this behavior is removed and you will now need to explicitly tell turborepo what to cache.

diff
{
  "pipeline": {
    "build": {
+     "outputs": ["dist/**", "build/**"]
    }
  }
}

If you were relying on the default cache output in Turborepo versions below 1.7, you can get the same behavior by running the @turbo/codemod set-default-outputs codemod:

bash
npx @turbo/codemod set-default-outputs

Also note that you will no longer need to specify outputs: [] because not caching anything is now the default behavior. The codemod will also remove this configuration from your tasks.

“Errors only” output mode for quieter logs

To bring visibility to errors, community member @dobesv contributed a solution to only show errors instead of all logs from a task run. While debugging a pipeline, --output-logs=errors-only can be used to keep your signal-to-noise ratio high so you can focus on ensuring successful runs for your pipelines. This can be used as a configuration option or as a CLI flag

bash
turbo build --output-logs=errors-only

Community

Since releasing Turborepo v1.6 and merging with Turbopack, we've seen incredible adoption and community growth:

Turborepo is the result of the combined work of all of our contributors including our core team.

Thank you for your continued support, feedback, and collaboration to make Turborepo your build tool of choice.