Snowpack 3.0 is out now! Read the announcement post →

WASM

WASM (short for WebAssembly) is a portable compilation target for programming languages, enabling deployment on the web for client and server applications.

To use WASM with Snowpack: Use the browser’s native WebAssembly & fetch APIs to load a WASM file into your application:

// Example: Load WASM in your project
const wasm = await WebAssembly.instantiateStreaming(
fetch('/example.wasm'),
/* { ... } */
);

In the future, we may add import "/example.wasm" ESM import support to automate this support for you. However, today WASM import support differs from bundler-to-bundler.

In any case, WASM import support would just be a shortcut or wrapper around the code snippet above. You can recreate this helper today in your own project:

// Example: WASM Loader (move this into some utility/helper file for reuse)
export function loadWasm(url, importObject = {module: {}, env: {abort() {}}}) => {
const result = await WebAssembly.instantiateStreaming(fetch(url), importObject);
return result.instance; // or, return result;
}

const wasm = await loadWasm('/example.wasm');