Commit Graph

20 Commits

Author SHA1 Message Date
Alex Crichton
29771b574c Migrate from a macro to an attribute
This commit migrates from `wasm_bindgen!`-the-macro to
`#[wasm_bindgen]`-the-attribute. The actual mechanics of the macro are
relatively simple in just generating some shims here and there, but wrapping
everything in one huge macro invocation can often seem intimidating as it gives
off this feeling of "oh dear anything can happen here!" Using an attribute
should curb expectations much more greatly of "oh there's just some extra stuff
happening behind the scenes".

The usage is otherwise relatively straightforward and close to what it was
before, but check out the DESIGN.md/README.md changes for more info!
2018-02-08 10:18:16 -08:00
Alex Crichton
e9d612a343 Implement optionally catching exceptions 2018-02-06 19:04:12 -08:00
Alex Crichton
e60aa6a990 Rename JsObject to JsValue
Let's reserve `JsObject` for something we actually know is an object
2018-02-06 15:04:46 -08:00
Alex Crichton
9ac713d4eb Reword intro in README
Not really an exclusive polyfill but moreso nice features too!
2018-02-02 08:14:05 -08:00
Alex Crichton
322f52001e No need to specify port to parcel 2018-01-30 08:06:05 -08:00
Alex Crichton
5098f97e7d Link to tests in README 2018-01-29 21:54:52 -08:00
Alex Crichton
dac2f2d170 Fix highlighting in README 2018-01-29 21:53:33 -08:00
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