Registry / devops / sourceror

sourceror

JSON →
library0.8.5jsnpmunverified

Sourceror is a compiler toolchain that transforms a subset of JavaScript (Source) into WebAssembly. The current stable version is 0.8.5, with a moderate release cadence of irregular updates. Key differentiators: it targets educational use via the js-slang runtime, ships TypeScript types, and requires Node's experimental WASM modules for CLI usage.

npm install sourceror
INSTALL
IMPORT
SIG · SOURCEROR
S
sourceror
devopsjavascriptv0.8.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.

sourceror
import sourceror from 'sourceror'
const sourceror = require('sourceror')
Package is ESM-only; CommonJS require will fail.
compile
import { compile } from 'sourceror'
Default export is the compile function.
sourceLanguage
import { sourceLanguage } from 'sourceror'
TypeScript type for Source language variants.

Compiles a simple Source function to a WebAssembly module using the default export.

import sourceror from 'sourceror'; import { parse } from 'js-slang'; const code = ` function add(x, y) { return x + y; } add(1, 2); `; const ast = parse(code, { language: 'source' }); const wasmModule = await sourceror(ast); console.log(wasmModule); // WebAssembly.Module instance
sourceror --version
Debug
Known issues
gotchaCLI requires Node flag --experimental-wasm-modules
fix
Run node --experimental-wasm-modules your-script.js
affects: >=0.0
breakingPackage is ESM-only; no CommonJS support
fix
Use import syntax instead of require()
affects: >=0.8
deprecatedOlder versions used a different API (e.g., sourceror as object with compile method)
fix
Update to 0.8+ and use the default export as a function
affects: <0.8
Errors
Common errors & fixes
Error [ERR_REQUIRE_ESM]: require() of ES Module
Using CommonJS require() on an ESM-only package
fix
Use import instead of require(), or set { "type": "module" } in package.json
SyntaxError: The requested module 'sourceror' is expected to be of type CommonJS but is ESM
Mixing module systems in the same project
fix
Ensure your project is ESM by adding "type": "module" in package.json
Upgrade
Version history
0.8.5latest on npm
Audit
Dependencies
js-slangrequiredProvides the runtime and source language definitions for the Source language
Agent activity
2 hits · last 30 days
node
2
Resources
sourceror — npm install sourceror · libregistry