{"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,"search_vec":"'0.4.6':17 '6':12 'activ':18 'anf':48 'artifact':52 'beta':55 'bitcoin':8 'compil':2,5 'current':53 'develop':19 'diagnost':46 'differenti':21 'dispatch':39 'end':26 'error':43 'export':47 'extens':38 'file':37 'front':25 'front-end':24 'full':51 'ir':49 'javascript':56 'key':20 'languag':27 'like':31 'move':33 'move-styl':32 'multipl':23 'nanopass':14 'never':40 'pass':13 'pipelin':15 'python':35 'refer':4 'return':44 'rúnar':1,3 'script':9 'solid':30 'solidity-lik':29 'style':34 'support':22 'throw':41 'typescript':6,28,57 'version':16 'via':10,36","created_at":"2026-05-01T13:49:31.258760+00:00","updated_at":"2026-05-01T13:49:31.258760+00:00","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,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"runar","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/icellan/runar","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/runar-compiler","openapi_spec":null,"status_page":null,"smithery":null,"categories":["data","serialization"],"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}}