turbo
39d623e1 - feat: Make turbo watch Cargo-aware (#13280)

Commit
71 days ago
feat: Make turbo watch Cargo-aware (#13280) ## Why Next in the Cargo workspace series. `turbo watch` in a Cargo-enabled repo has two failure modes today: the watcher's private package graph is JS-only (crate edits map to nothing), and nothing protects against the feedback loop where Cargo's continuous `target/` writes re-trigger the very tasks that produced them. Per the series design, the fix is a trait surface — `Toolchain::watch_spec` — with both implementations stated honestly. ## What - `Toolchain::watch_spec`: workspace-definition file names/paths (change → full rediscovery) and build-byproduct directory prefixes (events dropped). Plain-string data per the toolchain design rules - **Cargo**: any `Cargo.toml` or the root `Cargo.lock` triggers rediscovery (the crate set or its edges may have changed); manifests under `target/` are exempt; all events under root `target/` are dropped — the feedback loop must not depend on a `.gitignore` entry - **JavaScript**: declares nothing extra, documented as the real answer — JS workspace redefinition is already caught by the change mapper's conservative all-packages fallback - The watcher builds its package graph with the same toolchains a run registers (plumbed from the future flag in `watch.rs` and `daemon.rs`), so watch sees the run's package set - Known gap documented in ARCHITECTURE.md: hash-watcher content dedup is JS-glob-based, so a no-op crate save re-runs as a fast cache hit - Rider: one-line collapsible-if fix in `turborepo-napi` that currently breaks `cargo lint` on main (and therefore every contributor's pre-push hook) — flagged here rather than a separate PR since it blocks this branch's own push ## How Flag off: watcher behavior is unchanged (the merged spec is empty; classify short-circuits identically). Flag on, verified live under `turbo watch` on the `cargo_monorepo` fixture: dependency-crate source edit re-runs the entrypoint; JS edit re-runs only the JS package; writes under `target/` (including a `Cargo.toml` cargo places there) trigger nothing; adding a new crate manifest triggers full rediscovery. Unit coverage: three classify tests (manifest → rediscovery, lockfile → rediscovery, target/ suppression) each asserting the flag-off behavior too.
Author
Parents
Loading