Registry / devops / assemblyscript

assemblyscript

JSON →
library0.28.18jsnpmunverified

AssemblyScript compiles a strict variant of TypeScript to WebAssembly using Binaryen. Current stable version is 0.28.x, released quarterly. It generates lean and mean WebAssembly modules while being just an npm install away. Key differentiators vs. Emscripten or Rust/Wasm: uses TypeScript-like syntax, has a dedicated standard library, and a runtime optimized for Wasm. Targets Node.js >=20 and npm >=10.

npm install assemblyscript
INSTALL
IMPORT
SIG · ASSEMBLYSCRIPT
A
assemblyscript
devopsjavascriptv0.28.18
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Asc
import { Asc } from 'assemblyscript'
const Asc = require('assemblyscript')
AssemblyScript is ESM-only. Use named import for the compiler CLI.
compile
import { compile } from 'assemblyscript'
const compile = require('assemblyscript').compile
Use named import for the compiler function.
binaryen
import binaryen from 'assemblyscript'
import * as binaryen from 'assemblyscript'
Default import gives the binaryen module.
transform
import { Transform } from 'assemblyscript/dist/transform'
import { Transform } from 'assemblyscript'
Transform is in a subpath export.

Compiles a simple AssemblyScript function to Wasm binary using the compiler API.

import { compile } from 'assemblyscript'; const result = compile('export function add(a: i32, b: i32): i32 { return a + b; }', { optimize: 3, exportAll: true }); const wasm = result.binary; console.log(wasm.length);
Debug
Known issues
breakingIn v0.27, the compiler API changed from synchronous to async.
fix
Use async/await with compile().
affects: >=0.27
deprecatedRuntime functions like __new are deprecated in favor of new operator.
fix
Use new instead of manual runtime calls.
affects: >=0.28
gotchaAssemblyScript enforces strict type checking at compile time; you cannot use Any or dynamic types.
fix
Use proper concrete types (e.g., i32, f64, string).
affects: *
gotchaGlobal variable initializers must be constants, not expressions.
fix
Use static class fields or inline initialization where possible.
affects: *
gotchaAssemblyScript does not support closures or garbage collection in the traditional sense; memory must be manually managed.
fix
Use Array and Map from the standard library for automatic memory management.
affects: *
Errors
Common errors & fixes
ERROR: Cannot find module 'assemblyscript'
Package not installed in current project.
fix
npm install assemblyscript
TypeError: (intermediate value).compile is not a function
Using ESM import incorrectly with CommonJS require.
fix
Use `import { compile } from 'assemblyscript'` instead of require.
ERROR: Unknown option '--optimize'
Using a flag that does not exist in the current version.
fix
Check documentation for correct CLI flags; use `--optimizeLevel` instead.
ERROR: AssemblyScript runtime is not initialized
Trying to use runtime functions without calling `__initialize()` or using `export function` without proper setup.
fix
Use `export function` and ensure the generated Wasm includes the runtime.
Upgrade
Version history
0.28.18latest on npm
Audit
Dependencies
binaryenrequiredWebAssembly optimizer used during compilation
Agent activity
16 hits · last 30 days
node
12
OpenAI (training)
1
Resources
assemblyscript — npm install assemblyscript · libregistry