Rust API
compile
Compile source text from parse to generate.
pub async fn compile(
code: String,
options: CompileOptions,
plugins: Vec<SharedPluginable>,
) -> Result<CodeResult, CompileError>Compiles code from source to generated output.
Because the stages run inline, options, start, and end fire exactly once. The builtin parser resolves any requested input source map.
Parameters
| Name | Type | Description |
|---|---|---|
code | String | The source text to compile. |
options | CompileOptions | The compile options. |
plugins | Vec<SharedPluginable> | The plugins to run. |
CompileOptions
Every field is optional and resolved against defaults before use.
| Field | Type | Default | Description |
|---|---|---|---|
cwd | Option<PathBuf> | process working dir | Filesystem root used to resolve relative paths. |
file | Option<String> | index.ts | The file being compiled. The language is inferred from its extension. |
language | Option<Language> | inferred | The grammar of the code. Overrides the extension inference. |
source_type | Option<SourceType> | inferred | The module system of the code. Overrides the grammar's module kind. |
output | Option<OutputOptions> | file | Output code settings. output.file derives the default source-map URL. |
source_map | Option<SourceMapOptions> | off | The source-map inputs and outputs requested for the run. |
Returns
Result<CodeResult, CompileError>, where CodeResult is { code: String, map: Option<SourceMap> }.
Example
use telarel::{compile, CompileOptions, CodeResult};
let result: CodeResult = compile(
String::from("const x: number = 1;"),
CompileOptions::default(),
vec![],
).await?;
println!("{}", result.code); // const x = 1;Last updated on
compile_from_ast
Compile an existing AST through rewrite and generation.
Parser
A builtin parser over fixed source text and options.
Copyright © 2026, Alpheus