Registry / data / runar-compiler

runar-compiler

JSON →
library0.4.6jsnpmunverified

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.

npm install runar-compiler
INSTALL
IMPORT
SIG · RUNAR-COMPILER
R
runar-compiler
datajavascriptv0.4.6
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.

compile
import { compile } from 'runar-compiler'
const compile = require('runar-compiler')
Package is ESM-only; CommonJS require() will fail.
CompileResult
import type { CompileResult } from 'runar-compiler'
import { CompileResult } from 'runar-compiler'
CompileResult is an interface; use type import for type-only usage. In runtime it's a plain object, not a class.
CompileOptions
import type { CompileOptions } from 'runar-compiler'
Interface only, no runtime value.
CompilerDiagnostic
import type { CompilerDiagnostic } from 'runar-compiler'
const CompilerDiagnostic = require('runar-compiler').CompilerDiagnostic
Type-only export; cannot be required.
Severity
import type { Severity } from 'runar-compiler'
Type alias, not a runtime enum.

Compiles a P2PKH smart contract from TypeScript-like source to Bitcoin Script using the runar-compiler.

import { compile } from 'runar-compiler'; const source = ` import { SmartContract, assert, PubKey, Sig, hash160, checkSig } from 'runar-lang'; export class P2PKH extends SmartContract { readonly pubKeyHash: ByteString; constructor(pubKeyHash: ByteString) { super(pubKeyHash); this.pubKeyHash = pubKeyHash; } public unlock(sig: Sig, pubKey: PubKey) { assert(hash160(pubKey) === this.pubKeyHash); assert(checkSig(sig, pubKey)); } } `; const result = compile(source, { fileName: 'P2PKH.runar.ts' }); console.log(result.success); console.log(result.scriptHex); console.log(result.scriptAsm);
runar --version
Debug
Known issues
breakingPackage is ESM-only; no CommonJS support. require() on the package will throw ERR_REQUIRE_ESM.
fix
Use import syntax or dynamic import().
affects: >=0.1.0
gotchaThe fileName option must include the correct extension to select the parser (e.g., .runar.ts, .runar.sol). Wrong extension leads to parse errors.
fix
Ensure fileName matches the source language extension, e.g., 'contract.runar.ts' for TypeScript, 'contract.runar.sol' for Solidity-like.
affects: >=0.1.0
gotchacompile() never throws; all errors are returned as diagnostics in the CompileResult. Silently assuming success === true is dangerous.
fix
Always check result.success and inspect result.diagnostics for errors.
affects: >=0.1.0
Errors
Common errors & fixes
SyntaxError: Unexpected token 'export'
Source code is parsed as JavaScript without .runar.ts extension; export keyword not supported in older Node.js
fix
Rename file to end with .runar.ts, or pass fileName option with correct extension.
ERR_REQUIRE_ESM
Attempting to require() the ESM-only package from a CommonJS module
fix
Use import syntax (ESM) or dynamic import: const compile = (await import('runar-compiler')).compile;
TypeError: CompileResult is not a constructor
Importing CompileResult as a value instead of a type
fix
Use import type { CompileResult } from 'runar-compiler'; it is an interface, not a class.
Upgrade
Version history
0.4.6latest on npm
Audit
Dependencies
runar-langoptionalRuntime types and standard library imported by compiled contracts (e.g., SmartContract, assert)
Agent activity
7 hits · last 30 days
node
6
OpenAI (training)
1
Resources
runar-compiler — npm install runar-compiler · libregistry