Macros (evaluated at build)

Reserved $ functions are evaluated by the compiler and replaced with literals before transpile: inline a file, JSON, an env var, or the build timestamp. Stolen from Bun; a safe pass (lexer + re-parse guard). The values below are frozen into the bundle.

Tip
Macros skip strings, templates and comments (the code block below contains $buildTime() as text — not replaced). If an expansion would break parsing, the file is left untouched. Disable with BEXT_MACROS=0. v1: inlined files aren't tracked for cache invalidation.

Source

src/app/examples/macros/page.tsxTSX
// evaluated at BUILD, inlined as literals:
const BUILD_TIME: string = $buildTime();        // → an ISO string
const BUILD_TS: number = $buildTimestamp();      // → epoch millis
const BUILD_ID: string = $buildId();             // → a per-build id
const NODE_ENV = $env("NODE_ENV");               // → env value or null
const META = $inlineJson("macro-data.json");     // → JSON.parse(<inlined>)

Inlined at build

MacroValue (compiled literal)
$buildTime()2026-09-05T10:27:00Z
$buildTimestamp()1788604020170
$buildId()1a0711b75ca
$env("NODE_ENV")null
$inlineJson("macro-data.json").namebext build-time macros