-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Description
Verify canary release
- I verified that the issue exists in the latest Turborepo canary release.
Link to code that reproduces this issue
https://github.com/0xb4lamx/turborepo-ls-affected-accuracy-issue
Which canary version will you have in your reproduction?
2.5.6
Expected behavior
on changes to root package.json:
turbo ls --affectedshould only list packages that are actually affected by the change.
Note: According to Turborepo 2.1 release note,
turbo ls --affected --output=jsonwas introduced as a recommended replacement forturbo build --dry=jsonwhen you only need to retrieve a list of changed packages.
Actual behavior
on any random change to the root package.json:
turbo ls --affectedshows ALL packages as affected regardless of the change.turbo build --dry-run=jsonshows clear cache hit! (correct actual+expected behavior)
To Reproduce
-
Create a simple Turborepo with any packages:
npx create-turbo@latest test-repo cd test-repo -
Build to create initial cache:
pnpm install pnpm turbo build # This creates the cache that we'll test against -
Make a minimal change to root package.json:
# Add a space before the opening brace on line 1 sed -i '' '1s/{/ {/' package.json # Or manually edit. (add any random white space)
-
Check what turbo ls --affected shows:
pnpm turbo ls --affected
Result: Shows ALL packages as affected ❌
-
Check what turbo build --dry=json shows:
pnpm turbo build --dry=json | jq -c '. as $root | .tasks[] | { taskId, cache: .cache.status }'
Result: Shows ALL packages as
"cache":"HIT"✅
Additional context
this GH action job run could easily showcase the issue:
more details: https://github.com/0xb4lamx/turborepo-ls-affected-accuracy-issue/actions/runs/17892941470/job/50875748218.
I think --affected need to be more intelligent when handling changes to the root package.json (and turbo.json). A change in those files should not automatically mark all packages as affected unless the change actually impacts them.