Enforce boundaries with tags
turbo boundaries flags reach-in imports, undeclared deps and cycles.
Turborepo docsturborepo.dev
Catches violations before runtime/build errors
From turborepo, boundaries/RULE.md.
Green build, broken layers
Toggle imports into the code, then run the check.
Build onlyBad
turbo run buildBoundariesGood
turbo boundaries && turbo run build// packages/db/turbo.json
{ "tags": ["internal"] }
// apps/web/turbo.json
{ "tags": ["public"] }
// turbo.json
{
"boundaries": {
"tags": {
"public": { "dependencies": { "deny": ["internal"] } }
}
}
}
Why it matters, pros and cons
Why it matters
Hoisted node_modules and relative paths let bad imports build fine. They only fail later, in prune, a deploy or a refactor.
Pros
- Undeclared deps get caught before a Docker prune.
- Tag rules apply to dependencies of dependencies.
- Cycles show their full path.
Cons
- Experimental; output may change.
- Tags need upkeep as packages move.
- Adds a step to CI.