web3 / web3.js

Collection of comprehensive TypeScript libraries for Interaction with the Ethereum JSON RPC API and utility functions.
https://web3js.org/
Other
19.22k stars 4.92k forks source link

Circullar dependencies (Svelte + Rollup) #7133

Closed soyrubio closed 3 weeks ago

soyrubio commented 3 months ago

I am using web3-types and web3-eth-abi in my Svelte project (/w typescript). When importing web3-eth-abi, I get the following error on bundling my project using rollup:

[1] (!) Circular dependencies
[1] node_modules/web3-eth-abi/lib/esm/coders/base/tuple.js -> node_modules/web3-eth-abi/lib/esm/coders/base/index.js -> node_modules/web3-eth-abi/lib/esm/coders/base/tuple.js
[1] node_modules/web3-eth-abi/lib/esm/coders/base/index.js -> node_modules/web3-eth-abi/lib/esm/coders/base/array.js -> node_modules/web3-eth-abi/lib/esm/coders/base/index.js

I tried installing both installing whole web3 package, and also just the web3-eth-abi module separatelly. Both are causing me this issue.

See full output below:

[1] node_modules/web3-utils/lib/esm/socket_provider.js
[1] 1: var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
[1]                     ^
[1] 2:     function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
[1] 3:     return new (P || (P = Promise))(function (resolve, reject) {
[1] ...and 1 other occurrence
[1] node_modules/web3-utils/lib/esm/web3_eip1193_provider.js
[1] 1: var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
[1]                     ^
[1] 2:     function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
[1] 3:     return new (P || (P = Promise))(function (resolve, reject) {
[1] ...and 1 other occurrence
[1] node_modules/web3-utils/lib/esm/promise_helpers.js
[1] 15: along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
[1] 16: */
[1] 17: var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
[1]                      ^
[1] 18:     function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
[1] 19:     return new (P || (P = Promise))(function (resolve, reject) {
[1] ...and 1 other occurrence
[1] node_modules/web3-utils/lib/esm/web3_deferred_promise.js
[1] 15: along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
[1] 16: */
[1] 17: var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
[1]                      ^
[1] 18:     function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
[1] 19:     return new (P || (P = Promise))(function (resolve, reject) {
[1] ...and 1 other occurrence
[1] node_modules/web3-types/lib/esm/web3_base_provider.js
[1] 1: var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
[1]                     ^
[1] 2:     function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
[1] 3:     return new (P || (P = Promise))(function (resolve, reject) {
[1] ...and 1 other occurrence
SantiagoDevRel commented 3 months ago

Hi @soyrubio thanks for sharing this, the team will take a look at it asap💪 PS: which version of web3js are you using?

soyrubio commented 3 months ago

Thanks! 🙏

package.json

"web3-eth-abi": "^4.2.2",
"web3-types": "^1.6.0"

package-lock.json

"node_modules/web3-errors": {
  "version": "1.2.0",
  "resolved": "https://registry.npmjs.org/web3-errors/-/web3-errors-1.2.0.tgz",
  "integrity": "sha512-58Kczou5zyjcm9LuSs5Hrm6VrG8t9p2J8X0yGArZrhKNPZL66gMGkOUpPx+EopE944Sk4yE+Q25hKv4H5BH+kA==",
  "dependencies": {
    "web3-types": "^1.6.0"
  },
  "engines": {
    "node": ">=14",
    "npm": ">=6.12.0"
  }
},
"node_modules/web3-eth-abi": {
  "version": "4.2.2",
  "resolved": "https://registry.npmjs.org/web3-eth-abi/-/web3-eth-abi-4.2.2.tgz",
  "integrity": "sha512-akbGi642UtKG3k3JuLbhl9KuG7LM/cXo/by2WfdwfOptGZrzRsWJNWje1d2xfw1n9kkVG9SAMvPJl1uSyR3dfw==",
  "dependencies": {
    "abitype": "0.7.1",
    "web3-errors": "^1.2.0",
    "web3-types": "^1.6.0",
    "web3-utils": "^4.3.0",
    "web3-validator": "^2.0.6"
  },
  "engines": {
    "node": ">=14",
    "npm": ">=6.12.0"
  }
},
"node_modules/web3-types": {
  "version": "1.6.0",
  "resolved": "https://registry.npmjs.org/web3-types/-/web3-types-1.6.0.tgz",
  "integrity": "sha512-qgOtADqlD5hw+KPKBUGaXAcdNLL0oh6qTeVgXwewCfbL/lG9R+/GrgMQB1gbTJ3cit8hMwtH8KX2Em6OwO0HRw==",
  "engines": {
    "node": ">=14",
    "npm": ">=6.12.0"
  }
},
"node_modules/web3-utils": {
  "version": "4.3.0",
  "resolved": "https://registry.npmjs.org/web3-utils/-/web3-utils-4.3.0.tgz",
  "integrity": "sha512-fGG2IZr0XB1vEoWZiyJzoy28HpsIfZgz4mgPeQA9aj5rIx8z0o80qUPtIyrCYX/Bo2gYALlV5SWIJWxJNUQn9Q==",
  "dependencies": {
    "ethereum-cryptography": "^2.0.0",
    "eventemitter3": "^5.0.1",
    "web3-errors": "^1.2.0",
    "web3-types": "^1.6.0",
    "web3-validator": "^2.0.6"
  },
  "engines": {
    "node": ">=14",
    "npm": ">=6.12.0"
  }
},
"node_modules/web3-validator": {
  "version": "2.0.6",
  "resolved": "https://registry.npmjs.org/web3-validator/-/web3-validator-2.0.6.tgz",
  "integrity": "sha512-qn9id0/l1bWmvH4XfnG/JtGKKwut2Vokl6YXP5Kfg424npysmtRLe9DgiNBM9Op7QL/aSiaA0TVXibuIuWcizg==",
  "dependencies": {
    "ethereum-cryptography": "^2.0.0",
    "util": "^0.12.5",
    "web3-errors": "^1.2.0",
    "web3-types": "^1.6.0",
    "zod": "^3.21.4"
  },
  "engines": {
    "node": ">=14",
    "npm": ">=6.12.0"
  }
},
mconnelly8 commented 2 months ago

Hey @soyrubio, can you provide a link to your project for us to review?

luu-alex commented 3 weeks ago

Sorry we didn't respond to this, this should be fixed in the latest version checked by another comment here. https://github.com/web3/web3.js/issues/7250#issuecomment-2344032183 If anyone else is facing issues we can reopen this. Thank!