yew icon indicating copy to clipboard operation
yew copied to clipboard

Yew (worker) agents are not webpack friendly when using web-sys

Open jstarry opened this issue 5 years ago • 1 comments

Issuehunt badges

Problem Yew starts workers by making a fake script, setting its source, and trying to call wasm_bindgen on it, which doesn't work in the scope of webpack.

Potential Solution

#[cfg(feature = "web_sys")]
fn worker_new(name_of_resource: &str, is_module: bool) -> Worker {
    let href = utils::document().location().unwrap().href().unwrap();
    let script_url = format!("{}{}", href, name_of_resource);
    cfg_if! {
        if #[cfg(feature = "webpack")] {
            return Worker::new(&script_url).expect("failed to spawn worker");
        }
    }

Context: https://github.com/yewstack/yew/issues/1046#issuecomment-602800124


IssueHunt Summary

Backers (Total: $5.00)

Become a backer now!

Or submit a pull request to get the deposits!

Tips

jstarry avatar Apr 23 '20 14:04 jstarry

@jstarry has funded $5.00 to this issue.


issuehunt-oss[bot] avatar May 12 '20 03:05 issuehunt-oss[bot]

yew-agent since 0.2 no longer creates workers. It only re-exports methods from gloo. If anyone encounters the issue please create it in gloo repository instead.

voidpumpkin avatar Apr 03 '23 19:04 voidpumpkin