vercel / turborepo

Build system optimized for JavaScript and TypeScript, written in Rust
https://turbo.build/repo/docs
MIT License
26.33k stars 1.82k forks source link

Turbo repo doesnt properly manage env variables between import.meta && process.env #6287

Open carllippert opened 1 year ago

carllippert commented 1 year ago

What version of Turborepo are you using?

latest

What package manager are you using / does the bug impact?

pnpm

What operating system are you using?

Mac

Describe the Bug

I have a repo based on the tailwind starter.

packages/ui packages/typescript packages/tailwind packages/utils etc

I also have

apps/web apps/docs apps/tauri

tauri is powered by vite. docs and web are nextjs.

in packages/utils I am talking with external services like Supabase.

The web and docs sites demand i use process.env.ENV_VAR to access variables and tauri ( vite ) require i use import.meta.env.ENV_VAR.

Basically my packages/utils package can only build for either nextjs or vite and not both because consuming applications are dictating env variable access schemes.

Expected Behavior

I expect external packages can use the env system expected of the package and it doesnt matter who is consuming them.

To Reproduce

pnpm build.

check my ugly hack for dev mode here where i switch between impor.meta.env and process.env depending on whats up https://github.com/tryanything-ai/anything/commit/0d177ef5639532809bf11c59d06d6d7ffc421ed9#diff-1a60c5a3d399e5126728747c92f439796071799d9676ac38cf929e44f31d64e4

Reproduction Repo

https://github.com/tryanything-ai/anything/commit/0d177ef5639532809bf11c59d06d6d7ffc421ed9

TURBO-1551

gsoltis commented 1 year ago

Hmm, seems like something the eslint plugin would need to support. We can look into it.