rust-webpack-template
rust-webpack-template copied to clipboard
Web Worker example
Would be helpful to have a web-worker example... I had lots of trouble getting that to load
Would you mind sending a PR? What were your troubles?
Sure - I'm happy to fork/adapt to make a web-worker example.
Though when I tried with this repo, just as-is, I got:
error[E0277]: the trait bound `&mut syn::Field: quote::ToTokens` is not satisfied
--> /Users/davidk/.cargo/registry/src/github.com-1ecc6299db9ec823/wasm-bindgen-macro-support-0.2.21/src/parser.rs:361:44
|
361 | assert_not_variadic(&opts, &field)?;
| -^^^^^
| |
| the trait `quote::ToTokens` is not implemented for `&mut syn::Field`
| help: consider removing 1 leading `&`-references
|
= help: the following implementations were found:
<syn::Field as quote::ToTokens>
= note: required for the cast to the object type `dyn quote::ToTokens`
@dakom can you check this issue https://github.com/rustwasm/wasm-bindgen/issues/799 I think it is the same. Run cargo update
Yep, that fixed that error :)
Here you go - I put the changes in its own branch on the fork: https://github.com/dakom/rust-webpack-template/tree/worker-example
@dakom awesome, let me have a look 👍
Thanks! Related discussion fyi: https://github.com/webpack-contrib/worker-loader/issues/144
I'm running into the same error when trying to load a wasm-bindgen crate inside a web worker using webpack:
TypeError: Cannot read property '../client-wasm-worker/pkg/client_wasm_worker_bg.wasm' of undefined
This is only after using this workaround for a window is not defined
error.
Any help would be greatly appreciated.
https://github.com/VictorGavrish/rust-wasm-worker-template this is also a worker example!