yew
yew copied to clipboard
Yew (worker) agents are not webpack friendly when using web-sys
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)
-
jstarry ($5.00)
Become a backer now!
Or submit a pull request to get the deposits!
Tips
- Checkout the Issuehunt explorer to discover more funded issues.
- Need some help from other developers? Add your repositories on IssueHunt to raise funds.
@jstarry has funded $5.00 to this issue.
- Submit pull request via IssueHunt to receive this reward.
- Want to contribute? Chip in to this issue via IssueHunt.
- Checkout the IssueHunt Issue Explorer to see more funded issues.
- Need help from developers? Add your repository on IssueHunt to raise funds.
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.