router-sdk icon indicating copy to clipboard operation
router-sdk copied to clipboard

Add `module` and `jsbi` to package.json

Open keithbro-imx opened this issue 2 years ago • 4 comments

In a vite app, an issue occurs when both @uniswap/sdk-core and @uniswap/router-sdk are imported at the same time. A minimal repro can be found here: https://github.com/keithbro-imx/vite-uniswap-repro

In the browser, the following error is visible:

Uncaught TypeError: r.BigInt is not a function

r here is JSBI.

Using yalc locally I was able to point at a local build of this library, and I get the error:

Uncaught ReferenceError: require is not defined

Not exactly the same error, but this was resolved by adding the module option to the package.json. After this, both libraries could be imported and used at the same time.

I also added jsbi as a dependency (the same version constraints as core sdk for consistency), as this may also be contributing to the problem, though I wasn't able to confirm that.

keithbro-imx avatar Nov 06 '23 11:11 keithbro-imx

Hi @adjkant and @tinaszheng - would be great to get your thoughts on this one - thank you!

keithbro-imx avatar Nov 06 '23 11:11 keithbro-imx

We did some further testing of this fix by publishing the fix to an npm account, and observed the BigInt issue in the unfixed version, and no issue in the fixed version.

https://www.npmjs.com/package/@keithbro-imx/router-sdk?activeTab=versions

1.7.1 = unfixed 1.7.2 = fixed (this PR)

keithbro-imx avatar Nov 07 '23 23:11 keithbro-imx

@tinaszheng Any chance you could take a look? 🙏

pano-skylakis avatar Feb 06 '24 22:02 pano-skylakis

@jsy1218 Looks like you're active in this repo. Would you have a few mins to take a look at this PR and let us know if its suitable to to merge?

keithbro-imx avatar Feb 18 '24 09:02 keithbro-imx