An AssemblyScript template with support for many environments
This template is all you need to get started in AssemblyScript. It allows you to write a library in AssemblyScript, and use it in various environments.
- The wasm library is in
./src/wasm/. This is the AssemblyScript file that exports the functions for your library. - The browser app is in
./src/browser/. It sets up a simple form to get input from the user and passes it to the wasm. - The node wrappers are in
./src/node. Thelib.tsfile is a library file, and thecli.tsfile is meant to be used as a Node bin. - The wasi wrappers are in
./src/wasifolder.
Note: The AssemblyScript files have a .as.ts or .as extension, and the TypeScript files have a .ts extension.
npm install
npm run build.wasm./dist/index.wasm
export function doSomething(input: string): stringBuild:
npm install
npm run build.browser
Run:
npm run start.browser
Build:
npm install
npm run build.browser
import { doSomething } from "./dist/browser/lib.js"
await doSomething("input")Build:
npm install
npm run build.nodeRun:
node ./dist/node/cli.js 'input'import { doSomething } from "./dist/node/lib.js"
const output = await doSomething("input")Build:
npm install
npm run build.wasiRun:
wasmtime ./dist/wasi.wasm 'input'