rustwasm / gloo

A modular toolkit for building fast, reliable Web applications and libraries with Rust and WASM
https://gloo-rs.web.app
Apache License 2.0
1.78k stars 146 forks source link

Add option to spawn workers as a module #421

Open JonasAlaif opened 11 months ago

JonasAlaif commented 11 months ago

Workers created with the --target web flag must be spawned as a module. This adds the option to do that, alleviating the current --target no-modules missing features described here. I will create a linked PR in trunk to add an option to create workers with this flag.

ranile commented 11 months ago

Every major browser supports it so I don't see the need to keep the no-modules around. There is no user code that needs to be updated, as far as I'm aware, as all the JS is generated by wasm-bindgen and it calls WASM.

JonasAlaif commented 11 months ago

I've changed the default to spawn the worker as a module (which means that this will be a breaking change), but I think it's worthwhile keeping the old behavior around for backwards compatibility reasons.

JonasAlaif commented 11 months ago

Ready to merge now. Will be a breaking change regardless, since both the public API of spawner is changed as well as the default as_module is changed.

JonasAlaif commented 10 months ago

@hamza1311 or @futursolo if you have time :)

JonasAlaif commented 8 months ago

This is ready to be merged @hamza1311 @futursolo

TaoVonQi commented 7 months ago

I really need this PR. Any timeline when it will be available?

JonasAlaif commented 3 weeks ago

@ranile any chance you could have a look at merging this? Hopefully there aren't any conflicts in the meantime