Replies: 1 comment 11 replies
-
|
Normally, you don't commit |
Beta Was this translation helpful? Give feedback.
11 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Goals
Non-goals
Background
Turborepo v2 made a push to strict mode by default. While this does help greatly with predictability and caching, it puts more burden on env variable management.
In apps where all available env variables share the same prefix, (e.g.
NEXT_orVITE_), this is still manageable via one or two wildcard"env"entries.However, when projects use a variety of environment variables (without a single common prefix), there is currently no OOTB method of auto-tracking these in Turborepo as dependencies.
Two example scenarios:
PUBLIC_prefix for non-sensitive vars)Outside of Turborepo, env variables are sometimes already tracked in a local
.envfiles, sometimes including additional files such as.env.local,.env.development, etc. These provide not only defaults env values (which can still be overridden in CI/CD), but also serve as a place to list and document relevant env variables.At the moment, adding new env variables requires adding it to an existing
.envfile, and then not-forgetting-to-add it toturbo.jsonconfig, too.This gets cumbersome and error-prone quickly, especially if
"env"entries need to be listed multiple times in some, but not all, tasks (e.g.genandbuildmay depend on env vars, but notlint,testetc.).Proposal
Provide an opt-in feature that allows scanning env variables defined in one or more files (e.g.
.env), and add them to the final or default list of"env"dependencies.Potential config syntax (A):
{ "tasks": { "build": { "inputs": ["$TURBO_DEFAULT$", ".env", ".env.*"], "env": ["$TURBO_DOTENV$", "!MY_EXCEPTION_VAR"] } } }Here,
$TURBO_DOTENV$is a special placeholder, similar to"$TURBO_DEFAULT$, and expands automatically at Turborepo-runtime. Whereas the latter expands into Turborepo's default input file patterns,$TURBO_DOTENV$might expand into all env variables defined in local.envfiles.Challenges:
dotEnvproperty.Alternative config syntax (B):
{ "tasks": { "build": { "dotEnv": [".env", ".env.*"], "env": ["$TURBO_DEFAULT$", "!MY_EXCEPTION_VAR"] } } }Reviving the previously used
"dotEnv"property from Turborepo v1. This property would define files to scan for environment variable definitions. Those files would be default-included in"inputs"(no need to list them again), and the variables defined within would be default-included in"env". The"env"property can still be overridden, or expanded via"$TURBO_DEFAULT$"similar to"inputs".Challenges:
Beta Was this translation helpful? Give feedback.
All reactions