Skip to content
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

index.js:419 Uncaught ReferenceError: require$$0$1 is not defined when I add @walletconnect/web3-provider #6404

Closed
johnnguyen-nodejs opened this issue Jun 15, 2021 · 6 comments

Comments

@johnnguyen-nodejs
Copy link

johnnguyen-nodejs commented Jun 15, 2021

When i : import { WalletConnectProvider } from "@walletconnect/web3-provider;
and setup json() in rollup.config.js
can anyone help me ????

@johnnguyen-nodejs johnnguyen-nodejs changed the title index.js:419 Uncaught ReferenceError: require$$0$1 is not defined when add I add @walletconnect/web3-provider index.js:419 Uncaught ReferenceError: require$$0$1 is not defined when I add @walletconnect/web3-provider Jun 15, 2021
@Conduitry
Copy link
Member

GitHub issues aren't the right place for support questions like this. Please ask on StackOverflow or in our Discord chat room.

@monomadic
Copy link

just saying this same issue occurred with me, left me lost. If it's not a svelte specific issue (seems it is) it would have been nice to point people in the right direction, given that this is the only google hit for the issue.

@srokatonie
Copy link

@johnnguyen-nodejs Any luck with that? I seem to have a similar issue described here: #6891
@monomadic This issue can also be related to rollup.js

@jangxyz
Copy link

jangxyz commented Mar 5, 2022

Sharing my experience on how I managed to resolve this issue, for those who come by.

TLDR; I managed to make it work by replacing the library that a module was using, which was causing the error. I had to clone the module and patch it to use an alternative, to one that did work.

The problem

I encountered this issue after installing xast-util-from-xml, which uses an XML parser called sax-js (I don't know much about XML parsing). Browser complained about Uncaught ReferenceError: require$$0 is not defined. importing the module did not change the error from happening.
Using only sax-js confirmed that it was indeed the problem. Here's a code diff of bundle.js with and without using the module.

screenshot

bundle.js diff

Here the bundle is passing require$$0 to the app function, but it is not defined anywhere.

Working for a solution

Searching through github issues and stack overflows, all I can find is that it's related to the modules not being updated to new module importing scheme (node modules, requires and imports, duh). There were several questions, but I couldn't find a general answer to apply. Most of the questions were from the svelte users, but the community didn't seem to think it was the problem for the framework to fix.

I went to check out the sax-js repo, but it was pretty much complete, where no meaningful code commit was done after 2017. There were questions on the issue page whether the project is still alive, and directions for newer alternatives.

In the end, I checked out another alternative xml parser project(saxes), confirmed that using the module did not raise any errors, and patched the original xast-util-from-xml code to use the new xml parser. I cloned the project and just changed the code until the implemented tests pass. Fortunately XML parsers obey a well-defined specification, and there were only a few code changes to apply. It took several hours to make most of the tests pass though -- and in the end I couldn't make all of them pass, but just enough to bare.

Not the best solution I can find, but it did work for me.

@srokatonie
Copy link

@jangxyz Have you tried Webpack instead Rollup?

@jangxyz
Copy link

jangxyz commented Mar 8, 2022

@srokatonie No, I haven't tried webpack.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants