https://github.com/jamen/wasmify
Import WebAssembly code with Browserify.
https://github.com/jamen/wasmify
Last synced: 3 months ago
JSON representation
Import WebAssembly code with Browserify.
- Host: GitHub
- URL: https://github.com/jamen/wasmify
- Owner: jamen
- License: mit
- Created: 2017-07-01T13:20:43.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2018-03-09T19:20:14.000Z (over 8 years ago)
- Last Synced: 2025-01-12T09:42:25.851Z (over 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 46.9 KB
- Stars: 44
- Watchers: 1
- Forks: 10
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# wasmify
> Require WebAssembly modules with Browserify.
Use this [Browserify plugin](https://browserify.org/) to import [WebAssembly binaries](http://webassembly.org/).
## Install
```sh
$ npm i -D wasmify
```
## Usage
Simply load the plugin:
```sh
$ browserify -p wasmify
```
Which allows you to import `.wasm` files in your source:
```js
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.
```js
b.plugin(wasmify, {
sync: [
'sample.wasm'
// ...
]
})
```
This means that the exports can be accessed immediately.
```js
const sampleModule = require('sample.wasm')
const sample = sampleModule(imports)
sample.instance.exports.main(12, 34)
```