-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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
React automatic JSX fails with custom mode and externally set NODE_ENV #8192
Comments
Workaround is setting
vite/packages/vite/src/node/config.ts Lines 395 to 402 in 102b678
|
Nothing to do with
Let me support it. |
Temporary hack in case anyone else stumbles on this. class HackPlugin implements Vite.Plugin {
readonly name = "HackPluginForNODE_ENV"
enforce = 'pre' as const
apply = (config: Vite.UserConfig, env: Vite.ConfigEnv) => {
if (env.command === "build") {
process.env["VITE_USER_NODE_ENV"] = process.env.NODE_ENV ?? "production"
}
return true
}
} |
Describe the bug
One way to use
--mode
as mentioned in the docs is loading environment related options e.g. staging.The docs then suggest to set
NODE_ENV
via.env.mode
file. Though it seems completely valid to setNODE_ENV
externallyHowever, this usage pattern breaks
@vitejs/plugin-react
's automatic JSX runtime.The JSX transform doesn't seem to pick up
NODE_ENV
in this case, leading to importing JSX factory fromjsx-dev-runtime
, which is not defined inproduction
React build.Repro:
Uncaught TypeError: me.exports.jsxDEV is not a function
in browser's consoleReproduction
https://stackblitz.com/edit/vitejs-vite-gfcjac
System Info
Used Package Manager
npm
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: