rollup-plugin-webassembly
A rollup plugin that inlines (base64 encoded) and imports WebAssembly modules.
; ;
Installation
Install via npm:
npm install --save-dev rollup-plugin-webassembly
Configuration
Simply add the plugin to your rollup config. Any imported file with the wasm
extension will be processed by this plugin.
;; ;
This plugin also supports the standard include / exclude pattern:
;
Example
Given the following simple C file, compiled to wasm (using emscripten, or the online WasmFiddle tool):
int
The plugin will look for any wasm imports. For any it finds, the wasm file is inlined as a base64 encoded string (which means it will be ~33% larger than the original). The string is decoded and asynchronously compiled into a wasm module, which is returned by the import"
; ;
If your wasm module requires imports, these can be supplied as the first argument to the wasm function:
; ;