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

Fix `URL` name collision #23

Closed Karakatiza666 closed 1 year ago

Karakatiza666 commented 1 year ago

I am using wasm package in Svelte app that exports class URL. Vite generates code ""+new URL("..."), and because of wasm package's URL class new URL is undefined at this point. Adding URL = globalThis.URL reserves name 'URL' for a global URL object in this context, and URL class imported from wasm package gets another name in compiled code and works as expected.