Alpha: this compiler is under active development and updates will break your projects. Not recommended for real use yet.
Skip to content

Compiler internals ​

How helix turns author code into files. Each page covers one stage.

Layer Overview (src/core/)User codefrontend/FunctionContextcommands/<cmd>.tsnode + handlerir/Dispatcher, CodegenContextir/lower/per-version renderingcodegen/buildDatapack + passesOutput.mcfunction, JSONctx.say(), ctx.if() …pushes nodeshandlers run byrenders valueslines

buildDatapack(dp) runs everything after the AST and returns Map<path, contents>. dp.writeDatapack(path) writes that map to disk. Nothing before the write touches the disk, which is why the playground can run helix in a browser.

Where the code lives ​

StageFolder (helix/src/core/)
Fluent APIfrontend/
Nodes + handlerscommands/<cmd>.ts, base classes in ir/node.ts
Dispatchir/commandhandler.ts, ir/generate.ts
Valuesvalues/
Per-version renderingir/lower/
Build + passescodegen/
Disk writecodegen/write/

Diagrams of each stage are in helix/diagrams/ (PlantUML).

Diagrams ​

Package stackyour packtwinemodules, areas, lifecyclespoolopt-in pluginshelixcompiler: values, commands, codegenhelix-clihelix build / reportEach layer uses only the public APIof the one below, through its built dist/.
Codegen Flownew Datapack("ns", v26_3)dp.createFunction(name) / dp.public(name)fn.build(ctx => …)each ctx call pushes a nodebuildDatapack(dp)Render every functionnode -> handler -> linesRun passesinline, group, dedupe, infer types, intern readsthrow HelixBuildError(lists all of them)yeserrors?Files in memorydp.writeDatapack(path)

Released under the MIT License · Credits
These docs were written with AI; the layout and every page have been reviewed by a human.