starknet-io / starknet.js

JavaScript library for StarkNet
https://www.starknetjs.com
MIT License
1.22k stars 747 forks source link

Usage with Create React App #37

Closed fracek closed 3 years ago

fracek commented 3 years ago

I made an example using this library with react, everything is working fine in development, but in production it looks like starknet.js is throwing a type error. You can open this page to see the error more in detail.

To reproduce locally:

janek26 commented 3 years ago

Hey,

please have a look here: https://github.com/paulmillr/noble-ed25519/issues/23

it seems like the issue is in react scripts code, could you try to locate that bug in their source code?

Have you tried with next's/parcel? :) So we'd know if it's a general thing

janek26 commented 3 years ago

This helps:

"browserslist": {
    "production": [
      "chrome >= 67",
      "edge >= 79",
      "firefox >= 68",
      "opera >= 54",
      "safari >= 14"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }

in package.json

The issue is that native BigInt support is required atm

fracek commented 3 years ago

This worked like a charm (had to delete node_modules). Closing, thank you again.

MorganIsBatman commented 2 years ago
"browserslist": {
    "production": [
      "chrome >= 67",
      "edge >= 79",
      "firefox >= 68",
      "opera >= 54",
      "safari >= 14"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }

You are a legend @janek! I was about to gear myself up to faff about with my tsconfig when I found this. Instant solve! Thank you sir

maht0rz commented 2 years ago

@janek26 your fix just saved my day, i wonder what is the actual root cause of this problem - but thanks!

janek26 commented 2 years ago

The issue is that native BigInt support is required atm

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt#browser_compatibility

Hopefully this will be fixed soon by StarkWare switching BigInts to hex strings in compiled contracts

0xs34n commented 2 years ago

Users who build on the web should probably use next.js as there is an issue with the following packages:

https://github.com/0xs34n/starknet.js/issues/172

https://github.com/0xs34n/starknet.js/issues/131