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
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
fixRename 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
fixUse 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
fixUse import type { CompileResult } from 'runar-compiler'; it is an interface, not a class. Audit
Dependencies
runar-langoptionalRuntime types and standard library imported by compiled contracts (e.g., SmartContract, assert)