web3.js icon indicating copy to clipboard operation
web3.js copied to clipboard

Web3 Expo support

Open yao8384 opened this issue 2 years ago • 4 comments

Web3.js`s version comes '4.x' now; We can still only import the web3 browser version in our Vite and TS project;

the 'vite:import-analysis' plugin will throw an error, telling me the 'web3 'package is not exporting web3.min.js;

so i have a idea; as we add a declaration in web3 package.json ; and next, everything are working fine; codes are as follow:

"exports": {
".": {
	"types": "./lib/types/index.d.ts",
	"import": "./lib/esm/index.js",
	"require": "./lib/commonjs/index.js"
},
 // Add this line. it can solve errors from vite-scan;!!!
"./dist/web3.min.js": "./dist/web3.min.js"
},

how i use web3.js 4.x in my vite&ts project;

resolve: {
    alias: {
      "@": fileURLToPath(new URL("./src", import.meta.url)),
      web3: "web3/dist/web3.min.js",
    },
  }

Environment

  • Web3.js 4.0.1
  • vite & ts & vue3;
  • windows 10;

yao8384 avatar Jul 01 '23 03:07 yao8384

Thanks @yao8384 for opening an issue for this. We will look into it.

Muhammad-Altabba avatar Jul 06 '23 16:07 Muhammad-Altabba

Hi, I think it also affects web3-validator package. When trying to use web3-validator in Expo the package is resolved as undefined. After adding this line to it's package.json it works ok. image

olafkrawczyk avatar Jul 10 '23 08:07 olafkrawczyk

We should test 4.x builds with Expo.

jdevcs avatar Sep 11 '23 12:09 jdevcs

I use this patch for the latest web3 4.4.0 & bare expo 49.0 & RN 0.72.9: CleanShot 2024-02-10 at 11 48 22@2x

Rag0n avatar Feb 10 '24 11:02 Rag0n