07 — Compiler Architecture

Emit Phase


The Emit phase converts the validated, transformed AST into output artifacts. Built-in emitters produce CSS Custom Properties, Style Dictionary JSON, TypeScript type declarations, and Figma Variables. Custom emitters are supported via the plugin interface. The Emit phase receives a fully resolved AST — all token chains are resolved to concrete values, all composition graphs are validated, all state machines are verified.

Built-in Emitters

EmitterOutputPrimary Use
cssCSS Custom Properties, CSS @layer blocksWeb platform — browser environments.
style-dictionaryStyle Dictionary JSONCross-platform distribution — consumed by native emitters.
typescriptTypeScript type declarations for token names and component propsType-safe consumption in TS/JS codebases.
figmaFigma REST API-conformant Variables and Styles JSONDesign tool synchronisation (one-directional).

Emitter Contract

Each built-in emitter defines a contract: the set of AST node types it consumes, the output format it produces, and the platform constraints that govern value translation. Emitters MUST NOT modify the AST — they receive a read-only view. Emitters that encounter AST nodes they do not recognise MUST skip them and log a warning, not abort. This ensures forward compatibility as the AST schema evolves.

Emit Phase and Plugin Emitters

Plugin emitters register against a specific AST node type or set of node types. When the Emit phase processes those node types, it invokes registered plugin emitters in addition to built-in emitters. Plugin emitters receive the same read-only AST view as built-in emitters. Multiple emitters may produce output from the same AST nodes; their outputs are independent.