“ReferenceError: URL is not defined” from a Web assembly generated javascript file

I’m getting a “ReferenceError: URL is not defined” when initializing a Web Assembly module. The error is for a line like the one below, in the web assembly generated javascript file.

wasmBinaryFile=new URL("some_filename.wasm")

I’m exporting the module from the wasm generated javascript file and using it in another javascript file by constructing the module like

Module().then(...)

Why does this error happen? How can I define the URL() constructor before it’s called so this error won’t happen.

The thing is this normally works – however, when I invoke the module construction inside an AudioWorkletNode constructor, the error happens. Somehow, the URL() constructor definition is being deleted.