Skip to content

Latest commit

 

History

History
53 lines (35 loc) · 844 Bytes

readme.md

File metadata and controls

53 lines (35 loc) · 844 Bytes

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)