-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
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
npm run dev
works, npm build
throws a global is not defined
in the browser
#7257
Comments
Uncaught ReferenceError: global is not defined
in the browsernpm run dev
works, npm build
throws a global is not defined
in the browser
Update: I was able to build the project changing my configuration. Ironically enough, now
|
I got the build complete, and dev working by only adding
to the The preview command throws an error like Updating my config like yours didn't help with this error. |
Hey guys. I found another solution to this problem. I simply import wallet connect via: |
without other dependencies, just add |
esbuild is used only in dev, rollup for production. that's why it's working when you merge both of the config files. |
After setting |
Describe the bug
In the last days I've been developing my app using vite+svelte+ts. The app imports
@walletconnect/web3-provider
, and I had to fight quite a lot to make it work becauseglobal
,buffer
, andutil
were missing when running the app in the browser. I ended up doing this:util
and injecting it using@rollup/plugin-inject
.@esbuild-plugins/node-globals-polyfill
.global
toglobalThis
.You can see the full configuration in the file
vite.config.js
.After these changes my app started working using
npm run dev
.Yesterday I ran
npm build
and served it from a static server, and I'm back to square one: the app doesn't load and in the console I seeUncaught ReferenceError: global is not defined
.How to reproduce:
I have a repro https://github.com/vrde/dapp-template
I think that's an issue with
vite
because of the different outputs of thedev
and thebuild
commands.(Maybe related #6065?)
Reproduction
https://github.com/vrde/dapp-template/
System Info
Used Package Manager
pnpm
Logs
Validations
The text was updated successfully, but these errors were encountered: