Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mdn/webassembly-examples
Code examples that accompany the MDN WebAssembly documentation — see https://developer.mozilla.org/en-US/docs/WebAssembly.
https://github.com/mdn/webassembly-examples
wasm webassembly
Last synced: 5 days ago
JSON representation
Code examples that accompany the MDN WebAssembly documentation — see https://developer.mozilla.org/en-US/docs/WebAssembly.
- Host: GitHub
- URL: https://github.com/mdn/webassembly-examples
- Owner: mdn
- License: cc0-1.0
- Created: 2017-02-22T16:49:20.000Z (over 7 years ago)
- Default Branch: main
- Last Pushed: 2024-04-01T05:52:22.000Z (7 months ago)
- Last Synced: 2024-04-08T16:23:46.122Z (7 months ago)
- Topics: wasm, webassembly
- Language: WebAssembly
- Homepage:
- Size: 435 KB
- Stars: 1,081
- Watchers: 48
- Forks: 251
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
- awesome-list - webassembly-examples - US/docs/WebAssembly. | mdn | 795 | (WebAssembly)
README
# webassembly-examples
Code examples that accompany the MDN WebAssembly documentation — see https://developer.mozilla.org/en-US/docs/WebAssembly.
## Testing/modifying the examples
The examples can be tested locally by running a [local server](https://developer.mozilla.org/en-US/docs/Learn/Common_questions/Tools_and_setup/set_up_a_local_testing_server#using_python) to serve your directory of choice.
If you modify any `.wat` files for testing you will need to generate a corresponding `.wasm` file, replacing the existing version in the folder.
This can be done using the `wat2wasm` tool, which is part of the [WABT: The WebAssembly Binary Toolkit](https://github.com/WebAssembly/wabt/) (for setup/usage see [Converting the text .wat into a binary .wasm file](https://developer.mozilla.org/en-US/docs/WebAssembly/Text_format_to_Wasm#converting_the_text_.wat_into_a_binary_.wasm_file) on MDN and the readme in the WABT GitHub repo.Note that some examples use features that are still considered optional.
These are listed in the [supported proposals](https://github.com/WebAssembly/wabt/#supported-proposals) section on the WABT README.md, along with the flags used to invoke them.
For example, to build WASM for the [multi-memory](https://github.com/mdn/webassembly-examples/blob/main/understanding-text-format/multi-memory.wat) example you will need to specify the `--enable-multi-memory` flag as shown:```sh
wat2wasm --enable-multi-memory multi-memory.wat
```