^build runs dependencies first

The caret points at dependency packages, so builds run in waves.

Turborepo docsturborepo.dev
The ^ prefix is crucial - without it, you're referencing the same package.
Configuration referenceRead docs ↗

From turborepo, configuration/tasks.md.

Build in waves

Run a cold build of five packages.

No dependency orderBad
"build": { "dependsOn": [] }
^buildGood
"build": { "dependsOn": ["^build"] }
{
  "tasks": {
    "build": {
      "dependsOn": ["^build"],      // every dependency's build first
      "outputs": ["dist/**"]
    },
    "test": { "dependsOn": ["build"] },       // no ^: this package's build
    "deploy": { "dependsOn": ["web#build"] }  // one package's task
  }
}

A dependency edit reaches up

Everything is cached. Edit utils and build.

No dependency orderBad
0 rebuilt0 stale hits
"dependsOn": []
^buildGood
0 rebuilt0 stale hits
"dependsOn": ["^build"]

Why it matters, pros and cons

Why it matters

A task's hash includes the hashes of the tasks it depends on. ^build adds those edges for every declared dependency.

Pros

  • Libraries finish before the apps that import them.
  • Independent packages still build in parallel.
  • A dependency change invalidates its dependents.

Cons

  • Only declared package.json dependencies get an edge.
  • A long chain is a long critical path.
  • ^lint is too strict; see transit nodes.