1

Trying a few different examples out there and I am getting the error:

The requested module '/node_modules/@emurgo/cardano-serialization-lib-browser/cardano_serialization_lib_bg.wasm?import' does not provide an export named '__wbg_address_free' Using this project:

https://github.com/HarmonicPool/cardano-wallet-interface

Loader:


let private_wasm = undefined;
/**
 * *.wasm module can only be imported asyncronously
 * Loader class allow to load the cardano serializaton lib once and make it aviable every time
 */
 class Loader {

  
    // always call this method to be shure the wasm has been loaded;
    static async load() {
  
      //load once
      if ( private_wasm !== undefined ) return;
  
      /**
       * @private
       */
       private_wasm = await import(
        "@emurgo/cardano-serialization-lib-browser/cardano_serialization_lib"
      );
    }
  
    static get Cardano() {
      return private_wasm;
    }
  }
    
  module.exports = Loader;

Any ideas why? The loader looks same as every example I've seen out there.

3
  • If you are using nodeJs then you are NOT in the browser, right? you are in the backend? if thats the case you might consider NOT using the browser library and in that case there is no need of a Loader. I have used just loader in ES6 versions, and always is a little of a mess to get it up working, because you have to configure so many things like Webpack etc.. package.json ... I would recommend to include a little bit more of the configuration of your project. Also check the webpack.config of the project you are using as a template as well as package.json and of course node version. Jan 8, 2022 at 0:15
  • I was trying to do it with Vue + Vite and I think something about importing it with Vite is what wasn't working out, I thought I was follow the Vite docs but obvs not! Switched to Vue and Webpack and it's working now.
    – radflipper
    Jan 8, 2022 at 17:09
  • Thanks you for your answer you are amazing using WASM was horrible this implementation is much better Mar 4, 2022 at 20:00

1 Answer 1

1

I found that using WASM comes with a lot of headaches ...

There is a non-wasm version of the same lib which I have installed and have been using. Here is my github repo with an example:

https://github.com/dynamicstrategies/cardano-wallet-connector

The non-wasm npm to install is here:

https://www.npmjs.com/package/@emurgo/cardano-serialization-lib-asmjs

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.