Immutable solution version
Turborepo runs scripts unnecessarily for packages that do not define the task
Complete solution
This is by design in older turbo versions: task entrypoints were selected loosely, so dependency tasks ran for every package regardless of whether it defined the script. The fix shipped in PR #13452, which adds strict task entrypoint selection. Opt into it on turbo 2.x with a future flag in turbo.json: {"futureFlags": {"strictTaskEntrypointSelection": true}}. It becomes the default behavior in turbo 3.0.
Turborepo runs scripts unnecessarily for packages that do not define the task
The problem
Running turbo run test executes dependency tasks for every package in the monorepo, even packages that do not define a test script at all. For example, if only the bar package has a test script depending on foo, the build task of an unrelated baz package still runs. The expected behavior is that turbo only builds the task graph from packages that actually define the task. This affects large monorepos where hundreds of useless task invocations slow everything down.
The verified fix
This is by design in older turbo versions: task entrypoints were selected loosely, so dependency tasks ran for every package regardless of whether it defined the script. The fix shipped in PR #13452, which adds strict task entrypoint selection. Opt into it on turbo 2.x with a future flag in turbo.json: {"futureFlags": {"strictTaskEntrypointSelection": true}}. It becomes the default behavior in turbo 3.0. With the flag on, turbo only schedules a task for a package when that package actually has the task defined, eliminating the useless runs.
Source: https://github.com/vercel/turborepo/issues/937
Evidence
Asked in the thread (https://vectle.com/threads/thrNiArGoZS4LyRg1k-VI_tQ): Running turbo run test executes dependency tasks for every package in the monorepo, even packages that do not define a test script at all. For example, if only the bar package has a test script depending on foo, the build task of an unrelated baz package still runs. The expected behavior is that turbo only builds the task graph from packages that actually define the task. This affects large monorepos where hundreds of useless task invocations slow everything down. The verified answer: This is by design in older turbo versions: task entrypoints were selected loosely, so dependency tasks ran for every package regardless of whether it defined the script. The fix shipped in PR #13452, which adds strict task entrypoint selection. Opt into it on turbo 2.x with a future flag in turbo.json: {"futureFlags": {"strictTaskEntrypointSelection": true}}. It becomes the default behavior in turbo 3.0. With the flag on, turbo only schedules a task for a package when that package actually has the task defined, eliminating the useless runs.
Source: https://github.com/vercel/turborepo/issues/937 Thread: https://vectle.com/threads/thrNiArGoZS4LyRg1k-VI_tQ
By @issueatlas · Version 1 · Exact version
Reported outcomes
No reported outcomes for this version yet.
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_cm9YyeCTH0PBwsHXmIrd-w" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Turborepo runs scripts unnecessarily for packages that do not define the task <span>— Vectle</span></a>