Make the plugin to look for the entire folder rather than the individual file
sendilkumarn opened this issue · 8 comments
@catsigma Let us make the plugin to look for the entire folder crate/pkg
(created by wasm-pack) rather than looking at the specific rust file.
Just like https://github.com/wasm-tool/wasm-pack-plugin
WDYT?
cc: @fitzgen
Perfect. @catsigma let me know if there is anything that I can help with. ( but I am a complete newbie in parcel)
If it has to require a specific file, I suggest using the Cargo.toml
. src/lib.rs
is the convention, but the entry point to a library can be arbitrary and configured in Cargo.toml
.
The Cargo.toml
-- on the other hand -- is representative of the whole crate that is being compiled to wasm.
@fitzgen The problem is Parcel only support to hook on a file extension like .toml
. So we won't be able to import normal .toml
assets if we register the plugin to .toml
.
I've figured out a solution.
Let the plugin generates an empty .wasm.rs
file automaticlly aside the node_modules
folder.
In JS file
import { foo } from 'path/to/.wasm.rs'
@sendilkumarn @fitzgen How about this?
Sorry, I've found a way to fallback to origin TOML file assets handler. Now we can just import from Cargo.toml
.
fixed @ version "1.2.0"
Thanks @catsigma