Back to blog

Turborepo 1.5

Monday, September 19th, 2022
Matt Pocock
Name
Matt Pocock
X
@mattpocockuk
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

Turborepo 1.5 is a huge leap forward for our documentation and DX, as well as bringing big improvements to turbo prune:

Update today by running npm install turbo@latest.

The Monorepo Handbook

Setting up a monorepo for the first time often means navigating a lot of new concepts. You'll need to understand workspaces, package installation, sharing code and dependency management - and a lot more.

This often meant that folks who wanted to set up a monorepo from scratch had to piece information together from different documentation sites. First pnpm, then tsup, then back to changesets, then back to Turborepo for dessert.

We want to fill this gap with the Monorepo Handbook. We've built guides on how to integrate all the tools you'll need to make ship happen with your monorepo, including guides on:

Drop the run

You can now run tasks with the Turborepo CLI using turbo <task>.

Terminal
- turbo run build
+ turbo build
 
 
- turbo run lint build test
+ turbo lint build test

If your task name conflicts with a built-in turbo subcommand, we'll run our subcommand instead. That means you shouldn't name your tasks things like prune, run, or login - since those are built-in subcommands.

turbo run <task> will continue to work, and there are no plans to deprecate it.

Prune now supported on pnpm and yarn 2+

We're delighted to announce that turbo prune now supports in pnpm, yarn, and yarn 2+.

You can use turbo prune to create a pruned subset of your monorepo with a dedicated lockfile--with the correct dependencies needed for a given target application and its dependencies. This is especially useful for using efficiently Turborepo within a Docker image.

As part of the new handbook, we've also added a section on using turbo prune to build docker images.

Check out our previous blog on prune to learn more.

Environment variables in turbo.json

We've introduced two new keys to turbo.json - env and globalEnv. These allow environment variables to be configured separately from tasks:

turbo.json
{
  "globalDependencies": [
-   "$DATABASE_URL"
  ],
+ "globalEnv": [
+   "DATABASE_URL"
+ ],
  "pipeline": {
    "build": {
      "dependsOn": [
-       "$BUILD_ENV"
      ],
+     "env": [
+       "BUILD_ENV"
+     ]
    }
  }
}

globalEnv and env allow you to specify a list of environment variables without $ prefixes. This makes the configuration file significantly easier to read. Read more in our updated docs.

To help migrate from the previous syntax, we've prepared a codemod. You can run npx @turbo/codemod migrate-env-var-dependencies.

This work builds on the automatic env variable detection we added in 1.4.0.

Changes to package.json hashing

The package.json file in each workspace is now always considered an input for tasks in that workspace. This means that if you change the definition for a task in package.json, we want to invalidate any caches from the previous definition.

This also counts for the package.json in the root. Changes to the root package.json will invalidate tasks in the root workspace.

This helps make Turborepo's cache a bit smarter, and less likely to trip up when task definitions change.

Community

Since releasing Turborepo v1.4 in August, 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.

This release was brought to you by the contributions of: @7flash, @afady, @alexander-young, @atilafassina, @bguedes-moz, @bobaaaaa, @brunojppb, @chris-olszewski, @DoctorJohn, @erj826, @futantan, @gsoltis, @HosseinAgha, @ivov, @jaredpalmer, @joelhooks, @knownasnaffy, @laurentlucian, @leerob, @MarceloAlves, @mattpocock, @mauricekleine, @mehulkar, @Misikir, @nareshbhatia, @nathanhammond, @pakaponk, @PhentomPT, @renovate, @ruisaraiva19, @samuelhorn, @shemayas, @shuding, @t-i-0414, @theurgi, @tknickman, @yanmao-cc, and more!

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