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
bluwy
left a comment
There was a problem hiding this comment.
Thanks for making the changes! This LGTM too.
Looks like overall this implements #9274, except:
- Doesn't remove
NODE_ENVsupport in.envfiles. Maybe ok for now to minimize the breaking change, but it does mean stagingmodestill builds in developmentNODE_ENVby default. NODE_ENVis 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_ENVmore 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-legacythat I deleted as it appears to be outdated. Had it not been outdated, I think fixingplugin-legacywould 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).