10 WebAssembly modules in Node.js

 

This chapter covers:

  • Loading a WebAssembly module using Emscripten’s generated JavaScript code
  • Using the WebAssembly JavaScript API to load a WebAssembly module
  • Working with WebAssembly modules that call into JavaScript directly
  • Working with WebAssembly modules that use function pointers to call into JavaScript

In this chapter you’ll learn how to use WebAssembly modules in Node.js. With Node.js, there are some differences compared with a browser, like there being no graphical user interface. There are a lot of similarities between the JavaScript needed in a browser and in Node.js when working with WebAssembly modules. Even with the similarities, however, it’s recommended that you test your WebAssembly module in Node.js to verify that it works as expected on the versions of Node.js that you want to support.

Node.JS

Node.js is a JavaScript runtime built on the V8 engine that is the same engine that also powers the Chrome web browser. Node.js allows for JavaScript to be used as server-side code. It also has a large number of open-source packages available to help with many programming needs. For a book dedicated to teaching you about Node.js, Manning, see Node.js in Action, Second Edition: https://www.manning.com/books/node-js-in-action-second-edition

10.1  Revisiting what you know

 
 
 

10.2  Server-side validation

 
 

10.3  Working with Emscripten-built modules

 
 
 

10.3.1    Loading a WebAssembly module

 
 

10.3.2    Calling functions in the WebAssembly module

 
 

10.3.3    Calling into the JavaScript

 
 
 
 

10.3.4    Calling JavaScript function pointers

 
 
 
 

10.4  Using the WebAssembly JavaScript API

 
 
 

10.4.1    Loading and instantiating a WebAssembly module

 
 

10.4.2    Calling functions in the WebAssembly module

 
 
 

10.4.3    The WebAssembly module calling into the JavaScript

 
 
 

10.4.4    The WebAssembly module calling JavaScript function pointers

 
 
 

10.5  Exercises

 
 
 

10.6  Summary

 
 
sitemap

Unable to load book!

The book could not be loaded.

(try again in a couple of minutes)

manning.com homepage
test yourself with a liveTest