Skip to content

Tracking issue for javascript bundler integration #8

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

Closed
aturon opened this issue Jan 12, 2018 · 8 comments
Closed

Tracking issue for javascript bundler integration #8

aturon opened this issue Jan 12, 2018 · 8 comments

Comments

@aturon
Copy link
Contributor

aturon commented Jan 12, 2018

This is a point of coordination for work that JS bundlers are doing along two fronts:

  • Consuming npm packages with .wasm binaries.
  • Allowing for direct use of Rust source.

The former is connected to our npm integration story, but will probably not be Rust-specific, since the npm packages will likely just contain a compiled .wasm blob.

@steveklabnik steveklabnik changed the title Tracking issue for bundler integration Tracking issue for javascript bundler integration Jan 12, 2018
@steveklabnik
Copy link
Contributor

(changed the title because I thought this was about ruby's Bundler, not the generic idea of a "bundler")

@linclark
Copy link

I've added a diagram of the toolchain in #5 (comment) which includes bundlers.

@aturon
Copy link
Contributor Author

aturon commented Jan 13, 2018

@mgattozzi
Copy link
Contributor

Relevant: Parcel another web bundler just added support to drop in .rs files to get wasm. See the release announcement here. If we haven't already we should reach out and see how they did it, what the pain points were, and what can be done to help.

@aturon
Copy link
Contributor Author

aturon commented Jan 30, 2018

Update: we met with the Parcel team and had a great discussion!

The main focus was on how we ultimately want to support Rust libraries getting pulled in. The short story is:

We should be able to publish an npm package that has:

  • an outer ES module written in JS, generated by wasm-bindgen, that works with JS-friendly types
  • an "inner" module, which is a .wasm file, that fully specifies its imports (giving both module and function names; see the ABI issue)

The bundler is set up to allow you to import from .wasm files as if they were ES modules, so it will natively understand what's going on, and generate the appropriate code to instantiate the .wasm module. Parcel does not yet support imports from .wasm modules, but they will start working on that now.

Note that this model is not in any way tied to Rust. In particular, the wasm-bindgen tool is ultimately intended to be language-agnostic.

We intend to chat again with Webpack to see whether they are following a similar plan.

@alexcrichton
Copy link
Contributor

I've updated wasm-bindgen with the results of the discussion ("everything is an ES6 module") and it's got some examples about how it all works!

The bundler is set up to allow you to import from .wasm files as if they were ES modules, so it will natively understand what's going on, and generate the appropriate code to instantiate the .wasm module.

Another point to add to this is that we're expecting bundlers will also resolve the imports of a wasm file itself as if it were an ES6 module. In that sense the bundler is the one that's ultimately responsible for resolving the wasm modules imports (in addition to instantiation)

@aturon aturon mentioned this issue Jan 30, 2018
@alexcrichton
Copy link
Contributor

Webpack 4.0 beta supports wasm modules natively, and the README of wasm-bindgen was rewritten to exercise this like hello_world example

@alexcrichton
Copy link
Contributor

I'm gonna close this since webpack works quite well nowadays!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants