menu
announcement

Spectrum is now read-only. Learn more about the decision in our official announcement.

Parcel

📦🚀 Blazing fast, zero configuration web application bundler

Channels
Team

Import Rust Asset as Wasm w/o Writing "bindgen" into Bundle Loader

May 3, 2019 at 9:41pm

Import Rust Asset as Wasm w/o Writing "bindgen" into Bundle Loader

May 3, 2019 at 9:41pm
Hi there, I would love to import { run } from './lib.rs'; run(); and have Parcel compile my library to wasm (using wasm-pack) and then dynamically load the wasm module without writing the importsObject into the bundle loader (the approach taken by parcel-plugin-wasm.rs … and the approach I implemented in my own plugin parcel-plugin-wasm-pack).
Writing the importsObject into the loader has the advantage of being "easy" but the disadvantage that any other *.rs asset loaded then use that same loader and so must all share the same wasm-bindgen generated interface or fail at runtime. I have asked in the Rust #wasm-wg Discord, left a comment here: https://github.com/parcel-bundler/parcel/issues/647#issuecomment-487412779 and opened an issue on my own plugin here: https://github.com/mysterycommand/parcel-plugin-wasm-pack/issues/9
I've been digging at this as I'm able all week, and will continue to do so. Any help/guidance would be greatly appreciated. I really love working with Parcel and want to make it easier for everyone to try out Rust/Wasm.

May 16, 2019 at 7:20am
Is this plugin ready to use yet and how would I use it? There seems to be no documentation present