cashscript icon indicating copy to clipboard operation
cashscript copied to clipboard

cashscript not working with latest version of vite

Open mr-zwets opened this issue 1 year ago • 2 comments

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 avatar Jul 16 '24 08:07 mr-zwets

My issue was with using CashScript + Vite version ^5.3.1

Downgrading to Vite version 5.0.12 solved the issue

mr-zwets avatar Jul 16 '24 10:07 mr-zwets

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

Sydwell avatar Sep 03 '24 13:09 Sydwell

so this issue is related to #222 which has now been resolved and will be published with release v0.10.2 next week

mr-zwets avatar Oct 30 '24 09:10 mr-zwets

After removing hash-js from CashScript, CashScript works with vite when adding events for electrum-cash

To fix the vite build without any workaround, we need to update the electrum-cash package, as described in issue #224

mr-zwets avatar Dec 17 '24 12:12 mr-zwets

fixed as of v0.11.0-next.2

mr-zwets avatar Mar 05 '25 13:03 mr-zwets