Skip to content
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

fix NODE_ENV interpolation in vite production build #3547

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

maxsbelt
Copy link

I received an error in my project:

Screenshot 2023-02-16 at 13 44 40

I'm using vitejs toolchain and seems like it replaces process.env.NODE_ENV string with true/false value during the build, but it doesn't replace process.env['NODE_ENV'] (see source).

I got the problem because in my particular case one of the modules are declares process variable (so it's not an undefined) but vitejs doesn't specify process.env.

I'm suggesting to replace current check with process.env.NODE_ENV === 'production'. In this case vitejs can easily replace this string with particular value during the build.

This is should be safe update because there are plenty of popular packages that do the same check:

If you will search for process.env.NODE_ENV in node_modules you will see plenty of search results:

Screenshot 2023-02-16 at 14 23 05

But process.env['NODE_ENV'] only appears in react-dnd:

Screenshot 2023-02-16 at 14 23 47

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant