mirror of
https://github.com/rustwasm/wasm-bindgen.git
synced 2024-12-27 03:55:20 +03:00
02b7021053
This commit leverages two new attributes in the Rust compiler, `#[wasm_custom_section]` and `#[wasm_import_module]`. These two attributes allow removing a lot of hacks found in wasm-bindgen and also allows removing the requirement of `wasm-opt` to remove the unused data sections. This does require two new nightly features but we already required the `proc_macro` nightly feature and these will hopefully be stabilized before that feature! |
||
---|---|---|
.. | ||
console_log | ||
dom | ||
hello_world | ||
math | ||
performance | ||
smorgasboard | ||
wasm-in-wasm | ||
README.md |
Examples
This directory contains a number of examples of the #[wasm_bindgen]
macro and
how to display them in the browser. Each directory should contain a build.sh
which assembles all the relevant files, and then if you open up index.html
in
a web browser you should be able to see everything in action!
The examples here are:
hello_world
- the "hello world" of#[wasm_bindgen]
, aka throwing up a dialog greeting youconsole_log
- a showcase of#[wasm_bindgen]
importing classes and how to bindconsole.log
math
- likeconsole_log
except showing how to import Math-related functions insteaddom
- an example of accessing the globaldocument
object and appending HTML to itsmorgasboard
- a bunch of features all thrown into one, showing off the various capabilities of the#[wasm_bindgen]
macro and what you can do with it from JSperformance
- how to import APIs likeperformance.now()
and time various operations in Rustwasm-in-wasm
- how to interact with namespaced APIs likeWebAssembly.Module
and shows off creation of a WebAssembly module from Rust