Back to blog

Turborepo 1.10

Thursday, June 1st, 2023
Nathan Hammond
Name
Nathan Hammond
Tom Knickman
Name
Tom Knickman
X
@tknickman
Anthony Shew
Name
Anthony Shew
X
@anthonysheww
Mehul Kar
Name
Mehul Kar
X
@mehulkar

Turborepo 1.10 introduces new features to improve your local development experience:

Update today with

Terminal
npx @turbo/codemod migrate

Code Generators

turbo-gen

Turborepo Generators allow you to add new code to your repository in a predictable, structured way. Previously, you would need to copy code yourself and manually add dependencies to your new workspace. With Generators, we've automated the process of creating new workspaces and integrating them into your repository.

You can create a blank workspace from scratch, copy an existing workspace, or even create custom generators for more control. Custom generators leverage Plop configurations, a common template definition strategy used in the JavaScript ecosystem.

Custom generators can also be used to scaffold more granular sets of code than workspaces. You can significantly speed up tasks like:

Get started with your first generator by running:

Terminal
turbo gen

For more, check out the documentation.

Improved Environment Variable Inputs

Support for .env files

.env files are commonly used to load environment variables. This can cause problems when running with turbo, because these variables can be invisible, and are not easily included in the hash for your task. This problem could cause unintended cache hits while working locally.

Turborepo now makes this much easier with automatic support for .env files.

To ensure that Turborepo includes these variables in your hash, use the dotEnv key. For example, here is a configuration for a Next.js application:

./turbo.json
{
  "$schema": "https://turbo.build/schema.json",
  "globalDotEnv": [".env"],
  "pipeline": {
    "build": {
      "dotEnv": [
        ".env.production.local",
        ".env.local",
        ".env.production",
        ".env"
      ]
    },
    "dev": {
      "dotEnv": [
        ".env.development.local",
        ".env.local",
        ".env.development",
        ".env"
      ]
    },
    "test": {
      "dotEnv": [".env.test.local", ".env.test", ".env"]
    }
  }
}

This feature does not handle system environment variables. If you are not using .env files outside of development, make sure your environment variables are still enumerated in either env, or globalEnv to ensure they are included in your hash.

For more, check out the documentation.

Environment Variable Wildcards

Large applications can end up with many environment variables in their turbo.json. This can make your configuration difficult to manage and maintain.

With wildcards, you can now specify patterns of variables to include in your hash.

./turbo.json
{
  "$schema": "https://turbo.build/schema.json",
  "pipeline": {
    "build": {
      "env": ["ACME_*"]
    }
  }
}

For more, check out the documentation.

Environment modes

Turborepo environment modes are now out of experimental mode and are available for general use.

By default, and when turbo run is invoked with --env-mode=loose, all environment variables from the machine are made available to every single Turborepo task. This ensures the greatest compatibility while accepting some risk that a task will implicitly have access to a environment variable that is not specified in your turbo.json.

In the new strict mode, when turbo is invoked with --env-mode=strict, only important system environment variables and environment variables enumerated inside of turbo.json will be made available to a task.

For more, check out the documentation.

Community

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