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