lagon
lagon copied to clipboard
RFC: Environment variables
Currently, environment variables are accessible with process.env
, similar to Node.js. I came across an issue today with Lyra: to check if we are running in Node.js or an Edge runtime, they check if process !== undefined
and then use an API that is available only on Node.js, but not on Lagon.
Using process.env
to hold environment variables might be more challenging for external libraries to know in which environment they are running. Feel free to discuss your thoughts about this below.
For reference:
- Deno Deploy uses
Deno.env
: https://doc.deno.land/deno/stable/~/Deno.env - Cloudflare Workers uses global variables: https://developers.cloudflare.com/workers/platform/environment-variables/
TIL about CloudFlare supporting the global environment variables 😅 honestly I agree with process
being undefined
in workers as they are closer to a browser environment. That being said my suggestion would be to support import.meta.emv
which ties in with ESM and suggesting folks who want process.env
to use something like the replace plugin from rollup
Great suggestion, I like it. Note that WinterCG might in the future define a unified way to access environment variables across all runtimes: https://github.com/wintercg/environment-metadata/issues/1