Back to blog

Turborepo 1.8

Wednesday, February 22th, 2023
Greg Soltis
Name
Greg Soltis
X
@gsoltis
Nathan Hammond
Name
Nathan Hammond
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
Alexander Lyon
Name
Alexander Lyon
X
@_arlyon

Turborepo 1.8 brings better flexibility and more control to your codebase by improving turbo's understanding of your workspaces.

Update today by running npx @turbo/codemod migrate.

Workspace Configurations

In workspace directories, you can now add a turbo.json to:

This will enable teams to scale ownership of the projects in their monorepos by moving away from global configuration to fine-grain contol over tasks in workspaces.

For example, imagine your monorepo has a Next.js app and a SvelteKit app, and you want to use Turborepo to cache outputs of the build task. The Next.js build script creates a .next directory, whereas SvelteKit creates a .svelte-kit directory. Instead of adding both build directories in your root outputs, you can define the outputs key in the workspace instead:

turbo.json
{
  "pipeline": {
    "build": {
      "dependsOn": ["^codegen"],
      // no need to define outputs here!
    },
  },
}
apps/my-nextjs-app/turbo.json
{
  "extends": ["//"],
  "pipeline": {
    "build": {
      // dependsOn is inherited from root
      "outputs": [".next/**", "!.next/cache/**"],
    },
  },
}
apps/my-sveltekit-app/turbo.json
{
  "extends": ["//"],
  "pipeline": {
    "build": {
      // dependsOn is inherited from root
      "outputs": [".svelte-kit/**"],
    },
  },
}

The extends key in the Workspace Configurations enables workspace owners to use the best of the root turbo.json and customize the parts that makes their app different (The "//" sigil will look familiar if you’re used to defining tasks to run from your root).

Keys that are declared will replace the key from the root if those keys exist, overriding what is defined in your root configuration. Keys that are not declared are inherited from the root config.

In the example above, outputs is customized for both apps, while dependsOn is configured by the root turbo.json and remains "^codegen".

Learn more in the docs.

Automatic Workspace Scoping

In Turborepo v1.7, turbo became globally installable, giving you the power to run your tasks from anywhere in your codebase. However, turbo would still run tasks from the root, running tasks in other workspaces that you may not have intended to run.

With 1.8, turbo will automatically detect the workspace you are in and generate the --filter syntax to scope your task to that workspace.

As an example, if your current directory is apps/admin and you use the turbo build command, turbo will run turbo build --filter=admin under the hood, focusing on the workspace that you are working on.

Easier Migrations

Manually running individual codemods in the correct order is no longer required when upgrading Turborepo versions. @turbo/codemod now provides a simple migrate command which both upgrades your repo to the specified version (latest by default) of turbo, and runs any codemods required.

Try it out now with npx @turbo/codemod migrate.

Community

Since releasing Turborepo v1.7 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.