IMI-eRnD-Be / wasm-run

Bundles and tooling for Rust WASM frontend application
MIT License
35 stars 3 forks source link

JS snippets #26

Open cecton opened 3 years ago

cecton commented 3 years ago

I think JS can be imported and used from rust using this snippets thingies in wasm-bindgen: https://github.com/rustwasm/wasm-bindgen/blob/master/crates/cli-support/src/lib.rs#L634

This is missing in wasm-run and there is no public method in cli-support to generate them explicitly without generating a whole of different things.

cecton commented 3 years ago

Apparently there is an issue with wasm-bindgen snippets that remove the unused snippets of the final build. This is probably something we can address while doing this issue.

wasm-bindgen does this weird thing that when if the imported JS isn't used, it doesn't include in the binary. This becomes in a problem when all the JS needs to do is be imported to perform its function i.e. load the web component. This hack is required to have components to load (hamza1311/yew-material#1). This is non-optimal but there is nothing Yew can do about it.

https://github.com/yewstack/yew/issues/1666