I'm trying to import a module for use within a library which is compiled through webpack. Although the javascript API from the module is loaded, the accompanying .wasm file is not and causes any functions mentioning the wasm module to throw undefined errors. There is also the possibility that webpack is interfering with the .wasm file but I'm not sure. Here is the error.
Uncaught (in promise) TypeError: _index_bg_wasm__WEBPACK_IMPORTED_MODULE_0__.open_image is not a function
at Module.open_image (index_bg.js?0d72:1468)
And the associated function call
import('@silvia-odwyer/photon').then(photon => {
console.log(photon.open_image) // <-- correctly prints function
let ctx = canvas.getContext('2d');
let photonImg = photon.open_image(canvas, ctx); // <-- error
photon.grayscale(photonImg);
photon.putImageData(canvas, ctx, photonImg);
});
I have tried using wasm-loader, editing my tsconfig to use esnext according to this, writing in javascript instead of typescript, limiting the webpack chunk count to 1, and different ways of importing and compiling wasm from the documentation and online