vercel / turbo

Incremental bundler and build system optimized for JavaScript and TypeScript, written in Rust – including Turbopack and Turborepo.
https://turbo.build
MIT License
25.66k stars 1.75k forks source link

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

Open carllippert opened 8 months ago

carllippert commented 8 months 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 8 months ago

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