Skip to content

chore(build): optimize turborepo caching by scoping globalEnv variables#28728

Open
TanmayChaurasia24 wants to merge 2 commits intocalcom:mainfrom
TanmayChaurasia24:chore/optimize-turbo-globalenv
Open

chore(build): optimize turborepo caching by scoping globalEnv variables#28728
TanmayChaurasia24 wants to merge 2 commits intocalcom:mainfrom
TanmayChaurasia24:chore/optimize-turbo-globalenv

Conversation

@TanmayChaurasia24
Copy link
Copy Markdown

Summary

This PR audits and optimizes Turborepo's globalEnv list to dramatically improve cache hit rates across the monorepo for self-hosted operators, CI environments, and local developers.

Previously, globalEnv contained nearly 300 variables, including highly specific application secrets (e.g. TWILIO_SID, STRIPE_PRIVATE_KEY, etc.). This approach meant changing a single specific app variable unrestrictedly busted the entire monorepo cache across all 114 packages, forcing slow rebuilds from scratch for loosely-coupled packages like @calcom/prisma and @calcom/ui.

We reduced globalEnv down to 14 core essential variables (e.g. NODE_ENV, DATABASE_URL, CI) and scoped the remaining ~297 environmental variables directly downstream into the .env dependencies of the task definitions (namely @calcom/web#build, @calcom/website#build, and @calcom/api-v2#build) where they are actually used.

Changes:

  • Retained true universal core variables inside turbo.json globalEnv.
  • Migrated 297 task-specific config/integration keys directly to the task env arrays that bundle them.
  • Removed several stale variables completely if they weren't utilized anywhere in the /apps or /packages codebase workspaces.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Chore (Dependency updates, refactoring, or tooling improvements)

Checklist

  • Title follows conventional commits: feat(scope): description or chore(deps): description
  • Lint passes: yarn lint:fix
  • Diff is small and focused (<500 lines, <10 files)
  • Created as a draft PR

fixes #28633

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Turborepo globalEnv has 250+ entries, effectively defeating build caching for most contributors

1 participant