-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How should env variables be exposed? #8
Comments
@lucacasonato Do you (or another Deno member) know why Deno chose a Map-like object instead of just a bare object with getters/setters? |
Because "getting all" and "getting one specific" require different permissions. |
Ah that makes sense. I didn't think of this before, but we should ensure the proposed API works with permission systems and situations with limited permissions generally. |
just putting this out there that environment variables on Windows are case-insensitive. node.js and bun implement for a full formal spec, i would probably want it to be an object that implements a Map interface, but is not explicitly a Map (it could extend map?), so that the but maps take more thought to use, and are incompatible with "define plugin"s like bun and esbuild's not really sure the best thing but these are some things to think about when it comes to mind. edit: the webpack define plugin might allow functions; never have seen it used that way if that is the case. |
Another point on spec details: if called with a non-string should it be converted to one or always return |
I think it should throw (no implicit conversion). |
Throwing would match TC39’s future language direction in that regard; it’s definitely the better choice. |
I am currently leaning towards a Proxy-like approach where environment variables are only gotten when the getter is ran so it works with permission systems; but also easy/simple to access with bare properties. The potential issues I can think of so far:
|
I pushed an initial simplified ES-like spec in the readme for this, but I am very new to ES spec writing so it probably isn't great ;) |
A bare object (
process.env
,Bun.env
)? A Map-like object (Deno.env
)?The text was updated successfully, but these errors were encountered: