-
Notifications
You must be signed in to change notification settings - Fork 507
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
[Bug]: using onboard along with Vite
#794
Comments
I was able to get it working on the build for production, by using |
rollup
I was creating a public repository to share, and it seems Anyway, the test repo is located at: https://github.com/imsys/sveltekit-onboard-test |
rollup
Vite
I open an issue at vitejs/vite#6632 referring to this. |
Hey @imsys what is the latest state of this issue. Seems like everything is working okay for you now? |
This package is using RollUp to provide two versions: a CJS version and a ESM version. There are two ways to this to be fixed:
I'm just wondering if RollUp could have already fixed this. |
I just tried building blocknative using RollUp 2.66.1 with the default settings and it did not make any difference. |
@imsys I also came across this article by @FbN which addresses this problem by polyfilling esbuild. Here's the associated gist. I feel like this is something that ultimately needs to be addressed by Vite and that Evan You's vitejs/vite#728 (comment) is totally tone deaf on this issue. We're not even talking about top level dependencies here. It's highly likely that somewhere in your dependency tree you will have at least one sub-dependency that references the Node environment, especially when working with crypto libraries which (probably for security reasons) don't tend to update frequently. The problem we're running into is: What is happening and where is it happening?—Is it a problem with SvelteKit? Vite? rollup? esbuild? Some combination of them? It looks like Vue3 still simply uses rollup and does polyfill Node globals by default. I'm guessing this will change when they switch to Vite and a lot of dApps that use Vue3 and Web3Modal or Onboard will break if they update. I think a reasonable solution is for Vite to create a simple configuration option to polyfill the Node env for projects that need it—and just have it work. |
Funny thing is that Vite .ts code is transpiled to .cjs and run on NodeJs. xD |
@imsys This is a great discussion! But for house keeping reasons can this issue be closed? |
@taylorjdawson, yes sure, it's more a problem in Vite side, so we can close this. |
@imsys I finally managed to get V2 of Onboard (with all wallet modules including hardware wallets) working in SvelteKit (vite) the other day and some of your comments above helped a lot, so thanks for that! You should give V2 a try with Vite when you get a minute and let me know how you go. There is a build environments section that has the svelte.config that works. |
Current Behavior
I open the page and get an error thrown, it happens on the initialization of Onboard
I run
npm run dev
, or also in the buildnpm run build
and I get the errors mentioned bellow.Idk if the problem is SvelteKit, the node version, typescript or what. But from what I tried to understand, it seems to think that I'm using a Gnosis Safe wallet, when I'm not.
Onboard Version
1.37.1
Node Version
v17.3.1
What browsers are you seeing the problem on?
Firefox, Chrome
Relevant log output
Anything else?
I also tried to run that import while in the debug:
Maybe the bundler should be converting that import to an importable path? Is that the expected behavior, or is that injected and accessible when someone is using Gnosis Safe?
After doing all this debug, I'm inclined to think that problem is my bundler, as
@gnosis.pm/safe-apps-sdk
is inonboard
dependencies.The text was updated successfully, but these errors were encountered: