Turborepo 1.7

Turborepo 1.7

Wednesday, January 11th, 2023
Greg Soltis
Name
Greg Soltis
X
@gsoltis
Nathan Hammond
Name
Nathan Hammond
X
@nathanhammond
Tom Knickman
Name
Tom Knickman
X
@tknickman
Anthony Shew
Name
Anthony Shew
X
@anthonysheww
Jared Palmer
Name
Jared Palmer
X
@jaredpalmer
Mehul Kar
Name
Mehul Kar
X
@mehulkar
Chris Olszewski
Name
Chris Olszewski
Nicholas Yang
Name
Nicholas Yang
X
@nicholaslyang

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 NEW 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.

{
	"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:

bash npm install turbo --global

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.

turbo-inference

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.

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.

{
  "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:

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 (opens in a new tab) contributed a solution to only show errors instead of all logs from a task run (opens in a new tab). 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

turbo build --output-logs=errors-only

Community

Since releasing Turborepo v1.6 and merging with Turbopack (opens in a new tab), 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.