Skip to content

Conversation

@mohe2015
Copy link
Contributor

@mohe2015 mohe2015 commented Oct 10, 2025

Now I can use one wasm bundle for the worker and frontend

@mohe2015 mohe2015 requested a review from a team as a code owner October 10, 2025 18:31
@jkelleyrtp
Copy link
Member

Awesome! We should get an example up of creating a new worker on the fly and entering from a different entrypoint.

With dataurls, you can create a virtual worker.js that loads the current wasm bundle and then runs an exported function as its main.

None of that is too hard, we just don't have a great example for it.

@jkelleyrtp jkelleyrtp merged commit b077451 into DioxusLabs:main Oct 10, 2025
19 checks passed
@mohe2015 mohe2015 deleted the more-window-replacing branch October 10, 2025 20:05
@mohe2015
Copy link
Contributor Author

Yeah I'm already doing that. Maybe I will find the time to add an example sometime. Currently I still want to upstream some stuff so I can switch back to upstream directly

@rsaccon
Copy link

rsaccon commented Oct 10, 2025

I have an interesting use case for an example using webworker in Dioxus: Turso DB (sqlite rust rewrite beta) in dioxus web.
Turso db can be compiled to wasm, they ship Javascript bindings and they just published an Article on the inner workings of running the DB in the browser, which involves a webworker. I started myself to dig into this, but I am still at the very beginning, studying the examples at the wasm-bindgen guide.

@mohe2015
Copy link
Contributor Author

mohe2015 commented Oct 10, 2025

@rsaccon I'm actually already doing this with sqlite_wasm_rs, see https://github.com/tucan-plus/tucan-plus/blob/7d301ebae08d0e3940710077ef59db6aa7d5b45b/crates/tucan-plus-dioxus/src/main.rs

Edit: Also relevant is probably https://github.com/tucan-plus/tucan-plus/blob/7d301ebae08d0e3940710077ef59db6aa7d5b45b/crates/tucan-plus-worker/src/lib.rs#L576

Edit 2: Note that #4758 is currently blocking this with --release

Edit 3: Note that my approach does not use the SharedArrayBuffer so I do not need to set the headers etc. Also I don't use WASI.

@rsaccon
Copy link

rsaccon commented Oct 10, 2025

@mohe2015 thanks a lot for the explanation and links.

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

Labels

None yet

3 participants