Copyright 2019-2021 Moddable Tech, Inc.
Revised: June 14, 2021
This document provides instructions to build and run Moddable SDK apps for the Wasm platform.
-
Setup instructions


Setup instructions Setup instructions
-
Clone the Emscripten repository into your
~/Projectsdirectory and activate the latest version.cd ~/Projects git clone https://github.com/emscripten-core/emsdk.git cd emsdk ./emsdk install latest ./emsdk activate latestIf you already have the Emscripten repository, upgrade to the latest version using the following commands:
cd ~/Projects/emsdk git pull ./emsdk install latest ./emsdk activate latestWe last tested using version 2.0.24 (commit
e2dc11e0dbd8f9367d70c76e57cdb9a45515390e). -
Clone the Binaryen repository into your
~/Projectsdirectory and build it.cd ~/Projects git clone https://github.com/WebAssembly/binaryen.git cd binaryen cmake . && makeWe last tested using wasm-opt version 101 (commit
aec8d12282b5279b80e79f21d54491db5d55278e) -
Setup the
PATHand other environment variables by pasting the following commands into your~/.profile. The first command sources a shell script that sets environment variables for Emscripten. The second updates yourPATHto include BinaryEn.source ~/Projects/emsdk/emsdk_env.sh export PATH=~/Projects/binaryen/bin:$PATHNote: These instructions assume that your shell sources from
~/.profilewhen a new terminal is opened. That may not be the case depending on what shell you use and how you have it configured. Starting with macOS Catalina, the default shell iszshwhich uses~/.zshrcinstead.Note: You must open a new shell instance or manually run the export statements in your shell before proceeding. Adding the export statements to your
~/.profiledoes not update the environment variables in active shell instances. -
Build the Moddable Wasm tools from the command line:
cd ${MODDABLE}/build/makefiles/wasm make -
To test, build the
ballsexample for thewasmtarget.cd $MODDABLE/examples/piu/balls mcconfig -d -m -p wasmYou can run the app that's built in the browser by hosting it on a local HTTP server. Python provides a simple tool for doing this.
If you are using Python 2:
cd $MODDABLE/build/bin/wasm/debug/balls python -m SimpleHTTPServerIf you are using Python 3:
cd $MODDABLE/build/bin/wasm/debug/balls python3 -m http.serverGo to
localhost:8000in a browser. You should see a web page with a simulator runningballs.
-
Clone the Emscripten repository into your
~/Projectsdirectory and activate the latest version.cd ~/Projects git clone https://github.com/emscripten-core/emsdk.git cd emsdk ./emsdk install latest ./emsdk activate latestIf you already have the Emscripten repository, upgrade to the latest version using the following commands:
cd ~/Projects/emsdk git pull ./emsdk install latest ./emsdk activate latestWe last tested using version 2.0.4 (commit
88b4ec65923815c3077e3637eefb54ab272d2646). -
Clone the Binaryen repository into your
~/Projectsdirectory and build it.cd ~/Projects git clone https://github.com/WebAssembly/binaryen.git cd binaryen cmake . && makeWe last tested using wasm-opt version 96 (commit
a96e8310e1a58c0a43b2d0e2ff4f9db24dd9a18a) -
Setup the
PATHand other environment variables by pasting the following commands into your~/.bashrc. The first command sources a shell script that sets environment variables for Emscripten. The second updates yourPATHto include BinaryEn.source ~/Projects/emsdk/emsdk_env.sh export PATH=~/Projects/binaryen/bin:$PATHNote: You must open a new shell instance or manually run the export statements in your shell before proceeding. Adding the export statements to your
~/.profiledoes not update the environment variables in active shell instances. -
Build the Moddable Wasm tools from the command line:
cd ${MODDABLE}/build/makefiles/wasm make -
To test, build the
ballsexample for thewasmtarget.cd $MODDABLE/examples/piu/balls mcconfig -d -m -p wasmYou can run the app that's built in the browser by hosting it on a local HTTP server. Python provides a simple tool for doing this.
If you are using Python 2:
cd $MODDABLE/build/bin/wasm/debug/balls python -m SimpleHTTPServerIf you are using Python 3:
cd $MODDABLE/build/bin/wasm/debug/balls python3 -m http.serverGo to
localhost:8000in a browser. You should see a web page with a simulator runningballs.
Not all features of the Moddable SDK are supported in the Wasm simulator.
The following features are currently supported:
- All JavaScript features supported by XS
- Piu user interface framework
- Commodetto graphics library
The following features are not supported:
- Files
- Socket
- BLE
- Pins/IO
