I wanted to learn more about wasm and how you can implement things with rust and wasm without relying on a third party library bloating my code and making larger binaries, so i researched on ways to use wasm to make small applications and realised soon that even implementing console.log is not that straight forward
How
Since you sadly can’t directly send strings back to javascript we instead have to use pointers and uint8arrays to send data back to javascript,
And the following javascript code
As you can see its a lot of code to just print something simple to the console with rust and no third party libraries, but this does allow for a more flexible way to make modules that are smaller and more portable without having to use the glue code wasm_bindgen generates.
I created a more complex example that includes compressing and a ron decoder and encoder in wasm that uses just 200kb of wasm code you can find the repository here https://github.com/Tricked-dev/rustwasmboilerplate.
I am pretty new to wasm and low level coding like this and if you have a better way to these sorts of things either faster or shorter feel free to make a pull request to the repo!
Conclusion
with this article i want to shine some light on creating wasm modules without using the wasm_bindgen or other glue code libraries.