@sqlrooms/mosaic / astToESM
Function: astToESM()
astToESM(
ast,options?):string
Generate ESM code for a Mosaic spec AST.
Parameters
| Parameter | Type | Description |
|---|---|---|
ast | SpecNode | Mosaic AST root node. |
options? | { baseURL?: string; connector?: string; namespace?: string; depth?: number; imports?: Map<string, string | string[]>; preamble?: string | string[]; } | Code generation options. |
options.baseURL? | string | The base URL for loading data files. |
options.connector? | string | A database connector to initialize. Valid values are 'wasm', 'socket', and 'rest'. If undefined, no connector code is generated. |
options.namespace? | string | The vgplot API namespace object. |
options.depth? | number | The starting indentation depth. |
options.imports? | Map<string, string | string[]> | A Map of ESM imports to include in generated code. Keys are packages (e.g., '@uwdata/vgplot') and values indicate what to import (e.g., '* as vg'). |
options.preamble? | string | string[] | Code to include after imports. |
Returns
string
Generated ESM code using the vgplot API.
