parcel: Environment variables are not updated
๐ bug report
Iโm using dotenv to load environment variables from a .env
file ; thatโs convenient to change their value quickly. Though, right now I always need to restart parcel in order to have them changed inside the bundle.
๐ Configuration (.babelrc, package.json, cli command)
parcel watch server/index.js -d dist/server --target=node
๐ค Expected Behavior
The bundle should contain updated environment variables.
๐ฏ Current Behavior
Only environment variables from when parcel was launched are alive.
๐ Possible Solution
Maybe donโt cache env vars ?
๐ Your Environment
Software | Version(s) |
---|---|
Parcel | latest of 1.8.x |
Node | 8 LTS |
npm/Yarn | latest npm |
Operating System | Linux ce3280140caf 4.9.87-linuxkit-aufs #1 SMP Wed Mar 14 15:12:16 UTC 2018 x86_64 GNU/Linux |
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 6
- Comments: 27 (10 by maintainers)
We should probably add the env variables to the cache key
Hum. Not for me.
index.html
index.js
cmd
result
Now change it
cmd
Wrong result
Now try with a .env file
.env
cmd
Wrong result
NB1: mind the fact that the digest in the asset slug name did not change after the rebuild NB2: dotenv or inline environment variables changes nothing
In case its help to anyone having similar issues, we had to update our babel.config and specifically tell
transform-inline-environment-variables
to exclude which env vars we didnโt want to be inlined (and therefor cached).I may take an hour to contribute on this, @DeMoorJasper @mischnic can you point me to the right direction to โadd that environment change to the cache key ?โ
EDIT: I found this old issue #66, resolved with this PR #521, merged in this commit #6c3d34f, and integrated inside 1.5.0
This seems like a regression then ?