Commit Graph

63 Commits

Author SHA1 Message Date
Alex Crichton
c51a342cb3 Rewrite wasm-bindgen with ES6 modules in mind
This commit is a mostly-rewrite of the `wasm-bindgen` tool. After some recent
discussions it's clear that the previous model wasn't quite going to cut it, and
this iteration is one which primarily embraces ES6 modules and the idea that
this is a polyfill for host bindings.

The overall interface and functionality hasn't changed much but the underlying
technology has now changed significantly. Previously `wasm-bindgen` would emit a
JS file that acted as an ES6 module but had a bit of a wonky interface. It
exposed an async function for instantiation of the wasm module, but that's the
bundler's job, not ours!

Instead this iteration views each input and output as a discrete ES6 module. The
input wasm file is interpreted as "this *should* be an ES6 module with rich
types" and the output is "well here's some ES6 modules that fulfill that
contract". Notably the tool now replaces the original wasm ES6 module with a JS
ES6 module that has the "rich interface". Additionally a second ES6 module is
emitted (the actual wasm file) which imports and exports to the original ES6
module.

This strategy is hoped to be much more amenable to bundlers and controlling how
the wasm itself is instantiated. The emitted files files purely assume ES6
modules and should be able to work as-is once ES6 module integration for wasm is
completed.

Note that there aren't a ton of tools to pretend a wasm module is an ES6 module
at the moment but those should be coming soon! In the meantime a local
`wasm2es6js` hack was added to help make *something* work today. The README has
also been updated with instructions for interacting with this model.
2018-01-29 21:50:01 -08:00
Johann Hofmann
a84f87040d
Really fix bindings link in README.md 2018-01-20 19:20:01 +01:00
Johann Hofmann
04a3e596a5
Fix bindings link in README.md 2018-01-20 18:47:44 +01:00
Ralph Giles
5b37523d87 Fix typos in the README. 2018-01-15 15:12:38 -08:00
Alex Crichton
737bd8c965 Add objects to the top of the README 2017-12-19 20:00:52 -08:00
Alex Crichton
5b079b8f60 Update gist output 2017-12-19 19:21:43 -08:00
Alex Crichton
85cdb51719 Generate TypeScript by default instead of JS
This is what's needed in the immediate future anyway, so let's do that!
2017-12-19 19:06:48 -08:00
Alex Crichton
34e4cfa95d Link to generated JS bindings 2017-12-19 09:33:52 -08:00
Alex Crichton
db37034d11 Add some notes about impl details of objects 2017-12-19 09:30:57 -08:00
Alex Crichton
946e5317fe Support passing JS objects through Rust 2017-12-19 09:25:41 -08:00
Alex Crichton
eda9beae25 Get imports working in a basic capacity 2017-12-18 21:43:16 -08:00
Alex Crichton
9ec77e2b44 Add a basic README which at least attempts 2017-12-18 16:35:36 -08:00
Alex Crichton
abb9c845a5 Add CI and a small README 2017-12-18 14:49:04 -08:00