Menci / vite-plugin-wasm

Add WebAssembly ESM integration (aka. Webpack's `asyncWebAssembly`) to Vite and support `wasm-pack` generated modules.
MIT License
281 stars 16 forks source link

fetch wasm file should append baseUrl base on currenScript running env #47

Open joeyrenhuang opened 8 months ago

joeyrenhuang commented 8 months ago

Encountered a problem when use module federation. fetch wasm failed coz wasm locates different to window.location.origin, so here will get running env before fetch

zuckschwerdt commented 1 month ago

I encountered the same problem of needing to resolve the wasm file relative to the script url and not the current window.location.

@joeyrenhuang can you rebase to include the latest change (#50)?

zuckschwerdt commented 1 month ago

I've confirmed this working for my use-case, but it needs to not match @ in getRunningScript() so we don't prepend the function or code. For examples see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/stack I.e. apply https://github.com/zuckschwerdt/vite-plugin-wasm/commit/eead35b47fcc521b7200df3f7e6ec87b2897dc8f