gasp-xyz / mangata-sdk

trading SDK :racing_car: for easy communication with Mangata node
9 stars 6 forks source link

Webpack error when compiling #101

Closed michaeldev5 closed 8 months ago

michaeldev5 commented 10 months ago

Hello,

I am trying to use Mangata SDK but I am running into issues in webpack compilation in my vue.js app. Does your SDK support only ESM modules? Is there a way to make it work for commonJS?

This is the error I am getting:

ERROR in node:util
Module build failed: UnhandledSchemeError: Reading from "node:util" is not handled by plugins (Unhandled scheme).
Webpack supports "data:" and "file:" URIs by default.
You may need an additional plugin to handle "node:" URIs.
    at /Users/michaelabsolon/Projects/ui-v1/node_modules/.pnpm/webpack@5.75.0/node_modules/webpack/lib/NormalModule.js:832:25
    at Hook.eval [as callAsync] (eval at create (/Users/michaelabsolon/Projects/ui-v1/node_modules/.pnpm/tapable@2.2.1/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
    at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/Users/michaelabsolon/Projects/ui-v1/node_modules/.pnpm/tapable@2.2.1/node_modules/tapable/lib/Hook.js:18:14)
    at Object.processResource (/Users/michaelabsolon/Projects/ui-v1/node_modules/.pnpm/webpack@5.75.0/node_modules/webpack/lib/NormalModule.js:829:8)
    at processResource (/Users/michaelabsolon/Projects/ui-v1/node_modules/.pnpm/loader-runner@4.3.0/node_modules/loader-runner/lib/LoaderRunner.js:220:11)
    at iteratePitchingLoaders (/Users/michaelabsolon/Projects/ui-v1/node_modules/.pnpm/loader-runner@4.3.0/node_modules/loader-runner/lib/LoaderRunner.js:171:10)
    at runLoaders (/Users/michaelabsolon/Projects/ui-v1/node_modules/.pnpm/loader-runner@4.3.0/node_modules/loader-runner/lib/LoaderRunner.js:398:2)
    at NormalModule._doBuild (/Users/michaelabsolon/Projects/ui-v1/node_modules/.pnpm/webpack@5.75.0/node_modules/webpack/lib/NormalModule.js:819:3)
    at NormalModule.build (/Users/michaelabsolon/Projects/ui-v1/node_modules/.pnpm/webpack@5.75.0/node_modules/webpack/lib/NormalModule.js:963:15)
    at /Users/michaelabsolon/Projects/ui-v1/node_modules/.pnpm/webpack@5.75.0/node_modules/webpack/lib/Compilation.js:1371:12
    at NormalModule.needBuild (/Users/michaelabsolon/Projects/ui-v1/node_modules/.pnpm/webpack@5.75.0/node_modules/webpack/lib/NormalModule.js:1253:32)
    at Compilation._buildModule (/Users/michaelabsolon/Projects/ui-v1/node_modules/.pnpm/webpack@5.75.0/node_modules/webpack/lib/Compilation.js:1352:10)
    at /Users/michaelabsolon/Projects/ui-v1/node_modules/.pnpm/webpack@5.75.0/node_modules/webpack/lib/util/AsyncQueue.js:303:10
    at Hook.eval [as callAsync] (eval at create (/Users/michaelabsolon/Projects/ui-v1/node_modules/.pnpm/tapable@2.2.1/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
    at AsyncQueue._startProcessing (/Users/michaelabsolon/Projects/ui-v1/node_modules/.pnpm/webpack@5.75.0/node_modules/webpack/lib/util/AsyncQueue.js:293:26)
    at AsyncQueue._ensureProcessing (/Users/michaelabsolon/Projects/ui-v1/node_modules/.pnpm/webpack@5.75.0/node_modules/webpack/lib/util/AsyncQueue.js:280:12)
    at process.processImmediate (node:internal/timers:476:21)
 @ ./node_modules/.pnpm/@mangata-finance+sdk@2.1.1_@polkadot+api@10.10.1_@polkadot+types@10.10.1/node_modules/@mangata-finance/sdk/dist/index.js 2914:0-29 2926:63-79 2929:0-30 2932:35-52
 @ ./node_modules/.pnpm/file+paraspell-xcm-router-0.0.23.tgz_@acala-network+types@6.0.4_@polkadot+api-augment@10.10.1_yd7tbvuklmd4pc4bmuknc2fmcu/node_modules/@paraspell/xcm-router/dist/index.mjs 13:0-47 883:24-40
 @ ./node_modules/.pnpm/babel-loader@8.3.0_@babel+core@7.20.12_webpack@5.75.0/node_modules/babel-loader/lib/index.js!./node_modules/.pnpm/ts-loader@9.5.1_typescript@4.5.5_webpack@5.75.0/node_modules/ts-loader/index.js??clonedRuleSet-41.use[1]!./node_modules/.pnpm/vue-loader@15.11.1_css-loader@6.8.1_react-dom@18.2.0_react@18.2.0_vue-template-compiler@2.7.14_webpack@5.75.0/node_modules/vue-loader/lib/index.js??vue-loader-options!./src/views/RelayToPara.vue?vue&type=script&lang=ts 7:0-62 190:16-24 201:24-40
 @ ./src/views/RelayToPara.vue?vue&type=script&lang=ts 1:0-502 1:518-521 1:523-1022 1:523-1022
 @ ./src/views/RelayToPara.vue 2:0-62 3:0-57 3:0-57 10:2-8
 @ ./src/router/index.ts 32:19-85
 @ ./src/main.ts 4:0-30 34:2-8

Appreciate your help. Best regards, Michael.

devdanco commented 10 months ago

Hi @michaeldev5.

With the introduction of our new major version 2, we have transitioned away from supporting CJS and now exclusively support ESM. Notably, Polkadot has also adopted ESM as the only option in its latest version, which includes type generation. Polkadot Api

Maintaining compatibility with both CommonJS and ESM has proven to be challenging, leading to various issues. As a result, we've decided to focus solely on ESM to streamline development and enhance overall stability.

If you prefer, you can still utilize version 1 of the SDK, specifically version 1.21.9. However, please be aware that while this version is available, we anticipate potential issues, and we won't introduce new features into version 1 going forward, except for critical patches.

Feel free to reach out if you have any questions or concerns.

michaeldev5 commented 8 months ago

Thank you for your help, we have switched the project to ESM only.