StakeNow / SIWT

Sign In With Tezos: Access Control Management SDK
https://siwt.xyz/
MIT License
16 stars 3 forks source link

importing sdk on my React app breaks the bundle #26

Closed zamrokk closed 1 year ago

zamrokk commented 1 year ago

Describe the bug I import the sdk on my React application and the webpage does not display anymore

To Reproduce

  1. Use CRA Create React Application and import the sdk 0.0.3
  2. Do an import somewhere
    import { createMessagePayload } from "@siwt/sdk";
  3. refresh the page

you got Uncaught TypeError: axios_1.default is undefined on the web page console

Expected behavior Do not break the react bundle

Screenshots image

Desktop (please complete the following information):

Additional context When I do npm run start there is no error, it is when the page refresh to fetch the React bundle

package.json.lock

 "node_modules/@ionic/react": {
      "version": "7.0.0",
      "resolved": "https://registry.npmjs.org/@ionic/react/-/react-7.0.0.tgz",
      "integrity": "sha512-t9NlHZTiH/NvT3GLcO4yS5Whe9stpsZ9AtNOYS+aPcKM5vhxJSFGXDUvKtABOLi2CniW2kFE8krHwjz9V0GQYA==",
      "dependencies": {
        "@ionic/core": "7.0.0",
        "ionicons": "^7.0.0",
        "tslib": "*"
      },
      "peerDependencies": {
        "react": ">=16.8.6",
        "react-dom": ">=16.8.6"
      }
    },
  ...  
 "node_modules/react": {
      "version": "18.2.0",
...
"node_modules/@siwt/sdk": {
      "version": "0.0.3",
      "resolved": "https://registry.npmjs.org/@siwt/sdk/-/sdk-0.0.3.tgz",
      "integrity": "sha512-cZDzozAJEYbMdvgRqqbULcXw2o10h34EpKn7WsH2MCArgRGIaQ0gOgPBk5JhOL3bYkgKbYi+Od86JhljcseEng==",
      "peerDependencies": {
        "@taquito/utils": "15.1.0",
        "axios": "1.3.3",
        "ramda": "0.28.0",
        "tslib": "2.5.0"
      }
    },
    ...
   "node_modules/axios": {
      "version": "1.3.3",
zamrokk commented 1 year ago

npm i axios@0.27.2 --force seem to fix it

Just axios is not compatible with Typescript anymore after axios v1 ...

I recommend you to set the axios version like mine to allow Typescript to be used

royscheeren commented 1 year ago

Thanks @zamrokk