Back to blog

Turborepo 2.1

Tuesday, August 27th, 2024
Tom Knickman
Name
Tom Knickman
X
@tknickman
Anthony Shew
Name
Anthony Shew
X
@anthonysheww
Chris Olszewski
Name
Chris Olszewski
Nicholas Yang
Name
Nicholas Yang
X
@nicholaslyang
Dimitri Mitropoulos
Name
Dimitri Mitropoulos

Turborepo 2.1 improves integration with your repository, with features like:

Update today by running npx @turbo/codemod migrate or get started with npx create-turbo@latest.

Run tasks for changed packages with --affected

Turborepo’s Remote Caching shares a single cache across all of your machines, so you never have to do the same work twice. But, what if you could ignore unchanged packages altogether?

You can now use the --affected flag with turbo run to automatically target packages with changes between the latest commit of your current branch, and the default branch of your repository (usually main or master). turbo will use your Package Graph to ensure tasks are run for packages with direct changes or changes to internal dependencies.

Terminal
turbo run lint test --affected

You'll want to use this flag in situations like:

To learn more, visit the documentation.

Repository exploration tools

As a repository grows and changes, it can be difficult to quickly find what you’re looking for. We want to quickly surface your tasks, packages, and their relationships to make understanding your repository faster and easier.

turbo run

Use turbo run (with no task arguments) to get a list of the available tasks in your repository. This command also works with filters and Automatic Package Scoping.

Terminal
# List all tasks in the repository
turbo run
 
# List tasks in a specific package
turbo run --filter=@repo/ui
 
# Using Automatic Package Scoping
cd packages/ui && turbo run

Visit the documentation to learn more.

turbo ls

Use turbo ls to get a list of all the packages in your repository with their locations, or filter to a specific package to see a summary of its internal dependencies and tasks. turbo ls also supports --filter, and --affected, making it easy to gather a list of changed packages.

Terminal
# List all packages in the repository
turbo ls
 
# List dependencies and tasks for the `web` package
turbo ls web
 
## List affected packages
turbo ls --affected

turbo ls supports an experimental --output flag that can be used to return results in a specific format. For example, --output=json can be used to more easily create inputs for other tools or custom scripts. If you were previously using turbo build --dry=json only to retrieve a list of changed packages, give turbo ls --affected --output=json a try. Visit the docs for more information and leave feedback on output format on the turbo ls RFC.

Visit the documentation to learn more.

Terminal UI Improvements

In Turborepo 2.0, we released a new terminal UI to improve clarity for logs and allow for interactive tasks in local development. We heard your feedback, and prioritized polishing this UI, releasing improvements in patches to 2.0 and in this 2.1 release:

Building a great terminal UI experience has unique challenges, and we’re continuing to iterate on this experience. We appreciate your continued feedback as we keep up our work on creating great UI for monorepos.

Expanded configuration options

In this release, we’re adding more keys to turbo.json to give you more flexibility for your repository’s defaults. The following keys are new in this release:

turbo.json
{
  "envMode": "loose",
  "daemon": false,
  "cacheDir": "./my-custom-directory/"
}

You may have been using the flag equivalents for these configurations on many or all of your turbo invocations, littering your codebase with commands like:

Terminal
turbo run build --env-mode=loose --no-daemon --cache-dir=./my-custom-directory

These can now be simplified with a centralized configuration in turbo.json using Turborepo’s existing configuration model:

To learn more about available options and configurations, visit the documentation.

Other improvements

View the full changelog at vercel/turborepo.

Community

Since releasing Turborepo 2.0 we've seen incredible adoption and community growth:

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

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