CashScript / cashscript

⚖️ Easily write and interact with Bitcoin Cash smart contracts
https://cashscript.org
MIT License
113 stars 81 forks source link

cashscript not working with latest version of vite #199

Open mr-zwets opened 1 month ago

mr-zwets commented 1 month ago

when using yarn create vue to initialize a default vue-vite app, cashscript import is broken.

first I ran into

Uncaught TypeError: class heritage import_events.EventEmitter is not an object or null

originating from

var ElectrumSocket = class extends import_events.EventEmitter {

I was able to solve this with

yarn add events

https://github.com/vitejs/vite/issues/2694

but new errors pop up:

Error: Build failed with 1 error:
node_modules/cashscript/dist/utils.js:1:256: ERROR: No matching export in "node_modules/@bitauth/libauth/build/index.js" for import "bigIntToCompactSize"

and

Uncaught SyntaxError: The requested module 'http://localhost:5173/node_modules/hash.js/lib/hash.js?v=fcabd058' doesn't provide an export named: 'default'

which has the comment // TODO: Replace with libauth

mr-zwets commented 1 month ago

My issue was with using CashScript + Vite version ^5.3.1

Downgrading to Vite version 5.0.12 solved the issue

Sydwell commented 1 week ago

I having a similar issue with react/next, I can get it with next version 13.... but not 14...