Skip to content
Prev Previous commit
No commit message
  • Loading branch information
Pannous committed Mar 26, 2018
commit cb5453d3e00a9887e7d2d25332d26c5070e4ec45
15 changes: 9 additions & 6 deletions examples/hello-world/hello-world.sh
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
# install https://github.com/AssemblyScript/assemblyscript if not present
asc -v || npm install --save-dev AssemblyScript/assemblyscript

# compile Typescript to native WebAssembly
echo compile Typescript to native WebAssembly :
echo asc hello-world.ts -b hello-world.wasm -t hello-world.wast
asc hello-world.ts -b hello-world.wasm -t hello-world.wast

# load and run the binary in node.js
echo load and run the binary in node.js
node -i -e "
binary = require('fs').readFileSync('hello-world.wasm');
module = new WebAssembly.Module(binary);
imports = {console :{log_int : i => console.log(i) }}
instance= new WebAssembly.Instance(module,imports);
"

# load and run the binary in the browser:
echo load and run the binary in firefox:
echo open "hello-world.html"
# open "hello-world.html"

# chrome needs (local) server for example:
# sudo python -m SimpleHTTPServer 80
# open "http://localhost/hello-world.html"
echo chrome needs (local) server for example:
echo sudo python -m SimpleHTTPServer 80
echo then
echo open "http://localhost/hello-world.html"