Skip to content
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

web_sys::WorkerOptions is old spec lacking "type" and thus preventing module imports #2566

Open
KC2021 opened this issue May 27, 2021 · 1 comment

Comments

@KC2021
Copy link

KC2021 commented May 27, 2021

Motivation

WorkerOptions is missing "pub fn type()", this prevents Workers from using modules.
This is a significant issue in allowing developers to work with Workers when using rustwasm.

Proposed Solution

The solution is quite simple and shouldn't involve much.
The current web_sys implementation just needs to be updated to the current MDN spec (see "options").
The implementation would be similar to "name" which already exists, but for the property "type" instead.

The "type" could be defined the same way BlobPropertyBag's type parameter is for example.
There' is also the parameters "credentials" that may be added also.

Alternatives

None

Additional Context

This feature is quite crucial in multi-threaded rustwasm applications using Workers bootstrapped within Rust.

@greenpdx
Copy link

greenpdx commented Aug 5, 2021

I would like to run wasm in a Worker, but I need a WorkerOptions type: "module"

I created a new project with wasm-pack.
I cloned wasm-bindgen
but when I change the default to a path

wasm-bindgen = { path = "/home/ubuntu/wasm-bindgen", version = "0.2.75" }

    Updating crates.io index
error: failed to select a version for `wasm-bindgen-shared`.
    ... required by package `wasm-bindgen-macro-support v0.2.75`
    ... which is depended on by `wasm-bindgen-macro v0.2.75`
    ... which is depended on by `wasm-bindgen v0.2.75`
    ... which is depended on by `js-sys v0.3.52`
    ... which is depended on by `wasm-bindgen-futures v0.4.25`
    ... which is depended on by `wasm-bindgen-test v0.3.25`
    ... which is depended on by `webtst v0.1.0 (/home/ubuntu/webtst)`
versions that meet the requirements `=0.2.75` are: 0.2.75

the package `wasm-bindgen-shared` links to the native library `wasm_bindgen`, but it conflicts with a previous package which links to `wasm_bindgen` as well:
package `wasm-bindgen-shared v0.2.75 (/home/ubuntu/wasm-bindgen/crates/shared)`
    ... which is depended on by `wasm-bindgen-backend v0.2.75 (/home/ubuntu/wasm-bindgen/crates/backend)`
    ... which is depended on by `wasm-bindgen-macro-support v0.2.75 (/home/ubuntu/wasm-bindgen/crates/macro-support)`
    ... which is depended on by `wasm-bindgen-macro v0.2.75 (/home/ubuntu/wasm-bindgen/crates/macro)`
    ... which is depended on by `wasm-bindgen v0.2.75 (/home/ubuntu/wasm-bindgen)`
    ... which is depended on by `webtst v0.1.0 (/home/ubuntu/webtst)`

failed to select a version for `wasm-bindgen-shared` which could resolve this conflict
ubuntu@sysdyn:~/webtst$ 

I am willing to create a PR for this, I really need "type" as a WorkerPptions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants