Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Web3 Expo support #6247

Closed
yao8384 opened this issue Jul 1, 2023 · 4 comments
Closed

Web3 Expo support #6247

yao8384 opened this issue Jul 1, 2023 · 4 comments
Assignees
Labels
4.x 4.0 related Bug Addressing a bug

Comments

@yao8384
Copy link

yao8384 commented Jul 1, 2023

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 yao8384 changed the title [plugin vite:dep-scan] Missing "./dist/web3.min.js" export in "web3" package; [plugin vite:dep-scan] Missing "./dist/web3.min.js" export in "web3" package; [4.x] Jul 1, 2023
@yao8384 yao8384 changed the title [plugin vite:dep-scan] Missing "./dist/web3.min.js" export in "web3" package; [4.x] 4.x [plugin vite:dep-scan] Missing "./dist/web3.min.js" export in "web3" package; Jul 1, 2023
@yao8384 yao8384 changed the title 4.x [plugin vite:dep-scan] Missing "./dist/web3.min.js" export in "web3" package; [4.x]. plugin vite:dep-scan:Missing "./dist/web3.min.js" export in "web3" package; Jul 1, 2023
@yao8384 yao8384 changed the title [4.x]. plugin vite:dep-scan:Missing "./dist/web3.min.js" export in "web3" package; [4.x] 4.x plugin vite:dep-scan:Missing "./dist/web3.min.js" export in "web3" package; Jul 1, 2023
@yao8384 yao8384 changed the title [4.x] 4.x plugin vite:dep-scan:Missing "./dist/web3.min.js" export in "web3" package; 4.x [plugin vite:dep-scan] Missing "./dist/web3.min.js" export in "web3" package; Jul 1, 2023
@Muhammad-Altabba
Copy link
Contributor

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

@olafkrawczyk
Copy link

olafkrawczyk commented Jul 10, 2023

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

@jdevcs jdevcs changed the title 4.x [plugin vite:dep-scan] Missing "./dist/web3.min.js" export in "web3" package; Web3 Expo support Sep 11, 2023
@jdevcs jdevcs removed the Discussion label Sep 11, 2023
@jdevcs
Copy link
Contributor

jdevcs commented Sep 11, 2023

We should test 4.x builds with Expo.

@jdevcs jdevcs added the Bug Addressing a bug label Sep 11, 2023
@Rag0n
Copy link

Rag0n commented Feb 10, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4.x 4.0 related Bug Addressing a bug
Projects
None yet
Development

No branches or pull requests

6 participants