Skip to content

jamen/wasmify

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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)

About

Import WebAssembly code with Browserify.

Resources

License

Stars

Watchers

Forks

Packages

No packages published