You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The problem is that, document.currentScript refers to the current processing script, so as most of time init was been called from another script (and in this case, a script tag without src), this code fails.
The correct method is caching document.currentScript.src when it's initializing, for example:
We can't literally cache it like you had shown, because the code needs to check for the existence of the document object.
What we can do instead is cache the entire expression.
If document doesn't exist, and is created later, then I doubt that we'd want that document object, and the location won't change without reloading the scripts, so the entire thing can be a constant.
I would like to create a small PR updating both, ESM and non-ESM to cache the default sources so they will have equal performance at runtime, but I'd like to know, in what cases is it expected that the client would have a location, but not a document?
Describe the Bug
When building with
--target no-modules
, the output js file should be able to find its.wasm
file.Steps to Reproduce
without-a-bundler-no-modules
example and buildindex.html
as:Expected Behavior
It loads the
.wasm
file and runs.Actual Behavior
Additional Context
I treat it as a bug because the generated code did try to detect the correct url for its
.wasm
file, but it failed.Related code:
The problem is that,
document.currentScript
refers to the current processing script, so as most of timeinit
was been called from another script (and in this case, a script tag withoutsrc
), this code fails.The correct method is caching
document.currentScript.src
when it's initializing, for example:I verified it works after the modification:
The text was updated successfully, but these errors were encountered: