Without an outputs declaration Turborepo has no idea which files the
build task produces, so a cache hit replays the logs and reports success
while writing nothing:
$ rm -rf packages/openapi-typescript-helpers/dist
$ npx turbo run build --filter=openapi-typescript-helpers
openapi-typescript-helpers:build: cache hit, replaying logs a23865...
$ ls packages/openapi-typescript-helpers/dist
ls: No such file or directory
Anything that consumes the package then fails on the missing artifacts.
openapi-react-query's test script shells out to the openapi-typescript
CLI and dies with ERR_MODULE_NOT_FOUND for dist/index.mjs; with this
change the same sequence exits 0 with 37 tests passing.
Declaring outputs also makes it safe to persist .turbo/cache in CI,
which does not currently work for this reason.
Changes
turbo.jsonnever declaredoutputsfor any task, so Turborepo had no idea which files a task produces. A cache hit therefore replays the task's logs and reports success without writingdist/:That is a false green:
turbo run buildcan succeed with no artifacts on disk, so anything that consumes a package fails or silently reads stale output. The clearest case isopenapi-react-query, whose test script shells out to theopenapi-typescriptCLI:Reproduction
npx turbo run build --filter=openapi-react-query— populates the cachepackages/*/distnpx turbo run build --filter=openapi-react-query— cache hit, reports successcd packages/openapi-react-query && pnpm run testOn
main, step 4 exits 1 with theERR_MODULE_NOT_FOUNDabove. With this PR it exits 0, with 37 tests passing. I checked both directions — removing the new line reproduces the failure again.Fix
Declare
"outputs": ["dist/**"]on thebuildtask so Turbo caches and restores the artifacts. Every package'sbuildwrites todist/.How to Review
turbo.json; nothing else changes.outputschanges a task's hash, so the first run after this lands rebuilds everything once. After that, cache hits restoredist/as they should..turbo/cache. It matters for localturbousage, and it's a prerequisite for caching Turborepo output in CI.>>> FULL TURBO, 7/7 cached, 93ms), but that was only because nothing ran; the moment I forced the tests to execute, the missing artifacts surfaced on three platforms. I've kept ci: stop the test-e2e job from hanging for 6 hours #2869 to the e2e fix only and left the caching out.For what it's worth, my first guess was wrong: I assumed the task graph was missing a cross-package
^buildedge. It isn't — the graph is correct (openapi-react-query#test → openapi-react-query#build → openapi-typescript#build), and the missingoutputsis the whole cause.Checklist
docs/updated (if necessary) — not applicablepnpm run update:examplesrun (only applicable for openapi-typescript) — not applicableNo changeset:
turbo.jsonis build orchestration and is not published.