Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--no-modules for wasm-pack #317

Closed
catsigma opened this issue Sep 20, 2018 · 10 comments · Fixed by #327
Closed

--no-modules for wasm-pack #317

catsigma opened this issue Sep 20, 2018 · 10 comments · Fixed by #327
Assignees
Labels
feature request PR attached there's a PR open for this issue to-do stuff that needs to happen, so plz do it k thx

Comments

@catsigma
Copy link

💡 Feature description

--no-modules comes with wasm-bindgen-cli and it's needed for some bundlers.

@ashleygwilliams ashleygwilliams added to-do stuff that needs to happen, so plz do it k thx feature request labels Sep 20, 2018
@ashleygwilliams
Copy link
Member

i agree that wasm-pack should support all the options that wasm-bindgen has! i am curious which bundlers need to use --no-modules (just for my own edification!). thanks for filing this :)

@catsigma
Copy link
Author

catsigma commented Sep 20, 2018 via email

@ashleygwilliams
Copy link
Member

oh! interesting. we've been working with the Parcel team, and i am aware that the current way they handle wasm is slightly different from the webpack use case. thanks for the information.

tagging in @jamiebuilds - is supporting for an export object in the wasm loader on the roadmap? would like to hear your general thoughts on this (and anyone else on the team that might be working on this!) thanks :D

@ashleygwilliams ashleygwilliams self-assigned this Sep 21, 2018
@ashleygwilliams
Copy link
Member

@catsigma i'm gonna work on getting this in for 0.5.0 case (regardless of how the follow up with the Parcel folks shakes out) thanks again so much for the info! it's very helpful :)

@catsigma
Copy link
Author

catsigma commented Sep 21, 2018 via email

@ashleygwilliams
Copy link
Member

oh! as a followup- @catsigma what package.json keys would you want? any? perhaps browser?

@ashleygwilliams ashleygwilliams added the PR attached there's a PR open for this issue label Sep 21, 2018
@jamiebuilds
Copy link
Member

Hey @catsigma, could you share what you're doing in https://github.com/catsigma/parcel-plugin-wasmbindgen ? Just trying to figure out what Parcel is missing

@catsigma
Copy link
Author

@jamiebuilds What I've done is pretty simple.

  1. Hook my custom .rs asset in Parcel.
  2. Compile the imported .rs file in .js file by using wasm-pack or cargo & wasm-bindgen-cli.
  3. Get the generated no-modules JS adaptor and modify it to be a Parcel wasm loader.
  4. Hook the modified wasm loader.
  5. Disguise the .rs file as a .js file coding with importing the wasm file and exporting exports functions of it.
  6. Parcel does the bundle job.

The problem in Parcel is that the default wasm loader doesn't contain an __exports argument.
So we can only use these i32 i64 f32 f64 types.

@catsigma
Copy link
Author

@ashleygwilliams sorry, but I don't know what is the key in package.json for?

@catsigma
Copy link
Author

catsigma commented Sep 23, 2018

@ashleygwilliams @jamiebuilds
I've figured out a way to overcome this issue by modifying es-modules version to no-modules version manually.

github: https://github.com/catsigma/parcel-plugin-wasm.rs
npm: https://www.npmjs.com/package/parcel-plugin-wasm.rs

And it supports both wasm-pack and wasm-bindgen-cli now.

Thank you both.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request PR attached there's a PR open for this issue to-do stuff that needs to happen, so plz do it k thx
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants