-
Notifications
You must be signed in to change notification settings - Fork 38
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
7.4.0 is breaking create-react-app projects that worked in prior versions #168
Comments
As a side note... it's also challenging for libraries that might be shared in the frontend and the backend. Before they were able to rely on a common abstraction |
@mdesousa can you provide the syntax you were using before, that is now broken? My understanding is that this library didn't "just work" with |
I just tested with the latest version of
to the
I then started the application using Can you make sure to provide what version of |
switch this to vite + react |
hi @evanshortiss , i just tested and was able to reproduce the issue. please take a look at this repo. it has two commits:
|
Thanks so much for the repro repo. I see what you mean. It's related to the way the older Can you test a fix for me? Try EDIT: Ugh, I just realised this will break Vite, and others but it's a start on a hacky fix I guess. DetailsThis is how the bundled module.exports = from(({"NODE_ENV":"development","PUBLIC_URL":"","WDS_SOCKET_HOST":undefined,"WDS_SOCKET_PATH":undefined,"WDS_SOCKET_PORT":undefined,"FAST_REFRESH":true,"REACT_APP_TEXT":"Learn Env-Var"})); Here's how it looks with module.exports = from(typeof process === 'undefined' ? {} : ({"NODE_ENV":"development","PUBLIC_URL":"","WDS_SOCKET_HOST":undefined,"WDS_SOCKET_PATH":undefined,"WDS_SOCKET_PORT":undefined,"FAST_REFRESH":true,"REACT_APP_TEXT":"Learn Env-Var"})); The polyfill seems to replace I assume reason it works with the newer version of |
That works for me @evanshortiss! Thanks for taking a look. By the way, i'm not sure what you mean by "newer version of create-react-app"? The repo that I shared used the latest... 5.0.1. Same version referenced in https://create-react-app.dev/. You mentioned version 13.4.19... where did you get that? |
@mdesousa interesting...my EDIT: I see my error...I used my command history. Ignore my silliness 😫
Version comes from:
See my comment about the fix. I need to think about how to get that fix in, but not break Vite... |
oh @evanshortiss i see... |
Yeaaaah! I had used |
Hi, thanks for this great project! We have found it very useful over the years and use it everywhere that needs to deal with environment variables. It appears that 7.4.0 breaks projects that use
create-react-app
... seems related to #115 (Edit by Evan: I think this was meant to be #155).I understand the motivation of making the library usable for
vite
(we use it for new projects, and it's great that it's supported). But this shouldn't be at the expense of breakingcreate-react-app
... is there a way to default to the behavior or reading fromprocess.env
and allowvite
projects to override?The documented workaround (see below) isn't great... it means that we have to explicitly add our environment variables everywhere that they are imported. This is a lot of maintenance every time that we add or remove variables. Thanks.
The text was updated successfully, but these errors were encountered: