Velareference

CLI

The `vela` command. Lower your sources ahead of `rbxtsc`, with every command, flag and exit code.

vela build lowers your className usage into a second source tree. rbxtsc then compiles that tree, with no transformer plugin.

Terminal window
npx vela build && npx vela rbxtsc -p tsconfig.json

Use the CLI instead of the transformer, not alongside it. Both produce the same output. The CLI fits when your toolchain can’t load a roblox-ts plugin, or when you want the lowered sources as a file you can review.

Your config, the className declaration, your classes and every diagnostic work the same either way.

The command is installed as both vela and vela-rbxts.

Commands

CommandWhat it does
buildTransform the source tree once, then exit
watchTransform once, then again on every change
rbxtsc [args...]Run the project’s rbxtsc, with its errors pointed back at src
remapThe same rewrite, as a filter over rbxtsc output on stdin
sort [paths...]Sort the classes in your sources, or check that they are sorted

vela with no command prints help and exits 0.

Options

Every command takes the same flags. The last two apply to sort only.

Option
-p, --project <dir>Project root. Default: the current directory
--src <dir>Source tree to read, relative to the project root. Default: src
--out <dir>Generated tree to write. Default: .vela/src
--cleanDelete the generated tree before building
-q, --quietHide the header and summary lines
-h, --helpPrint help
-v, --versionPrint the vela-rbxts version
--checksort: list the files that need sorting and exit 1, writing nothing
--class-functions <names>sort: comma-separated helpers whose arguments are class lists, such as cn,cva
  • Value flags take either form: --src ui or --src=ui.
  • For rbxtsc, put Vela’s flags before the command. Everything after rbxtsc goes to roblox-ts: vela --src app rbxtsc -w.
  • --quiet hides only the src -> .vela/src header and the summary line. Warnings and diagnostics always print to stderr. No flag silences them.

--src and --out can’t be the same directory or contain each other, and --out can’t be the project root. Vela rejects these before writing anything:

vela: error: --out must differ from --src: the generated tree would overwrite your sources.

Switching from the transformer

Point rootDir, baseUrl and include at the generated tree, and remove the plugin entry:

tsconfig.json
{
"compilerOptions": {
"rootDir": ".vela/src",
"baseUrl": ".vela/src",
"outDir": "out"
},
"include": [".vela/src"]
}

Build in two steps. Run roblox-ts through vela rbxtsc so its errors name your real files:

Build
npx vela build && npx vela rbxtsc -p tsconfig.json
Watch
npx vela watch & npx vela rbxtsc -w -p tsconfig.json

vela build warns on every run if rootDir still points at src or the plugin is still registered:

vela: warning: tsconfig.json compilerOptions.rootDir is "src" but the generated tree is ".vela/src". Point rootDir and include at ".vela/src" so rbxtsc compiles the lowered sources.
vela: warning: tsconfig.json still registers the "vela-rbxts/transformer" plugin. Remove it — the CLI already lowered these sources.

A leftover plugin only wastes work. It finds nothing left to lower. The check reads only rootDir and plugins from the root tsconfig.json, and it doesn’t check include. If it can’t parse the file, it stays silent. Comments and trailing commas are fine.

What lands in the generated tree

--out mirrors all of --src:

Source fileIn the generated tree
.tsx using classNameTransformed. The output is reprinted, so comments are gone
.tsx with no classNameCopied as written
Everything else (.ts, .d.ts, .lua, .json, assets)Copied byte for byte

Folder structure is kept, so relative imports and baseUrl still resolve. Your vela-env.d.ts is copied too, so className still type-checks inside the generated tree.

Vela keeps its own files in .vela/, outside the mirror, so none of them reach out/:

File
.vela/.gitignoreContains *, so the tree stays out of git. Written on the first run and never overwritten
.vela/build-manifest.jsonWhat the last run wrote. Used for pruning
.vela/maps/<path>.mapA v3 source map per transformed file, such as .vela/maps/client/App.tsx.map. Used by vela rbxtsc and vela remap

Rebuilds and pruning

  • An output that hasn’t changed is never rewritten, so its mtime stays put and rbxtsc -w doesn’t rebuild it.
  • When a source file is deleted, Vela deletes its output and any folder left empty. It only deletes files the manifest says it wrote. Files you added to the tree by hand are left alone.
  • --clean deletes the whole --out folder and resets the manifest, including any files you added.

Diagnostics and exit codes

Diagnostics print to stderr and point at your real files and lines, not the generated tree. Paths are relative to --src, so they have no leading src/:

client/V.tsx:4:27 - warning vela/compiler(unknown-variant): Unknown variant "checked" in "checked:px-4"; supported variants are active, dark, focus, gamepad, hover, landscape, mouse, portrait, touch, the breakpoints sm, md, lg, xl, 2xl and their `max-` forms, `group-*` and `peer-*` over hover, active, focus and the attribute variants, and `attr-[Name=value]`.
2 transformed, 2 copied, 1 warning (167ms)

