Skip to content

@zeus-js/compiler

Rust-native JSX/TSX compiler. The package exposes one transform contract and does not provide a Babel plugin or a second compiler backend.

transformModule

ts
import { transformModule } from '@zeus-js/compiler'

const result = transformModule({
  source: 'const view = <button>{count()}</button>',
  filename: 'view.tsx',
  target: 'dom',
  runtimeModule: '@zeus-js/runtime-dom',
  delegateEvents: true,
  sourceMap: true,
})

The result contains generated JavaScript, an optional Source Map v3, and structured diagnostics. Diagnostics are returned for compiler errors and are not hidden in an exception message.

Options

OptionTypeDescription
sourcestringModule source containing JSX/TSX.
filenamestringStable source filename used by diagnostics and maps.
target'dom' | 'ssr'Select DOM or server code generation.
runtimeModulestringRuntime module imported by generated code.
delegateEventsbooleanEnable delegated event collection for DOM output.
sourceMapbooleanGenerate a Source Map v3.
hmrbooleanInject the development render boundary when supported.

hmr is only meaningful for DOM development transforms. It is ignored for SSR, production, component-only modules, and modules with an explicit import.meta.hot boundary.

Targets

DOM output creates static templates and direct runtime bindings. SSR output serializes the same owned IR and omits event/ref bindings. Host and Slot remain Web Components compiler builtins; unsupported SSR forms return a structured diagnostic.

Native packages

@zeus-js/compiler loads @zeus-js/compiler-native, which selects the platform package for the current Node.js OS, architecture, and libc. A native load failure includes every attempted binary/package error so installation problems are actionable.