[Bug]: wasm js bindings generated by wasm-pack is not compatible with raw browser import #268
Open
1 task done
Labels
bug
Something isn't working
Dojo.js Version
all
What happened?
Currently dojo.js use wasm-pack to generate the js boilerplate to load wasm in browser/node/etc...
Unfortunately wasm-pack generate js file that load wasm via es import (
import * as wasm from "./<lib>.wasm"
) which is not support by browser.Some bundler will magically transform such import so browser can import it, some other (like vite) requires a community plugin to make it work. But ideally dojoengine should work without such external tool and as such it would be great if dojo.js output a js boilerplate compatible with browser (without require any other toool)
It seems using the wasm-bindgen cli to generate the js binding generate the correct js so it can be loaded in browser without any extra bundler
What is the expected behavior?
I expect to be able to use dojo with raw browser import, without the need for a bundler
Steps to reproduce
generate import map for torii-client and its dependencies
set them up in the index.html and add a script that load the torii-client and you ll'see the following error:
see reproduction repo : https://github.com/bug-reproduction/torii-wasm-in-browser
see codepen : https://codepen.io/wighawag/pen/RwzddBM
Trace
No response
Is there an existing issue for this?
The text was updated successfully, but these errors were encountered: