-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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!: make NODE_ENV
more predictable
#10996
Conversation
b48f16c
to
e51b965
Compare
NODE_ENV
more predictable
2f4fa35
to
3c43204
Compare
/ecosystem-ci run |
📝 Ran ecosystem CI: Open
|
I think we should move forward with this one to be able to test it during the alpha window. @bluwy feel free to merge after you review it. |
NODE_ENV
more predictableNODE_ENV
more predictable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for making the changes! This LGTM too.
Looks like overall this implements #9274, except:
- Doesn't remove
NODE_ENV
support in.env
files. Maybe ok for now to minimize the breaking change, but it does mean stagingmode
still builds in developmentNODE_ENV
by default. NODE_ENV
is still mutated inresolveConfig
. Maybe it's also ok as the rule is simpler now.
Merging since we can improve the above later.
@bluwy can you clarify? I believe the default would be vite/packages/vite/src/node/build.ts Line 459 in 7d24b5f
If you don't define |
Ah you're right I missed that. Nevermind then 😄
It's mostly the concern that vite/packages/vite/src/node/config.ts Lines 499 to 505 in 7d24b5f
Now that I think about it, since builds are production |
There were a couple of improvements in the updated version of Vite around decoupling build modes and NODE_ENV: * vitejs/vite#10996 * vitejs/vite#11045 Accordingly, this change: * Consistently uses import.meta.env.MODE to set build mode specific values vs relying on the (previous) behavior around how import.meta.env.PROD was set. * Adds a development environment file so NODE_ENV is set to development for this builds.
Description
Make the value of
NODE_ENV
more predictableAdditional context
This was discussed in #9274
The one intricacy in implementing was related to running tests. When the first test runs Vite will set a value for NODE_ENV and then Vite will no longer reset the value on subsequent tests, so I had to handle that in the tests themselves. That's unlikely to affect our users though, so I think this is still a good trade-off. E.g. when Playwright runs the Vite server in the tests, it will do so in a sub-process, which I think would isolate each server process from one another.
There was a comment in one of the tests about
plugin-legacy
that I deleted as it appears to be outdated. Had it not been outdated, I think fixingplugin-legacy
would have been the better approach than making Vite adhere to the behavior of a single plugin, but that appears no longer relevant.What is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes #123
).