{"id":26348,"library":"runar-compiler","title":"Rúnar Compiler","description":"Rúnar reference compiler (TypeScript to Bitcoin Script) via a 6-pass nanopass pipeline. Version 0.4.6, actively developed. Key differentiators: supports multiple front-end languages (TypeScript, Solidity-like, Move-style, Python) via file extension dispatch; never throws, all errors returned as diagnostics; exports ANF IR and full artifact. Currently in beta.","status":"active","version":"0.4.6","language":"javascript","source_language":"en","source_url":"https://github.com/icellan/runar","tags":["javascript","typescript"],"install":[{"cmd":"npm install runar-compiler","lang":"bash","label":"npm"},{"cmd":"yarn add runar-compiler","lang":"bash","label":"yarn"},{"cmd":"pnpm add runar-compiler","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Runtime types and standard library imported by compiled contracts (e.g., SmartContract, assert)","package":"runar-lang","optional":true}],"imports":[{"note":"Package is ESM-only; CommonJS require() will fail.","wrong":"const compile = require('runar-compiler')","symbol":"compile","correct":"import { compile } from 'runar-compiler'"},{"note":"CompileResult is an interface; use type import for type-only usage. In runtime it's a plain object, not a class.","wrong":"import { CompileResult } from 'runar-compiler'","symbol":"CompileResult","correct":"import type { CompileResult } from 'runar-compiler'"},{"note":"Interface only, no runtime value.","wrong":null,"symbol":"CompileOptions","correct":"import type { CompileOptions } from 'runar-compiler'"},{"note":"Type-only export; cannot be required.","wrong":"const CompilerDiagnostic = require('runar-compiler').CompilerDiagnostic","symbol":"CompilerDiagnostic","correct":"import type { CompilerDiagnostic } from 'runar-compiler'"},{"note":"Type alias, not a runtime enum.","wrong":null,"symbol":"Severity","correct":"import type { Severity } from 'runar-compiler'"}],"quickstart":{"code":"import { compile } from 'runar-compiler';\n\nconst source = `\nimport { SmartContract, assert, PubKey, Sig, hash160, checkSig } from 'runar-lang';\n\nexport class P2PKH extends SmartContract {\n  readonly pubKeyHash: ByteString;\n\n  constructor(pubKeyHash: ByteString) {\n    super(pubKeyHash);\n    this.pubKeyHash = pubKeyHash;\n  }\n\n  public unlock(sig: Sig, pubKey: PubKey) {\n    assert(hash160(pubKey) === this.pubKeyHash);\n    assert(checkSig(sig, pubKey));\n  }\n}\n`;\n\nconst result = compile(source, { fileName: 'P2PKH.runar.ts' });\n\nconsole.log(result.success);\nconsole.log(result.scriptHex);\nconsole.log(result.scriptAsm);","lang":"typescript","description":"Compiles a P2PKH smart contract from TypeScript-like source to Bitcoin Script using the runar-compiler."},"warnings":[{"fix":"Use import syntax or dynamic import().","message":"Package is ESM-only; no CommonJS support. require() on the package will throw ERR_REQUIRE_ESM.","severity":"breaking","affected_versions":">=0.1.0"},{"fix":"Ensure fileName matches the source language extension, e.g., 'contract.runar.ts' for TypeScript, 'contract.runar.sol' for Solidity-like.","message":"The fileName option must include the correct extension to select the parser (e.g., .runar.ts, .runar.sol). Wrong extension leads to parse errors.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Always check result.success and inspect result.diagnostics for errors.","message":"compile() never throws; all errors are returned as diagnostics in the CompileResult. Silently assuming success === true is dangerous.","severity":"gotcha","affected_versions":">=0.1.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Rename file to end with .runar.ts, or pass fileName option with correct extension.","cause":"Source code is parsed as JavaScript without .runar.ts extension; export keyword not supported in older Node.js","error":"SyntaxError: Unexpected token 'export'"},{"fix":"Use import syntax (ESM) or dynamic import: const compile = (await import('runar-compiler')).compile;","cause":"Attempting to require() the ESM-only package from a CommonJS module","error":"ERR_REQUIRE_ESM"},{"fix":"Use import type { CompileResult } from 'runar-compiler'; it is an interface, not a class.","cause":"Importing CompileResult as a value instead of a type","error":"TypeError: CompileResult is not a constructor"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}