cardano-serialization-lib icon indicating copy to clipboard operation
cardano-serialization-lib copied to clipboard

WebAssembly.instantiateStreaming

Open CyberCyclone opened this issue 3 years ago • 0 comments

Hi, I'm trying to use the browser module however I'm having issues using the WebAssembly.instantiateStreaming method. The framework I'm using doesn't support wasm via the 'import' method and they've said the only way is to use WebAssembly.instantiate / Streaming.

const importObject = {
	module: {}
};
const fetchPromise = fetch('/wasm/cardano_serialization_lib_bg.wasm');
const wasmInstance = await WebAssembly.instantiateStreaming(fetchPromise, importObject);
this._wasm = wasmInstance.exports;	

I can fetch the file correctly however WebAssembly.instantiateStreaming throws the below error message.

TypeError: WebAssembly.instantiate(): Import #0 module="./cardano_serialization_lib_bg.js" error: module is not an object or function

Does anyone have any ideas on how I can get wasm on a browser to work with the above method? I've tried using raw JS / asm but unsurprisingly it's incredibly slow (55+ seconds to add up change), so WebAssembly.instantiateStreaming remains my only option.

Thanks!

CyberCyclone avatar Dec 23 '21 06:12 CyberCyclone