Client-side WebAssembly with Webpack
Web applications continue to grow in complexity and size. Simply serving up a few handwritten HTML, CSS, and JavaScript files is not feasible for large applications. To manage this complexity, web developers use bundlers to allow for modularization, ensure browser compatibility, and reduce the size of JavaScript files. In this section, we're going to be using a popular bundler, Webpack, to utilize Wasm without using emcc
.
Â
Â
Overview of the project
The example Webpack application extends the functionality of the C code we wrote in the Compiling C without the glue code section of Chapter 5, Creating and Loading a WebAssembly Module. Instead of showing a blue rectangle bouncing around a red background, we'll show an alien in a spaceship bouncing around the Horsehead Nebula. The collision detection functionality has been modified to accommodate for bouncing within a rectangle, so the movement of the spaceship will be random. The code for this section is located...