-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Broken linked modules in no-modules target if shim is not parsed in document #3277
Comments
I tracked the |
I was quiet confused how Eventually I discovered what I think was an oversight in #3069, |
I made a PR to address this issue: #3279. |
Oh, that's pretty bad. I'm particularly concerned about the I think that may be worth yanking the new release of To be clear, I'm not suggesting we yank the whole thing, just
👍
It's already disabled by default. |
I believe as long as it's documented that
Yes, but not in |
Describe the Bug
If the no-modules target is used and the shim is not parsed in a document, like for example in any kind of worker, any linked module will break.
This problem partially stems from #3069, which now uses
new URL('path/to/linked/module', script_src)
.When using the no-modules target,
script_src
can not possibly be correct when not used in a document, which was an oversight from this PR: #3169.The problem is that if you are in a worker and using
importScripts()
,location.href
can never return the path to the imported script, the shim, which is what we want, insteadlocation.href
will return the path to the script that starts the worker, which is not useful in this context and in fact will break any path created for linked modules.Steps to Reproduce
I can't really get the examples working because wasm-pack doesn't work for me, but the simplest example is using the
Atomics.waitAsync
polyfill in Firefox inside a worker, which currently uses linked modules and will try to create a nested worker, which will fail becausenew URL()
will report an invalid base, for example if the base is a blob.Solution
I think the solution is two-fold here:
location.href
ifdocument
is undefined. It is simply impossible to get the path to the shim with the no-modules target, at least as far as I have research.Disable--split-linked-modules
by default when using the no-modules target.--split-linked-modules
is already disabled by default, but not when usingwasm-bindgen-cli-support
, e.g.wasm-bindgen-test-runner
.The text was updated successfully, but these errors were encountered: