-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
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
process.env.NODE_ENV replace bug #13597
Comments
vite 4.3.9 |
We're having the same issue as well in our end, after updating npm. @ankyo were you able to resolve it ? |
You can write a simple plugin to fix it import { createUnplugin } from 'unplugin'
export const unplugin = createUnplugin((mode: string) => {
return {
name: 'unplugin-fixenv',
transform(code) {
if (code.includes('process.env.NODE_ENV')) {
return code.replace(/_globalThis\$process\.env\.NODE_ENV/, `"${mode}"`)
}
return code
},
}
})
export const fixEnvForVite = unplugin.vite export default defineConfig(
{
mode: 'development',
plugins: [
fixEnvForVite('development'),
],
},
) it works for me |
Thanks a lot it worked! btw @ankyo do you think we're going to see an 'internal' fix that pertains to this issue or does this plugin makes the cut on the long term? |
Hello @ankyo. Please provide a minimal reproduction using a GitHub repository or StackBlitz. Issues marked with |
Hi, this is a known issue, it seems that the fix will be shipped in v5.0 (#11151) The issue occurs because vite/packages/vite/src/node/plugins/clientInjections.ts Lines 7 to 8 in 8868fb7
|
Yeah I think this is a duplicate of #9829. Closing in favor of it. |
Describe the bug
Error: Uncaught SyntaxError: Unexpected string (at msw.js?v=12ee2438:6178:115)
graphql/jsutils/instanceOf.js
.vite/deps/msw.js in browser
Reproduction
No Link
Steps to reproduce
The above should make the problem clear
System Info
Used Package Manager
pnpm
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: