vite-plugin-env-compatible
vite-plugin-env-compatible copied to clipboard
Fatal error when a variable with the same name as expanded variable is declared
Hey 👋🏻
Context
A RangeError
(more specifically Maximum call stack size exceeded
) is raised when we declare a variable with the same name as the expanded variable.
e.g.,
MY_VAR=${MY_VAR}
If we change the value to something else. It works just fine.
This is an issue in dotenv-expand
, and it was fixed in 11.0.0 (more details in the linked issues).
Description
Even though the issue is already fixed in dotenv-expand
, we still use version 5.1.0
here.
https://github.com/IndexXuan/vite-plugin-env-compatible/blob/12cd100cdb9e0e9fda96f546dad900751adc0907/package.json#L48
Also, since 5.1.0
is not compatible with version 11.0.0
(as expected 😅), we cannot force a resolution to 11.0.0
in the user project.
Solution
We need to bump dotenv-expand
to at least 11.0.0
to fix this issue.
In the meantime, we can declare variables this way, and it should work:
MY_VAR='\${MY_VAR}'
Links
- https://github.com/motdotla/dotenv-expand/issues/98
- https://github.com/vitejs/vite/issues/13399
Not sure if I'm missing something here. So please let me know.