Compiling and serving the result

We're only generating a Wasm module, so we can use the build task we set up in the previous chapter to compile our code. Select Tasks | Run Build Taskā€¦ or use the keyboard shortcut Ctrl/Cmd + Shift + B to compile the code. If you're not using VS Code, open a CLI instance in the /chapter-06-interact-with-js folder and run the following command:

emcc js-without-glue.cpp -Os -s WASM=1 -s SIDE_MODULE=1 -s BINARYEN_ASYNC_COMPILATION=0 -o js-without-glue.wasm

Once complete, open a terminal in the /book-examples folder, and run the following command to start your local server:

serve -l 8080

Open up a browser and navigate to http://127.0.0.1:8080/chapter-06-interact-with-js/js-without-glue.html. You should see something like this:

The Wasm module running in the browser without glue code

Just as with the previous examples, if you press the Pause button, the caption on the button should change to Start and the circle should stop moving.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset