MeshJS / mesh

An open-source library to advance Web3 development on Cardano
https://meshjs.dev
Apache License 2.0
206 stars 54 forks source link

Cannot read properties of undefined (reading 'PrivateKey') using Vite (Vue3/Nuxt) #257

Open PalmerEk opened 1 month ago

PalmerEk commented 1 month ago

Receive the error

Cannot read properties of undefined (reading 'PrivateKey')

when including Mesh in Vue 3 / Nuxt based projects.

Appears to be an issue with importing @stricahq/* (and @emurgo/cip14-js)

PalmerEk commented 1 month ago

Can't seem to create a branch/submit PR but the fix is to change the following import declarations to namespace:

mesh/packages/mesh-common/src/utils/asset-fingerprint.ts import * as CIP14 from "@emurgo/cip14-js";

mesh/packages/mesh-core-cst/src/stricahq/bip32ed25519/index.ts import * as strica from "@stricahq/bip32ed25519";

mesh/packages/mesh-core-cst/src/stricahq/cbors/index.ts import * as strica from "@stricahq/cbors";

mesh/packages/mesh-core-cst/src/stricahq/bip32ed25519/privateKey.ts
import * as strica from "@stricahq/bip32ed25519";

NanezX commented 1 month ago

Same issue here. My project used the ^1.5.4 and then this allow to be resolved to 1.6.4 and crashed with this error. The whole app crashed so I had to fix the version to 1.5.4

The only difference is that I was using React.

jinglescode commented 1 month ago

working on it

tabdon commented 1 month ago

@PalmerEk would you mind sharing your vite.config.js? I had a vite project that was working, and then suddenly it stopped. I'm getting the same errors you are. I've downgraded to old versions and it's still happening. I'm puzzled.

jinglescode commented 1 month ago

@PalmerEk @NanezX @tabdon try version 1.6.5

tabdon commented 4 weeks ago

@jinglescode so far so good! thanks!