-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Dependent module support #3034
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
base: main
Are you sure you want to change the base?
Dependent module support #3034
Conversation
09d03ab
to
077ed00
Compare
077ed00
to
1fad8d2
Compare
1fad8d2
to
bb5bdd9
Compare
Sorry but this is in the same boat for me as #3069 where I don't have the time/energy to review major changes like this. |
bb5bdd9
to
2bba3e8
Compare
b449736
to
d7287aa
Compare
d7287aa
to
94879f7
Compare
@Liamolucko, in #3168 (comment) you say that you want to support the feature provided by this PR somehow. This wasn't clear to me, so that was encouraging. This draft has some problems: It adds a big dependency and it cannot An option to solve these issues is JS parsing in another crate, that uses
Additionally, setting both No matter which approach we choose, wasm_bindgen should support multiple shims (#3247 (comment)), so the linked module can choose the expected shim format by @Liamolucko, what do you think? |
That's an interesting idea, but I think most of the problems you mentioned can be solved without farming things out to other crates. The idea I had for the syntax of picking a shim was something along the lines of As for the large swc dependency and lack of It doesn't solve the Side-note about potentially reducing the size of the JS parsing dependency: we don't really need a full JS parser to simply replace
Huh, I only just noticed now that this PR makes all of the dependencies of linked modules (and regular snippets) get included as snippets too. The fact that this applies to normal snippets too is a potential breaking change. Previously, writing Do you think there's much need for this? I always imagined linked modules being pretty small wrappers that just served to get the wasm module up and running, which wouldn't have any need for dependencies (other than the shim).
Hm, that's an interesting way of doing it. As I mentioned above, I was imagining something more like |
if val == "$wbg_main" { | ||
pl.push((imp.src.span.lo.0 + 1, imp.src.span.hi.0 - 1)); | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a little weird that "$wbg_main"
only gets expanded when used as an import specifier. That means that you can't do import("$wbg_main")
, importScripts("$wbg_main")
, require("$wbg_main")
, etc. I think it'd be better if all instances of "$wbg_main"
were expanded, not just the ones in import specifiers.
Also, I think $wbg_shim
might be a better name.
This PR now provides a draft of dependent modules on top of the already available linked modules.
Import handling and linked modules are both very useful. The combination of these features can be used to implement nearly all possible approaches of WASM integration into workers and worklets (pure JS worker, shared WASM module with message passing without threads, shared WASM memory to run threads).
This is a proof-of-concept. It is already usable, but there are a lot of remaining issues, like unclean argument parsing and that it is only tested on
--target web
.Fixes #3019