-
-
Notifications
You must be signed in to change notification settings - Fork 6k
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
vite:define
can't process std-env
#15367
Comments
|
It looks like esbuild's bug. I was testing https://unpkg.com/std-env@3.6.0/dist/index.mjs on esbuild playground with vite/packages/vite/src/node/plugins/define.ts Lines 19 to 26 in 5684fcd
And I found that applying Here are playground links:
|
I just thought of the quick workaround to replace offending https://stackblitz.com/edit/vitejs-vite-k6fmaw?file=vite.config.ts import { defineConfig } from 'vite';
export default defineConfig({
plugins: [
{
name: 'workaround-esbuild-define-panic',
enforce: 'pre',
transform(code) {
return code.replace(
'globalThis.process?.env[o]',
'(globalThis.process?.env)[o]'
);
},
},
],
}); |
This should be fixed in esbuild v0.19.10 https://github.com/evanw/esbuild/releases/tag/v0.19.10 I confirmed https://stackblitz.com/edit/vitejs-vite-21ssdn?file=package.json |
@hi-ogawa Thanks for investigating and the fix 💚 |
Describe the bug
std-env
contains some environment-agnostic utilities (see source).The current
vite:define
plugin can't process this (see compiled library), and there seems to be no way to opt-out of processing a file with the define plugin.Linked upstream issue: nuxt/nuxt#24793
Reproduction
https://stackblitz.com/edit/vitejs-vite-ndari4
Steps to reproduce
npm run dev
(which will run the build command)System Info
Used Package Manager
npm
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: