wharfkit / wallet-plugin-wombat

WalletPlugin for the Wharf Session Kit. Allow users to login and sign transactions with Wombat wallet.
https://wharfkit.com
Other
1 stars 1 forks source link

Reference Error #10

Closed rahul-webd closed 1 year ago

rahul-webd commented 1 year ago

I am getting a reference error while using this library in a Next.js Project with Typescript.

image

It seems like having type: module in package.json creates this error.

aaroncox commented 1 year ago

Any chance you have an example codebase we could look at?

I know with Next.js all of the Session Kit and its plugins need to be exclusively loaded client side (the SSR will throw errors), but that doesn't seem to be related to the error. This sounds like some sort of bundler issue with how the project itself is including the dependencies.

It's just hard to tell exactly what's happening based on the information provided thus far.

rahul-webd commented 1 year ago

You can try out this Repo https://github.com/rahul-webd/next-wharf-demo, There will be a reference error due to Wombat.

Yes, it seems to be some bundler issue. The type: module field in package.json is passed down to the output. And since in the ES module type, all .js files default to the ES module (.mjs if not explicitly defined), it expects an ES module behaviour there but require is being used to import some dependency in the conflicting file which shows the CommonJS pattern and hence the conflict occurs.

aaroncox commented 1 year ago

Awesome, thanks much for the example as well as some clarity on what's happening.

We removed the type: module from the package and reworked some of our dependencies, and a new release is published as 1.0.4. Let us know if that works for you!

rahul-webd commented 1 year ago

It is working now. Thanks.