Import WebAssembly code with Browserify.
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
test
.gitignore
index.js
license
package-lock.json
package.json
readme.md

readme.md

wasmify

Require WebAssembly modules with Browserify.

Use this Browserify plugin to import WebAssembly binaries.

Install

$ npm i -D wasmify

Usage

Simply load the plugin:

$ browserify -p wasmify

Which allows you to import .wasm files in your source:

const sampleModule = require('./sample.wasm')

sampleModule(imports).then(sample => {
  sample.instance.exports.main(12, 34)
})

Sync modules

Small modules (< 4KB) can be imported synchronously through a sync option.

b.plugin(wasmify, {
  sync: [
    'sample.wasm'
    // ...
  ]
})

This means that the exports can be accessed immediately.

const sampleModule = require('sample.wasm')

const sample = sampleModule(imports)

sample.instance.exports.main(12, 34)