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
| Emitter | Output | Primary Use |
|---|---|---|
| css | CSS Custom Properties, CSS @layer blocks | Web platform — browser environments. |
| style-dictionary | Style Dictionary JSON | Cross-platform distribution — consumed by native emitters. |
| typescript | TypeScript type declarations for token names and component props | Type-safe consumption in TS/JS codebases. |
| figma | Figma REST API-conformant Variables and Styles JSON | Design 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.