vite icon indicating copy to clipboard operation
vite copied to clipboard

Breaking change to env vars expansion since [email protected]

Open nezed opened this issue 1 year ago • 3 comments

Describe the bug

We're using env expansion feature for our .env files.

Given following .env file as example:

# .env
VITE_SOURCE=12345
VITE_EXPANDED=$VITE_SOURCE-678-ab

We expect, the behaviour of Vite@<=5.1.1:

console.log(import.meta.env.VITE_EXPANDED) // 12345-678-ab

Actual result for Vite@>=5.1.2:

console.log(import.meta.env.VITE_EXPANDED) // 12345

the -678-ab part is missing now

Reproduction

https://stackblitz.com/edit/vitejs-vite-yalk8f?file=.env

Steps to reproduce

  • have any setup with [email protected]+
  • have any .env file setup
  • in .env file have an env variable vith env expansion and trailing content

UPD: Seems that the braking change have only affected the env expansion with kebab-cased content after the env var reference.

Example:

Vite@<=5.1.1 (correct) image

Vite@>=5.1.2 (breaking change) image

You can try it yourself by changing a Vite version in this minimalistic Vite-only example

System Info

Seems to be reproducible in setup and package manager.

Verified on:
Package managers: npm, pnpm
Envs: OS X, StackBlitz
Vite setup: `npm create vite` is just fine
.env loading method: both
 - .env in root directory with zero configuration
 - via `loadEnv()`

Used Package Manager

npm

Logs

No response

Validations

nezed avatar Mar 15 '24 11:03 nezed

The root cause seems to be dotenv-expand@^11.0.3, brought to [email protected] with #15875

See the issue motdotla/dotenv-expand#124

nezed avatar Mar 15 '24 12:03 nezed

Working on this issue

akashMasih avatar May 17 '24 11:05 akashMasih

having the same issue. thanks @akashMasih for working on a solution!

bitbirddev avatar Jun 03 '24 12:06 bitbirddev

Hey @akashMasih @bitbirddev, don't hesitate to collaborate on root-cause issue motdotla/dotenv-expand#124 as well. Just a thumbs up or a comment would be great :wink:

nezed avatar Jun 03 '24 15:06 nezed