The summary counts files transformed and copied. It adds removed files, errors and warnings when there are any.

Exit code
0Built. Warnings don’t fail the run
1A file failed to compile, or --src doesn’t exist
2Bad usage: unknown command or option, a flag missing its value, or a --src/--out conflict

A file with an error is not written, and its previous output is deleted. That stops rbxtsc from compiling a stale version. For example, a broken vela.css:

client/App.tsx - error vela/host(compiler-invocation-failed): Failed to parse vela.css:
…/vela.css:3:10 "hotpink" is not a color. Write a hex literal, "rgb(r g b)", or a Color3 expression.
0 transformed, 2 copied, 1 removed, 1 error (4ms)

client/App.tsx stays out of .vela/src until you fix the stylesheet. A missing runtime fails the same way, with runtime-not-installed.

Codes are the same as under the transformer, so the diagnostics reference applies. Only the format differs: vela/compiler(unknown-variant) here, TS89000: [@vela-rbxts/compiler] unknown-variant under roblox-ts.

build

Terminal window
npx vela build [options]

Transforms or copies every file in --src, then deletes outputs whose source is gone.

watch

Terminal window
npx vela watch [options]

Builds once, prints vela watch: waiting for changes..., then rebuilds only what changed. Changes are debounced by 60ms, and each summary is prefixed:

vela watch: 1 transformed, 0 copied (26ms)
ChangeWhat happens
A source file editedThat file is rebuilt
A source file deletedIts output is deleted
vela.config.ts, vela.config.json or vela.css at the project root editedThe whole tree is rebuilt with the new config
A stylesheet that vela.css pulls in with @import editedThe whole tree is rebuilt, even if the file is outside the project

An @import you add while watch runs is picked up from the next rebuild. The transformer has no equivalent; see the vela.css notes.

Watch uses recursive fs.watch. Where the platform doesn’t support it, Vela polls every 400ms instead and says so:

vela: warning: Recursive file watching is unavailable; polling every 400ms instead.

SIGINT and SIGTERM stop watching and exit with the last build’s status.

rbxtsc and remap

roblox-ts only sees the generated tree, so its line numbers don’t match your files. vela rbxtsc fixes that:

npx rbxtsc -p tsconfig.json
.vela/src/client/App.tsx:13:11 - error TS2322: Type 'string' is not assignable to type 'number'.
npx vela rbxtsc -p tsconfig.json
src/client/App.tsx:5:8 - error TS2322: Type 'string' is not assignable to type 'number'.
5 const n: number = "oops";

vela rbxtsc runs your project’s roblox-ts and passes along everything after rbxtsc. It rewrites paths, lines and columns in both output streams back to src, and redraws the code frame from your file. It exits with rbxtsc’s exit code.

To run roblox-ts yourself, pipe its output through vela remap:

Terminal window
npx rbxtsc -p tsconfig.json 2>&1 | npx vela remap

A pipe returns the last command’s exit code. Set pipefail if your build depends on rbxtsc’s.

  • rbxtsc runs in the project root. vela -p game rbxtsc -p tsconfig.json reads game/tsconfig.json and prints paths relative to game.
  • A stale map is ignored. If a file changed since its map was written, or has no map yet, its diagnostics print unchanged rather than pointing at the wrong line.
  • A copied file only gets its path rewritten, and only once its contents match the source.
  • A type error on a lowered prop points at the className it came from.

sort

Terminal window
npx vela sort [paths...] [options]

Sorts the classes in every .tsx file under --src, or under the files and directories you name. The order is the one the editor’s sort action writes, and the nearest vela.config is read the way a build reads it. sort works on your real sources, so it fits a transformer project too.

sorted src/client/App.tsx
vela: sorted 1 file.

In CI or a pre-commit hook, add --check. It prints each unsorted file, writes nothing, and exits 1 if any file needs sorting:

Terminal window
npx vela sort --check
src/client/App.tsx
vela: 1 file needs sorting. Run "vela sort" to fix.

A className and any const string it names are always sorted. To sort the arguments of helpers called outside a className, list them the way the editor’s velaRbxts.classFunctions does:

Terminal window
npx vela sort --class-functions cn,cva

What you give up

  • Your editor and tsc --noEmit see the generated tree, because that’s what rootDir and include name. Type errors, stack traces and go-to-definition land in .vela/src. Only vela rbxtsc and vela remap map errors back. Luau stack traces at runtime still name generated code. The language server reads your real sources, so completions, hover and colors work as usual.
  • It’s a second process to keep running. If vela watch dies, rbxtsc -w keeps compiling the last tree it wrote, with no warning.
  • Installation: the transformer setup, and the TypeScript versions both paths need.
  • Configuration: vela.config.ts, which the CLI reads the same way.
  • Diagnostics: every code either path can report.