You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The problem is that we can not always use the workaround which is using 'process.env\u200b.NODE_ENV' instead of 'process.env.NODE_ENV'.
For example, if you are using esbuild-wasm and need to use the define object, the desired object is as follows:
const result = await esbuild.build({
... // other irrelevant configs
define: {
"process.env.NODE_ENV": '"development"',
},
});
But this will be converted to:
define: {
""development"": '"development"',
},
Which clearly has a syntax error.
You also are not able to use 'process.env\u200b.NODE_ENV' instead; because it is not the expected key for esbuild-wasm or any other libraries. The workaround I used is as follows:
const result = await esbuild.build({
... // other irrelevant configs
define: {
// vite compatibility! https://github.com/vitejs/vite/issues/3077
// eslint-disable-next-line no-eval
[eval('"process"') + ".env.NODE_ENV"]: '"development"',
},
});
Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to vuejs/core instead.
Hmm I suppose down the line something combined it automatically so it'd be the same as "process.env.NODE_ENV". The workaround you showed using eval may be the simpler though hacky way for now.
Describe the bug
The bug is already mentioned here: #3077
The problem is that we can not always use the workaround which is using
'process.env\u200b.NODE_ENV'
instead of'process.env.NODE_ENV'
.For example, if you are using
esbuild-wasm
and need to use thedefine
object, the desired object is as follows:But this will be converted to:
Which clearly has a syntax error.
You also are not able to use
'process.env\u200b.NODE_ENV'
instead; because it is not the expected key foresbuild-wasm
or any other libraries. The workaround I used is as follows:Reproduction
https://stackblitz.com/edit/vitejs-vite-gzsbyb?file=main.js
System Info
Used Package Manager
npm
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: