Wasm By Example is a website containing simple examples for how to get things done with wasm.
Table of Contents
- Getting Started
This project is heavily inspired by Go By Example. Wasm is still relatively young, and I thought it would be great to have a similar, hands-on / tutorial / introduction into WebAssembly for those who "learn by doing".
Create a GitHub account if you don't already have one.
nvm install --lts
Create your own fork of the wasm-by-example repository by clicking "Fork" in the Web UI. During local development, this will be referred to by
Download your fork to a local repository.
git clone email@example.com:<your username>/wasm-by-example.git
Add an alias called
upstreamto refer to the main
torch2424/wasm-by-examplerepository. Go to the root directory of the newly created local repository directory and run:
git remote add upstream firstname.lastname@example.org:torch2424/wasm-by-example.git
Fetch data from the
git fetch upstream master
Set up your local
masterbranch to track
origin/master(which will rapidly become outdated).
git branch -u upstream/master master
Branch (do this each time you want a new branch)
Create and go to the branch:
git checkout -b <branch name> master
Building & Running the project
- Make sure you have the latest packages (after you pull):
- To build the project, run:
npm run build
- To serve, and build on changes for the project, run:
npm run dev
Thank you for wanting to contribute! Below is a guide for contributing different parts of the project:
Examples are the individual examples, concepts, or ideas conveyed for each language. Examples are laid out in the following format:
Where the variables represent the following ideas:
EXAMPLE_NAME- is the name / title of the example.
PROGRAMMING_LANGUAGE- is the programming language used for the code snippets (e.g Rust).
READING_LANGUAGE- is the langauge that the idea is read / spoken (e.g English).
It is highly reccomended examples also offer a demo where reasonable. Demos should be placed:
Please place all relevant files there, and feel free to serve via an iframe, or link to the full source code. It is also reccomended you offer a
README.md to explain the demo, or simply offer build instructions.
Now that we understand how examples are made, let's see some general guidance for contributing examples:
Creating a new Example
Awesome! Glad to see new examples and ideas! I'd reccomended opening an issue before contributing an entirely new example. This way we can discuss if the example idea is beneficial, and to bring awareness to other contributors that ma want to do any translations and things.
After the idea has been discussed, feel free to open a PR following the format explained above, and we can review and add it to the website!
By default, all new examples will be last in the example list on the homepage. To set the order of your example, add your example's name to the array in
build-system/example-order.js to set its order.
Adding a new Programming Language to an Example
If you are adding a new programming language, feel free to simply open a new PR with the format explained above, and we can review and add it to the website! NOTE: It is highly reccomended you add a demo of your example, unless there is a good reason for not providing one.
Adding a new Reading Language (Translation) to an Example
If you are adding a new reading language, feel free to simply open a new PR with the format explained above, and we can review and add it to the website! New reading languages don't require a new demo or anything like that, and simply translate the written text between examples where it seems right.
Improving the shell (the base website)
Improving the shell (E.g the language switcher or typos in the landing page and things), feel free to open a PR! For larger ideas or new sections of the site, it is reccomended to open an issue first for discussion.
Any other contributions
For all other types of contributions (E.g perhaps you are a platform that wants to expand on Wasm By Example or something), please open an issue first describing the idea, and then we can work on a PR that works for the communitty at large.
Google Analytics is used on Wasm By Example, and is only used to record Basic visit data, as the script is only loaded.
This work is copyright Aaron Turner and licensed under a Creative Commons Attribution 4.0 License.