- wasmer-sdk-v0.6.0Latest
- wasmer-sdk-v0.6.0-rc.2
- wasmer-sdk-v0.6.0-rc.1
- wasmer-sdk-v0.6.0-alpha
- wasmer-sdk-v0.5.1
- wasmer-sdk-v0.5.0
- wasmer-sdk-v0.4.1
- wasmer-sdk-v0.4.0
- wasmer-sdk-v0.4.0
- wasmer-sdk-v0.3.0
- wasmer-sdk-v0.2.0
- wasmer-sdk-v0.1.0
- v1.2.2
- v1.2.1
- v1.0.2
- v1.0.1
- v1.0.0
- v1.0.0-beta1
- v1.0.0-alpha5
- v1.0.0-alpha4
- v1.0.0-alpha3
- v1.0.0-alpha1
Wasmer JS
This repository consists of multiple packages:
Wasmer WASI
Isomorphic Javascript library for interacting with WASI Modules in Node.js, the Browser and Deno
NPM
For instaling @wasmer/wasi
run this command in your shell:
npm install --save @wasmer/wasi
And then import it in your server or client-side code with:
import { init, WASI } from '@wasmer/wasi';
Deno
This package is published in Deno in the wasm
package, you can import it direclty with:
import { init, WASI } from 'https://deno.land/x/wasm/wasi.ts';
Usage
// This is needed to load the WASI library first (since is a Wasm module)
await init();
let wasi = new WASI({
env: {
// 'ENVVAR1': '1',
// 'ENVVAR2': '2'
},
args: [
// 'command', 'arg1', 'arg2'
],
});
const moduleBytes = fetch("https://deno.land/x/wasm/tests/demo.wasm");
const module = await WebAssembly.compileStreaming(moduleBytes);
// Instantiate the WASI module
await wasi.instantiate(module, {});
// Run the start function
let exitCode = wasi.start();
let stdout = wasi.getStdoutString();
// This should print "hello world (exit code: 0)"
console.log(`${stdout}(exit code: ${exitCode})`);
Building
To build this library you will need to have installed in your system:
npm i
npm run build
Testing
Build the pkg and run the tests:
npm run build
npm run test
Pending things to implement
Currently, the Wasmer WASI implementation is only able to execute WASI packages and read the stdout.
- API to interact with the in-memory filesystem
What is WebAssembly?
Quoting the WebAssembly site:
WebAssembly (abbreviated Wasm) is a binary instruction format for a stack-based virtual machine. Wasm is designed as a portable target for compilation of high-level languages like C/C++/Rust, enabling deployment on the web for client and server applications.
About speed:
WebAssembly aims to execute at native speed by taking advantage of common hardware capabilities available on a wide range of platforms.
About safety:
WebAssembly describes a memory-safe, sandboxed execution environment […].
License
The entire project is under the MIT License. Please read the
LICENSE
file.