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

Tracking issue for javascript bundler integration #8

Open
aturon opened this Issue Jan 12, 2018 · 7 comments

Comments

Projects
None yet
5 participants
@aturon
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 from Tracking issue for bundler integration to Tracking issue for javascript bundler integration Jan 12, 2018

@steveklabnik

This comment has been minimized.

Contributor

steveklabnik commented Jan 12, 2018

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

@linclark

This comment has been minimized.

linclark commented Jan 13, 2018

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

@aturon aturon added the packaging label Jan 13, 2018

@aturon

This comment has been minimized.

Contributor

aturon commented Jan 13, 2018

@mgattozzi

This comment has been minimized.

Member

mgattozzi commented Jan 23, 2018

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

This comment has been minimized.

Contributor

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

This comment has been minimized.

Contributor

alexcrichton commented Jan 30, 2018

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 referenced this issue Jan 30, 2018

Open

New targets #38

@alexcrichton

This comment has been minimized.

Contributor

alexcrichton commented Mar 4, 2018

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

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