Commit 3d3723bf authored by Tomáš Hübelbauer's avatar Tomáš Hübelbauer

Lay ground for Rust and WebAssembly import example

parent 811e781c
# Parcel
- [ ] Create an example of Parcel bundling Rust and WebAssembly which it both supports out of the box I think
- Document if any why importing Rust files like that is a bad idea and if they perhaps should be in a module and imported as Wasm of that module
- [ ] Consult [albizures/parcel-rust](https://github.com/albizures/parcel-rust) for more information and inspiration
- [ ] Figure out why commenting out the Rust `add` function call works but not commenting it out results in an empty page with no errors
- [ ] Add an example of straight up `import`ing a WebAssembly file
- [ ] Add an example of `import`ing Rust more complexly by importing a Cargo crate and not a simple Rust file
## Installing
......@@ -17,6 +19,10 @@
It just works! Reference `index.ts` in your `index.html` and you're all set bruv.
### Rust
## Contributing
- [ ] Try out [Rust in Parcel](https://www.reddit.com/r/rust/comments/7z8imh/announcing_stdweb_04_now_with_support_for_parcel/)
import * as qrcode from 'qrcode-generator';
import { add } from './test.rs';
window.addEventListener('load', async _ => {
const qr = qrcode(0, 'H');
qr.addData(await parcel());
qr.make();
document.body.innerHTML = qr.createImgTag(10);
console.log(add);
});
......
#[no_mangle]
pub fn add(a: i32, b: i32) -> i32 {
return a + b
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment