{"id":26419,"library":"sourceror","title":"Sourceror","description":"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.","status":"active","version":"0.8.5","language":"javascript","source_language":"en","source_url":"https://github.com/source-academy/sourceror","tags":["javascript","typescript"],"install":[{"cmd":"npm install sourceror","lang":"bash","label":"npm"},{"cmd":"yarn add sourceror","lang":"bash","label":"yarn"},{"cmd":"pnpm add sourceror","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Provides the runtime and source language definitions for the Source language","package":"js-slang","optional":false}],"imports":[{"note":"Package is ESM-only; CommonJS require will fail.","wrong":"const sourceror = require('sourceror')","symbol":"sourceror","correct":"import sourceror from 'sourceror'"},{"note":"Default export is the compile function.","wrong":null,"symbol":"compile","correct":"import { compile } from 'sourceror'"},{"note":"TypeScript type for Source language variants.","wrong":null,"symbol":"sourceLanguage","correct":"import { sourceLanguage } from 'sourceror'"}],"quickstart":{"code":"import sourceror from 'sourceror';\nimport { parse } from 'js-slang';\n\nconst code = `\nfunction add(x, y) {\n  return x + y;\n}\nadd(1, 2);\n`;\n\nconst ast = parse(code, { language: 'source' });\nconst wasmModule = await sourceror(ast);\nconsole.log(wasmModule); // WebAssembly.Module instance","lang":"typescript","description":"Compiles a simple Source function to a WebAssembly module using the default export."},"warnings":[{"fix":"Run node --experimental-wasm-modules your-script.js","message":"CLI requires Node flag --experimental-wasm-modules","severity":"gotcha","affected_versions":">=0.0"},{"fix":"Use import syntax instead of require()","message":"Package is ESM-only; no CommonJS support","severity":"breaking","affected_versions":">=0.8"},{"fix":"Update to 0.8+ and use the default export as a function","message":"Older versions used a different API (e.g., sourceror as object with compile method)","severity":"deprecated","affected_versions":"<0.8"}],"env_vars":null,"search_vec":"'0.8.5':21 'cadenc':26 'cli':53 'compil':5 'current':17 'differenti':31 'educ':34 'experiment':49 'irregular':28 'javascript':12,55 'js':39 'js-slang':38 'key':30 'moder':24 'modul':51 'node':47 'releas':25 'requir':46 'runtim':41 'ship':42 'slang':40 'sourc':13 'sourceror':1,2 'stabl':18 'subset':10 'target':33 'toolchain':6 'transform':8 'type':44 'typescript':43,56 'updat':29 'usag':54 'use':35 'version':19 'via':36 'wasm':50 'webassembl':15","created_at":"2026-05-01T13:49:52.652601+00:00","updated_at":"2026-05-01T13:49:52.652601+00:00","problems":[{"fix":"Use import instead of require(), or set { \"type\": \"module\" } in package.json","cause":"Using CommonJS require() on an ESM-only package","error":"Error [ERR_REQUIRE_ESM]: require() of ES Module"},{"fix":"Ensure your project is ESM by adding \"type\": \"module\" in package.json","cause":"Mixing module systems in the same project","error":"SyntaxError: The requested module 'sourceror' is expected to be of type CommonJS but is ESM"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"sourceror","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/source-academy/sourceror","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/sourceror","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-05-01","next_check":"2026-07-30","install_tag":null}}