Skip to content
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

Using lookupEnv and dotenv for configuration #4

Closed
paluh opened this issue Aug 21, 2020 · 4 comments
Closed

Using lookupEnv and dotenv for configuration #4

paluh opened this issue Aug 21, 2020 · 4 comments

Comments

@paluh
Copy link

paluh commented Aug 21, 2020

What do you think about using lookupEnv and adding purescript-dotenv dependency to this project so we can have a bit more elegant (no direct FFI) way of handling configuration? Is it worth it? Should I provide a PR?

@paluh paluh changed the title Using dotenv for configuration Using lookupEnv and dotenv for configuration Aug 21, 2020
@robertdp
Copy link
Contributor

robertdp commented Aug 21, 2020

That would work for server-side applications, but not with this projects bundling approach. Node process.env values are encoded at bundle time by Parcel, and can't be read from the environment or from a dotfile by the application because these don't exist in the browser.

@paluh
Copy link
Author

paluh commented Aug 21, 2020

Oh sorry. Stupid me ;-)

@paluh paluh closed this as completed Aug 21, 2020
@paluh
Copy link
Author

paluh commented Aug 21, 2020

P.S.
@robertdp I was somewhat mislead by the code from Config.js. Is process a thing in the browser environment? I should probably just check where it is used ;-)

@robertdp
Copy link
Contributor

robertdp commented Aug 21, 2020

process is a magic global variable that is provided by Node and doesn't exist in the browser. So the packaging/bundling tools have access to it at build/bundle time. After that we're out of luck.

In Parcels case it searches the JS it is bundling for process.env.SOME_VAR and replaces that with the string-encoded value from the environment. It also automatically loads dotenv config files and gives those values higher priority than values from the Node environment.

Config.js is just a convenient way of injecting these values so we can access them in the browser.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants