Skip to content

Core Components

The compiler orchestrates through a set of interdependent services. See Architecture Overview for pipeline phases.

graph TB
    subgraph Discovery["Discovery & IR"]
        Program["Program"]
        SourceFiles["SourceFiles"]
        FileProcessor["FileProcessor"]
    end
    
    subgraph Mgmt["IR Management"]
        IRRI["IRRI"]
        Transformers["Transformers"]
    end
    
    subgraph Output["Output"]
        Plugins["Plugins"]
        FileWriter["FileWriter"]
    end
    
    Compiler["Compiler"]
    
    Compiler --> Discovery
    Compiler --> Mgmt
    Compiler --> Output
    FileProcessor --> IRRI
    Transformers --> IRRI
    
    style Compiler fill:#fff3e0,stroke:#f57f17,stroke-width:3px,color:#000
    style Discovery fill:#e3f2fd,stroke:#01579b,color:#000
    style Mgmt fill:#f3e5f5,stroke:#6a1b9a,color:#000
    style Output fill:#e8f5e9,stroke:#33691e,color:#000
ComponentPurpose
ProgramValidate tsconfig.json, glob input files
SourceFilesRegistry for source and generated files
FileProcessorBuild IR for one file
IRRICollect and query all IRefs by kind
TransformersSync AST nodes from IR state
PluginsRun generators and derivatives
FileWriterPreprocess, print, write all files
CompilerOrchestrate pipeline
class Compiler {
async compile(): Promise<Map<string, FileIR>> {
await this.#program.discover()
await this.#sourceFiles.loadSource()
this.#sourceFiles.clearGenerated()
const irs = new Map<string, FileIR>()
for (const sourceFile of this.#sourceFiles.getAll().values()) {
const ir = await this.#fileProcessor.process(sourceFile)
if (ir) irs.set(sourceFile.fileName, ir)
}
await this.#plugins.runGenerators(irs)
await this.#plugins.runDerivatives(irs)
await this.#fileWriter.writeEverything()
return irs
}
}

Program – Discovers and validates input. See Compilation Phases.

SourceFiles – Central registry. See File Management.

FileProcessor – Builds FileIR for one source file, dispatches to transformers.

IRRI – Tracks all IRefs by kind. See IRRI & IRRef.

Transformers – Update AST from IR state. Examples: ComponentTransformer, PropertyTransformer.

Plugins – Listen via handle() method. Generators create global files; derivatives create per-file adapters.

FileWriter – Single pass: preprocess → print → postprocess → write. See Symbol Resolution.

All services use Dependency Injection for singleton pattern and automatic wiring.