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

Does parcel use dotenv, or dotenv flow? The documentation is incomplete and confusing #1013

Open
rsimp opened this issue Mar 14, 2022 · 4 comments

Comments

@rsimp
Copy link

rsimp commented Mar 14, 2022

Is Parcel using dotenv as it claims, or dotenv-flow? It links to dotenv but supports multiple env files in the same manner as dotenv-flow, which is not included behavior with dotenv and actively warns against it. However dotenv-flow has specific rules on which env files have higher precedence. Command line env variables have the highest precedence, and .env.local is still loaded for test. This is the behavior that next.js and create react app uses.

I think parcel needs to go with one or the other, link to it, and use the same logic. If not remove the link and just document it's own rules : What files can be source controlled? What files overwrite others? Are command line env variables overwritten if defined etc.

Also what is the rationale behind not using .env.local for test? Env variables loaded via jenkins/aws/etc are higher priority than ones defined in env files with dotenv-flow. .env.local will have unsourced secrets and may need to be different than the actual test environment (dev/qa/staging etc), but API keys may still be necessary for any integration or end-to-end testing. Precedence order should make sure it all works correctly which is the main concern when using multiple .env files. I'd probably end up with two local env files with the same configuration and I'm not sure I'm understanding what the benefit is.

@rsimp
Copy link
Author

rsimp commented Mar 14, 2022

Also dotenv-flow supports using an unsourced .env file and having a sourced .env.defaults. Is this behavior supported as well? Do you see my point? Either you need to document the full behavior, or document every case where the behavior deviates. It might be better to just say you took inspiration from dotenv-flow, but documentation is lacking either way.

Right now the behavior mimics dotenv-flow more than dotenv but doesn't quite work the same, and is missing a link to the documentation for dotenv-flow which answers questions the Environment variables section doesn't answer.

@rsimp rsimp changed the title Does parcel use dotenv, or dotenv flow? The documentation is uncomplete and confusing Does parcel use dotenv, or dotenv flow? The documentation is incomplete and confusing Mar 14, 2022
@mischnic
Copy link
Member

@rsimp
Copy link
Author

rsimp commented Mar 15, 2022

Hmm, so I see that the code is actually the same as in create-react-app and next.js. Same behavior for test with the same comment verbatim:

Don't include .env.local for test environment since normally you expect tests to produce the sameresults for everyone

I thought they used to use dotenv-flow but I guess they switched at some point.

The behavior is definitely more in alignment with dotenv-flow and disregards advice on multiple files and source control.

I think the biggest thing missing here is a section on source control, and maybe expand on precedence order. Both create-react-app and next.js have sections in their documentation going over both in more detail.

@mrcoles
Copy link

mrcoles commented Apr 13, 2023

I just ran into this question too. How about this proposed edit to the docs? #1079

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

3 participants