If you haven't done so already, you should set up your project following the steps laid out in the Hello World Example example.
First, let's add the following to our
Then, let's compile that using wasm-pack, which will create a
wasm-pack build --target web
Next, lets create an
index.js file to load and run our wasm output. Let's import the wasm initialization module from
pkg/exports.js that was generated by wasm-pack. Then, let's call the module passing in the path to our wasm file at
pkg/exports_bg.wasm that was generated by wasm-pack. Then, let's go ahead and call out exported functions, and explore what functions were NOT exported:
Lastly, lets load our ES6 Module,
index.html. And you should get something similar to the demo (Source Code) below!
Next let's take a look at WebAssembly Linear Memory.