Skip to content

fix(web): align outputFileTracingRoot with turbopack.root for monorepo#2041

Merged
jeanduplessis merged 2 commits intomainfrom
fix/next-config-monorepo-root
Apr 6, 2026
Merged

fix(web): align outputFileTracingRoot with turbopack.root for monorepo#2041
jeanduplessis merged 2 commits intomainfrom
fix/next-config-monorepo-root

Conversation

@kilo-code-bot
Copy link
Copy Markdown
Contributor

@kilo-code-bot kilo-code-bot bot commented Apr 6, 2026

Summary

  • Fix the Turbopack build failure caused by outputFileTracingRoot and turbopack.root diverging during vercel build --prod.
  • The root cause: vercel build sets NEXT_PRIVATE_OUTPUT_TRACE_ROOT to the project directory (apps/web), which becomes the default outputFileTracingRoot. When only turbopack.root was set to the monorepo root (../..), Next.js detected a mismatch and overrode turbopack.root with the wrong outputFileTracingRoot value, causing next/package.json resolution to fail.
  • The fix explicitly sets both outputFileTracingRoot and turbopack.root to the same monorepo root (resolve(import.meta.dirname, '../..')), ensuring they stay in sync regardless of the Vercel CLI's default.

Verification

  • CI build check: pass (pnpm run build / next build)
  • CI typecheck check: pass
  • CI lint check: pass
  • Reviewed Next.js config resolution source (packages/next/src/server/config.ts) to confirm that explicit outputFileTracingRoot overrides the NEXT_PRIVATE_OUTPUT_TRACE_ROOT env var default, and that matching values bypass the "both set but differ" warning.

Visual Changes

N/A

Reviewer Notes

  • The vercel build CLI does NOT set link.repoRoot when using prebuilt deploys via vercel link + vercel build --prod in CI, so NEXT_PRIVATE_OUTPUT_TRACE_ROOT defaults to the CWD (apps/web), not the monorepo root.
  • Next.js 16.1.6 behavior: when both outputFileTracingRoot and turbopack.root are set but differ, Next.js warns and uses outputFileTracingRoot, overriding turbopack.root. This is why only setting turbopack.root was insufficient.
  • The Vercel adapter path (NEXT_ADAPTER_PATH) is NOT enabled for Next.js 16.1.6 (minimum is v16.2.0-canary.28), so no adapter-level config override is in play.

Built for John Fawcett by Kilo for Slack

After the monorepo migration, turbopack.root pointed to the workspace
root but outputFileTracingRoot was not set, causing Next.js to default
it to the apps/web directory. This mismatch breaks the build because
Next.js requires both values to agree and cannot resolve the next
package from the app directory alone.

Extract a shared monorepoRoot constant and use it for both settings.
@kilo-code-bot
Copy link
Copy Markdown
Contributor Author

kilo-code-bot bot commented Apr 6, 2026

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (1 files)
  • apps/web/next.config.mjs

Reviewed by gpt-5.4-20260305 · 91,654 tokens

…must be set

vercel build sets NEXT_PRIVATE_OUTPUT_TRACE_ROOT to the project directory
(apps/web), which becomes the default outputFileTracingRoot. If only
turbopack.root is set to the monorepo root, the two values diverge and
Next.js overrides turbopack.root with outputFileTracingRoot, breaking
next/package.json resolution.
@jeanduplessis jeanduplessis merged commit 287a4d5 into main Apr 6, 2026
15 checks passed
@jeanduplessis jeanduplessis deleted the fix/next-config-monorepo-root branch April 6, 2026 06:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant