Choose one: ๐ feature request
Running the following code should work
// rust.rs
#[no_mangle]
fn get_string() -> String {
String::new("string")
}
import { get_string } from "./rust.rs";
assert(get_string() === "string");
Currently, with that Rust code, you will get undefined
when called from JS causing the asserting to fail.
Admittedly, I'm probably not someone who's anywhere near authorized enough to open this issue, but my intention here is to get some discussion started on it at least. Maybe some more experienced rustaceans can chime in with some actual useful information regarding this.
From the little research I did (mind you, I didn't actually test this), there is a project called wasm-bindgen by @alexcrichton that can be used to fix this behavior. Maybe that could somehow be integrated into parcel.
| Software | Version(s) |
| ---------------- | ---------- |
| Parcel | 1.5.1
| Node | 9.3.0
| npm/Yarn | npm 5.5.1
| Operating System | Fedora 27
Hello! At least on the Rust side of things my current plan at least is to advertise https://github.com/alexcrichton/wasm-bindgen for this use case (as you've pointed out). It's not quite ready for prime time but I think it's something Parcel may want to have knowledge of! In its final state it'd probably look something like:
wasm-bindgen
section (naming TBD)wasm-bindgen
section is found, then the wasm-bindgen
tool is executed on the wasm file, generating a JS and a wasm file. (the JS file replaces the original wasm file, and the new wasm file generated is imported by the JS file)Ideally in the long run the "Rust project" aspect can be replaced with "any native project compiling to wasm" too!
Hi! Can we expect any progress on this feature in near future? )
I would really love to use wasm-bindgen with parcel
If I try to build this project with parcel, it panics at __wasm_bindgen_unstable
section, which is expected behaviour for now, I suppose.
Maybe, if you have other priorities at the moment, I could try to do it myself. I'd love to help, but I'm not sure I have enough skills for this task. ) How difficult is to implement its support?
I've made a plugin to solve this issue.
https://www.npmjs.com/package/parcel-plugin-wasmbindgen
It works for me.
(Currently the package name is parcel-plugin-wasm.rs
)
@catsigma, haven't checked it yet, but this sounds very nice! May I ask you to publish your plugin on github as well, so we could contribute to your work?
Sure, lโll establish a github repo for it later today.
Friday, September 14, 2018, 18:56 +0800 from [email protected] notifications@github.com:
@catsigma , haven't checked it yet, but this sounds very nice! May I ask you to publish your plugin on github as well, so we could contribute to your work?
โ
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub , or mute the thread .
@catsigma would be cool if you could try gets wasm bindings working inside parcel core. We could def use someone to improve rust support/stability inside parcel
Sent with GitHawk
Iโve checked the related parts of source codes. It may take huge change to support wasm module by default. So I think a plugin supporting wasm-bind gen exclusively is better.
Friday, September 14, 2018, 23:13 +0800 from [email protected] notifications@github.com:
@catsigma would be cool if you could try gets wasm bindings working inside parcel core. We could def use someone to improve rust support/stability inside parcel
Sent with GitHawk
โ
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub , or mute the thread .
Most helpful comment
Hello! At least on the Rust side of things my current plan at least is to advertise https://github.com/alexcrichton/wasm-bindgen for this use case (as you've pointed out). It's not quite ready for prime time but I think it's something Parcel may want to have knowledge of! In its final state it'd probably look something like:
wasm-bindgen
section (naming TBD)wasm-bindgen
section is found, then thewasm-bindgen
tool is executed on the wasm file, generating a JS and a wasm file. (the JS file replaces the original wasm file, and the new wasm file generated is imported by the JS file)Ideally in the long run the "Rust project" aspect can be replaced with "any native project compiling to wasm" too!