vela build lowers your className usage into a second source tree. rbxtsc then compiles that
tree, with no transformer plugin.
npx vela build && npx vela rbxtsc -p tsconfig.jsonUse 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
| Command | What it does |
|---|---|
build | Transform the source tree once, then exit |
watch | Transform once, then again on every change |
rbxtsc [args...] | Run the project’s rbxtsc, with its errors pointed back at src |
remap | The 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 |
--clean | Delete the generated tree before building |
-q, --quiet | Hide the header and summary lines |
-h, --help | Print help |
-v, --version | Print the vela-rbxts version |
--check | sort: 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 uior--src=ui. - For
rbxtsc, put Vela’s flags before the command. Everything afterrbxtscgoes to roblox-ts:vela --src app rbxtsc -w. --quiethides only thesrc -> .vela/srcheader 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:
{ "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:
npx vela build && npx vela rbxtsc -p tsconfig.jsonnpx vela watch & npx vela rbxtsc -w -p tsconfig.jsonvela 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.
It fails on the first file with compiler-invocation-failed (fix). A vela.config.json avoids it, because only a .ts config goes through TypeScript.
What lands in the generated tree
--out mirrors all of --src:
| Source file | In the generated tree |
|---|---|
.tsx using className | Transformed. The output is reprinted, so comments are gone |
.tsx with no className | Copied 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/.gitignore | Contains *, so the tree stays out of git. Written on the first run and never overwritten |
.vela/build-manifest.json | What the last run wrote. Used for pruning |
.vela/maps/<path>.map | A v3 source map per transformed file, such as .vela/maps/client/App.tsx.map. Used by vela rbxtsc and vela remap |
The next build overwrites any edit you make in .vela/src, with no warning.
Rebuilds and pruning
- An output that hasn’t changed is never rewritten, so its mtime stays put and
rbxtsc -wdoesn’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.
--cleandeletes the whole--outfolder 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 | |
|---|---|
0 | Built. Warnings don’t fail the run |
1 | A file failed to compile, or --src doesn’t exist |
2 | Bad 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
npx vela build [options]Transforms or copies every file in --src, then deletes outputs whose source is gone.
watch
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)| Change | What happens |
|---|---|
| A source file edited | That file is rebuilt |
| A source file deleted | Its output is deleted |
vela.config.ts, vela.config.json or vela.css at the project root edited | The whole tree is rebuilt with the new config |
A stylesheet that vela.css pulls in with @import edited | The 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:
.vela/src/client/App.tsx:13:11 - error TS2322: Type 'string' is not assignable to type 'number'.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:
npx rbxtsc -p tsconfig.json 2>&1 | npx vela remapA 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.jsonreadsgame/tsconfig.jsonand prints paths relative togame. - 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
classNameit came from.
sort
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.tsxvela: 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:
npx vela sort --checksrc/client/App.tsxvela: 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:
npx vela sort --class-functions cn,cvaWhat you give up
- Your editor and
tsc --noEmitsee the generated tree, because that’s whatrootDirandincludename. Type errors, stack traces and go-to-definition land in.vela/src. Onlyvela rbxtscandvela remapmap 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 watchdies,rbxtsc -wkeeps compiling the last tree it wrote, with no warning.
Related
- 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.