Registry / web-framework / as2wasm

as2wasm

JSON →
library0.1.5jsnpmunverified

as2wasm is an Apache Royale tool that transpiles Actionscript (AS3) source code directly to WebAssembly (Wasm) modules. Version 0.1.5 is the latest stable release, part of the Apache Royale 0.9.x series. It enables running legacy Flash/Actionscript applications in modern browsers without the Flash plugin, targeting WebAssembly for near-native performance. Key differentiators: it is the only open-source AS3-to-Wasm transpiler, integrates with the Apache Royale framework for cross-platform UI compilation, and supports both ActionScript 3 and optional SWF input via a separate binary variant. Release cadence follows Apache Royale's quarterly releases.

npm install as2wasm
INSTALL
IMPORT
SIG · AS2WASM
A
as2wasm
web-frameworkjavascriptv0.1.5
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.

transpile
import { transpile } from 'as2wasm'
const transpile = require('as2wasm').transpile;
as2wasm is ESM-only; require() will not work. Use dynamic import or esbuild bundler.
compileFile
import { compileFile } from 'as2wasm'
Compiles a single .as file to Wasm bytes.
compileString
import { compileString } from 'as2wasm'
import compileString from 'as2wasm';
Default export is not available; use named import.
version
import { version } from 'as2wasm'
Exports package version string for runtime checks.

Demonstrates compiling ActionScript files and strings to WebAssembly modules, then instantiating them.

import { compileFile, compileString, transpile } from 'as2wasm'; // Compile a .as file to Wasm async function compileAsFile(inputFile) { const result = await compileFile(inputFile); console.log('Wasm module size:', result.byteLength); return result; } // Transpile inline ActionScript const asCode = ` class HelloWorld { static function sayHello():String { return "Hello from AS3 in Wasm!"; } } `; const wasmModule = await compileString(asCode); // wasmModule is a Uint8Array containing the Wasm binary // Instantiate and use const wasmInstance = await WebAssembly.instantiate(wasmModule); const sayHello = wasmInstance.exports['HelloWorld.sayHello']; console.log(sayHello()); // prints the string
as2wasm --version
Debug
Known issues
breakingas2wasm v0.1.0 removed the SWF-to-Wasm pipeline; use apache-royale-0.9.x-bin-js-swf for SWF support.
fix
Install the SWF variant: npm install apache-royale-0.9.x-bin-js-swf or use the royale-asjs SWF build.
affects: >=0.1.0
deprecatedThe function `compile()` was renamed to `compileString()` in v0.1.3.
fix
Replace calls to `compile()` with `compileString()`.
affects: >=0.1.3
gotchaModule uses ES modules only; importing with CommonJS `require()` throws an error.
fix
Use dynamic import (e.g., `import('as2wasm')`) in Node.js or configure your bundler for ESM.
affects: >=0.1.0
gotchaWebAssembly memory limit: AS3 strings and arrays may exceed default Wasm memory (64KB).
fix
Use the `memory` option: `compileString(code, { memory: { initial: 256, maximum: 512 } })`.
affects: >=0.1.0
breakingv0.1.4 dropped support for ActionScript 2 compatibility flags; use AS3-only.
fix
Remove `-as2` or `--as2` flags in compile options; code must be AS3 compliant.
affects: >=0.1.4
Errors
Common errors & fixes
Error: Cannot find module 'as2wasm'
Package not installed or not in the node_modules path.
fix
Run `npm install as2wasm` (or `yarn add as2wasm`) in your project root.
TypeError: as2wasm.compile is not a function
Using the old `compile()` function name replaced in v0.1.3.
fix
Use `compileString()` instead of `compile()`.
SyntaxError: Octal literals are not allowed in strict mode in AS3
ActionScript code contains legacy octal literals (e.g., 0777) not supported in strict mode.
fix
Convert octal literals to decimal or hex (e.g., 0777 -> 511 or 0x1FF).
Compile error: 'import' declarations may only appear at top level of a module
Used ES module import syntax inside ActionScript code (file), but transpiler expects AS3 import.
fix
Use ActionScript import statements: `import flash.display.Sprite;`
Wasm runtime error: out of memory (OOM) when allocating large string
WebAssembly memory insufficient for large ActionScript objects.
fix
Increase initial memory size: `compileString(code, { memory: { initial: 512 } })`.
Upgrade
Version history
0.1.5latest on npm
Audit
Dependencies
apache-royale-compilerrequiredas2wasm depends on the Apache Royale compiler for parsing and generating intermediate code.
binaryenrequiredBinaryen is used for WebAssembly optimization and validation.
Agent activity
17 hits · last 30 days
node
14
OpenAI (training)
1
Resources
as2wasm — npm install as2wasm · libregistry