goatandsheep / react-native-dotenv

Load react native environment variables using import statements for multiple env files.
https://www.npmjs.com/package/react-native-dotenv
MIT License
811 stars 48 forks source link

Follow dotenv-flow variable precedence #491

Open jleem99 opened 9 months ago

jleem99 commented 9 months ago

The documentation for this library mentions that it follows the dotenv-flow for multi-environment variable loading. (link)

However, I've noticed a minor difference when compared to the dotenv-flow. According to the dotenv-flow's variables overwriting priority, the variable merging order should be:

  1. .env
  2. .env.local
  3. .env.development
  4. .env.development.local
  5. Command line variables

But in practice, when NODE_ENV='development', the order of variable merging in this library seems to be:

  1. .env
  2. .env.development
  3. .env.local
  4. .env.development.local
  5. Command line variables

This had lead some confusions, for instance, mode-specific variables being unexpectedly overwritten by variables from the .env.local file.

github-actions[bot] commented 9 months ago

Hey, thank you for opening this issue! 🙂 To boost priority on this issue and support open source please tip the team at https://issuehunt.io/r/goatandsheep/react-native-dotenv/issues/491