Yuku for TSRX

Parse, analyze and print TSRX with the Yuku parser

A TSRX parser, analyzer, and code generator, written in Zig on Yuku and shipped as one WebAssembly module. The tree is ESTree, with the node types of @tsrx/core.

src/Cart.tsrx
export function Cart({ items }): unknown @{
  const count = items.length;
  <ul class="cart">
    @for (const item of items; key item.id) {
      <li>{item.label}</li>
    } @empty {
      <li>Your cart is empty</li>
    }
    @if (count > 0) { <li>{count} in the cart</li> }
    <style>.cart { display: grid; gap: 4px; }</style>
  </ul>
}
a TSRX component, highlighted with the TSRX grammar @tsrx/yuku

The program parse returns, as JSON: ESTree, with TSRX nodes such as JSXCodeBlock, JSXForExpression and JSXStyleElement.

the parser starts when this page loads

Parsing performance

Against the official parser, @tsrx/core, both building an ESTree AST.

Shorter is faster. Median time per file to parse the 1,987 TSRX sources of the test suite, over 3 runs, each in a fresh Node.js 24 process on an Apple M5 Pro.

Maintained by Jack Shelton, on tsrx-org/yuku. Thanks to Arshad Yaseen for his help.

Next: a CSS tree for every <style>, parsed in the same pass by yuku-css, once yuku#280 lands.