API Reference
Key exports and types from @constela/compiler
Key Exports
| Export | Description |
|---|---|
compile | Main compilation function |
CompileOptions | Configuration options for compilation |
CompileResult | Result containing generated code |
transform | AST transformation utilities |
compile
The main compilation function:
typescript
function compile(program: Program, options?: CompileOptions): CompileResult;CompileOptions
| Option | Type | Default | Description |
|---|---|---|---|
target | "esm" | "cjs" | "iife" | "esm" | Output module format |
minify | boolean | false | Minify the output |
sourcemap | boolean | false | Generate source maps |
CompileResult
typescript
interface CompileResult {
ok: boolean;
code?: string;
program?: CompiledProgram;
errors?: CompileError[];
warnings?: CompileWarning[];
sourcemap?: string;
}CompileWarning
Warnings are non-blocking issues detected during compilation, such as accessibility violations:
typescript
interface CompileWarning {
code: string;
message: string;
path: string;
}| Field | Type | Description |
|---|---|---|
code | string | Warning code (e.g., "A11Y_IMG_NO_ALT") |
message | string | Human-readable description of the issue |
path | string | JSON path to the offending node (e.g., "/view/children/0") |
See Error Codes for the full list of warning codes.