#1520·ripple

Upgrading to the next @tsrx/core: template text parsing (tsrx-org/tsrx#711), spread-argument markup on the server, and a decoded `JSXText.value` (tsrx-org/tsrx#710)

Author: leonidazCreated Sep 26, 2026Updated Sep 29, 2026

[!WARNING] Don't start this until @tsrx/core 0.5.2 is published on npm, then upgrade straight to it. 0.5.0 and 0.5.1 are published. tsrx-org/tsrx#710 is fixed in tsrx-org/tsrx#972, which is open and ships in 0.5.2, a patch, not a later minor as planned before (updated 2026-09-29).

  • One change: do "What Ripple needs to change" and "Decoded template text value in 0.5.2" below together with the bump to ^0.5.2. A ^0.5.0 or ^0.5.1 range picks up 0.5.2 on any lockfile refresh, and against 0.5.2 Ripple's decoder decodes text twice. Removing the decoder against 0.5.1 breaks 2 tests, so it can't go first either.
  • A bug today, not tied to a release: #1517 can be fixed now.

Issue Category

Other

Bug Description

Ripple's catalog pins @tsrx/core at ^0.3.3, which doesn't pick up a new minor. 0.4.0 was published on 2026-09-25. The next release is tsrx main with its pending changesets, plus tsrx-org/tsrx#711 if that merges before the release. It will be 0.5.0, a minor, because it changes the language (tsrx-org/tsrx#732). This issue lists what the upgrade changes for @tsrx/ripple, what breaks, and what Ripple needs to change. It also covers tsrx-org/tsrx#710, a parser change in 0.5.2 that breaks Ripple silently.

In short:

  • Tests. With the next core, 4 tests fail. All 4 assert class-map pruning, which 0.4.0 removed, and #1516 already covers them. Nothing else fails with tsrx main or with #711.
  • SSR (breaking). An element in a component's spread argument (<Child {...{ label: <b>x</b> }} />) compiled on 0.3.3 and 0.4.0. With the next core, the server build throws Not implemented: JSXElement. Ripple needs a one-line fix in three places.
  • tsrx-org/tsrx#711 (not breaking). It restores text that Ripple dropped or rejected, and Ripple needs no change for it. Without #711, the next release would silently drop the text before a > in <Child label=<b>a > b</b> />, which 0.4.0 renders correctly.
  • TS view (existing bug, #1519). Ripple's TypeScript view prints template text that Ripple decoded itself, so >, <, &gt; and &#123;x&#125; reach TypeScript bare (TS1382) or as an expression. #711 fixes this only in core's printer, which Ripple doesn't use. The fix is small, and it needs #711's core.
  • Spread children (#1518). Since 0.4.0, {...items} parses and is reported as unsupported. Ripple's TS view doesn't handle it: it adds syntax errors, and a spread alone in a fragment makes compile_to_volar_mappings throw.
  • tsrx-org/tsrx#710 (0.5.2, silent break). Once template text's value is decoded, Ripple decodes it a second time: &amp;lt; renders < instead of &lt;. No Ripple test catches it. Ripple's decoding has to be removed in the same change that bumps to 0.5.2.
Change Release Effect on Ripple
Assigned <style> blocks keep every selector (tsrx-org/tsrx#251) 0.4.0, published 4 tests fail, tracked in #1516
JSX spread children parse and are reported as unsupported (tsrx-org/tsrx#495) 0.4.0, published TS view syntax errors, and a throw for <>{...items}</> (#1518)
Elements in spread arguments and unbraced attribute values are template markup (tsrx-org/tsrx#713) next SSR throws for a spread argument; comments there are comments
Template text whitespace after closing tags, in setup statements and in containers next {n} items in a setup statement renders 3 items instead of 3items; TS view text keeps line breaks
'}' expected. for a missing }, and fixes for hangs and crashes next Error messages change; <div title=<b>a /* c */ b</b> /> no longer runs out of memory
A > in text in a {…} container is text; template text raw leaves out comments; the core printer escapes <, >, {, } (tsrx-org/tsrx#711) next, if merged Fixes dropped text; no Ripple change needed
Template text value is decoded, raw is as written (tsrx-org/tsrx#710, fixed in tsrx-org/tsrx#972) 0.5.2 Double decoding unless Ripple drops its decoder

What changes in the AST and parser

1. A > in template text inside a {…} container is text (tsrx-org/tsrx#711, fixing tsrx-org/tsrx#694). On 0.4.0 and main, the parser read a > right after a tag in a container as code and dropped the text before it. After a child container, it rejected the >.

tsrx
export function App() @{
	const c = true;
	<main>{c && <b>a > b</b>}</main>
}

Ripple's client output for the <b>:

javascript
// 0.4.0 and main: renders "> b"
var root_1 = _$_.template_el('b', null, '> b');

// with #711: renders "a > b"
var root_1 = _$_.template_el('b', null, 'a > b');

With a child container before the text ({c && <b>{y} a > b</b>}), 0.4.0 and main fail with Unexpected token `>`. Did you mean `&gt;` or `{">"}`? (4:22). With #711 it compiles, and the text run is " a > b". The same holds in @if bodies inside containers, nested containers, fragments, ternaries, and .map arrows. For an element that is an attribute value without braces, it's a regression that #711 fixes:

tsrx
export function App() @{
	<Child label=<b>a > b</b> />
}
Core Ripple renders the label as
0.3.3, 0.4.0 a > b
main > b
#711 a > b

2. Template text's raw leaves out comments (tsrx-org/tsrx#711). In a template, a // or /* … */ comment between an element's children is a comment, not text (TSRX spec, 4.3), so <p>a /* c */ b</p> renders a b: a and b are the <p>'s text. In plain TSX the same JSX would render a /* c */ b. That text's value is a b before and after. raw was a /* c */ b (the source slice) and is now a b. A line comment on its own line between children is left out the same way. Ripple reads only value, so its output doesn't change. The TS-view fix below depends on this.

3. Elements in a spread argument or an unbraced attribute value are template markup (tsrx-org/tsrx#713, fixing tsrx-org/tsrx#656). <Child {...{ label: <b>…</b> }} /> and <Child label=<b>…</b> /> used to be plain JSX, read by acorn-typescript's JSX parser. Now they are template elements, like the element in label={<b>…</b>}:

  • They carry metadata.native_tsrx and metadata.templateMode: 'template'.
  • A comment in them is a comment, not text.
  • @if, @for, @switch, @try and @{ … } in them are directives.
  • Their text is template text, which isn't decoded yet. It used to be acorn's decoded text.

On the server, the spread form now throws (see Breaking changes). On the client, output is unchanged except for text. &nbsp; in a spread argument's element used to render as a non-breaking space, and it now renders as the literal &nbsp;, because Ripple's own decoder handles only five named references (see #710 below). &amp;lt; used to render <, and it now renders &lt;, which is correct.

<div title=<b>a /* c */ b</b> /> runs out of memory in the parser on 0.3.3 and 0.4.0 (tsrx-org/tsrx#695). On main it parses, and the comment is left out.

4. Template text whitespace. Several pending changesets make template text follow JSX's whitespace rules: parser-jsx-text-whitespace, parser-setup-statement-text and parser-template-text-containers.

  • Text in an element inside a setup statement or a container keeps its leading spaces:

    tsrx
    export function App() @{
        const n = 3;
        const label = <span>{n} items</span>;
        <p>{label}</p>
    }
    javascript
    // 0.4.0: renders "3items"
    var __a = String(__prev._a ?? '') + "items";
    
    // next: renders "3 items"
    var __a = String(__prev._a ?? '') + " items";
  • The text after a closing tag now starts at the tag, so its value includes the line break and indentation after the tag. For JSX targets this fixes <span> … </span> 2 rendering 12. In Ripple it still renders 12: get_template_text_value trims both ends of any text that holds a line break with String.prototype.trim(), which also drops the leading space. Only Ripple's TS view changes. There, the text in 4 of Ripple's own files gains its line break: packages/ripple/tests/client/tsx.test.tsrx, templates/basic/src/App.tsrx, website-new/src/components/actions.tsrx and website-new/src/components/docs-layout.tsrx.

5. Error messages. A missing } reports '}' expected. as TypeScript does, instead of Unexpected token, at the same position. An @if/@for/@try body still open at the end of the input is now an error instead of being accepted. 4 compile-error sources in Ripple's tests get the new message, and no Ripple test asserts it. Many other parser changes (TypeScript forms, collect/loose mode errors, comment attachment) change no Ripple output in the comparison below.

6. Assigned <style> blocks keep every selector (tsrx-org/tsrx#251, in 0.4.0). Tracked in #1516.

Breaking changes and the Ripple code they affect

A. Class-map pruning tests (tsrx-org/tsrx#251, 0.4.0). See #1516. These are the only test failures.

B. SSR of an element in a spread argument (tsrx-org/tsrx#713, next).

tsrx
function Child(props) @{
	<div>{props.label}</div>
}

export function App() @{
	<Child {...{ label: <b>x</b> }} />
}
Core compile(source, 'App.tsrx', { mode: 'server' })
0.3.3, 0.4.0 compiles, and the label renders <b>x</b>
main, #711 throws Not implemented: JSXElement (consider using 'esrap/languages/tsx')

The client build is unchanged. The server transform visits a component's attribute value with template_child: false (server/index.js#L2519-L2531). Its comment says why: without it, template JSX in the value leaks to the printer. The spread argument is visited without it (#L2553-L2561). The element used to be plain JSX, which JSXElement lowers in a value position. Now it's a template element, and it takes the template-child path.

A host element has the same gap in both places: #L2305-L2308 for an attribute value and #L2324-L2327 for a spread. <div title={<b>x</b>} /> already threw on 0.3.3. With the next core, the unbraced and spread forms throw too.

Test failures

Every run is pnpm exec vitest run --maxWorkers=4 from the root: all 12 projects and 181 files.

@tsrx/core Passed Failed Skipped
0.3.3 (pinned) 2376 0 12
tsrx main (f73b6760) 2372 4 12
tsrx-org/tsrx#711 (c71ebf37) 2372 4 12
#711 with #710's decoding simulated 2372 4 12

The same 4 fail each time, all from #1516:

  • |ripple-client| packages/ripple/tests/client/css/scoped-styles.test.tsrx > $class and apply > keeps every selector of a theme and only class selectors of a plain class map
  • |ripple-client| packages/ripple/tests/client/css/style-identifier.test.tsrx > style class maps > compiler output > prunes style expression selectors the class map cannot reach in client mode
  • |ripple-client| packages/ripple/tests/client/css/style-identifier.test.tsrx > style class maps > compiler output > prunes style expression selectors the class map cannot reach in server mode
  • |ripple-server| packages/ripple/tests/server/style-identifier.test.tsrx > style class maps (server) > server compiler output > prunes style expression selectors the class map cannot reach

No test covers the SSR spread case, the > cases, or double decoding.

Reproduction Steps

On Ripple main at 83ed56159, @tsrx/core was pointed at a tsrx checkout with a pnpm override in pnpm-workspace.yaml, not committed. After it, pnpm install --no-frozen-lockfile --ignore-scripts was run.

yaml
overrides:
  esrap: ^2.3.2
  '@tsrx/core': link:../tsrx-upgrade-711/packages/tsrx
  semver: ^7.7.4

The test suite ran against each core in the table above. On top of that, 2,191 distinct sources were compiled with @tsrx/ripple against 0.3.3, 0.4.0, main and #711, in client mode, server mode, and compile_to_volar_mappings. The outputs were compared and syntax-checked: acorn for the JavaScript, and TypeScript's TSX parser for the TS view.

  • 229 tracked Ripple .tsrx files and 467 source literals from Ripple's tests.
  • 59 tsrx .tsrx files and 989 source literals from tsrx's tests.
  • 447 generated sources: 19 texts (a >, =>, <3, character references, comments, @if > x) in 20 template places (containers, control-flow bodies, attribute values, spread arguments, setup statements, a dynamic tag name), plus functions, the module level, and <script> bodies.

Results for #711 against main:

  • Ripple's own files and literals. No output changes in any mode.
  • Generated sources. 73 client, 49 server and 73 TS-view outputs change, all texts with a > in a container or in an attribute-value element, as in item 1. 7 client and TS-view outputs, and 6 server outputs, compile where main threw. None go from compiling to failing, and no output gains a syntax error.

What Ripple needs to change

With the next release:

  1. Bump @tsrx/core in the catalog (pnpm-workspace.yaml), its minimumReleaseAgeExclude entry, and the lockfile.

  2. Adopt #1516: the 4 tests and the docs on class-map pruning.

  3. Fix the SSR spread argument. Visit spread arguments and host attribute values with template_child: false, as component attribute values already are. Add an SSR test for <Child {...{ label: <b>x</b> }} />.

    diff
    --- a/packages/tsrx-ripple/src/transform/server/index.js
    +++ b/packages/tsrx-ripple/src/transform/server/index.js
    @@ -2304,7 +2304,7 @@
                             const metadata = { tracking: false };
                             const expression = /** @type {AST.Expression} */ (
    -                            visit(attr_value, { ...state, metadata })
    +                            visit(attr_value, { ...state, template_child: false, metadata })
                             );
    @@ -2323,7 +2323,9 @@
                     } else if (attr.type === 'JSXSpreadAttribute') {
                         spread_attributes?.push(
    -                        b.spread(/** @type {AST.Expression} */ (visit(attr.argument, state))),
    +                        b.spread(
    +                            /** @type {AST.Expression} */ (visit(attr.argument, { ...state, template_child: false })),
    +                        ),
                         );
    @@ -2554,7 +2556,7 @@
                         props.push(
                             b.spread(
                                 /** @type {AST.Expression} */ (
    -                                visit(attr.argument, { ...state, metadata: { ...state.metadata } })
    +                                visit(attr.argument, { ...state, template_child: false, metadata: { ...state.metadata } })
                                 ),
                             ),
                         );

    With this, every generated element in a braced, unbraced, or spread attribute value compiles on the server (76 of 76), and the component-prop output matches 0.3.3's. With steps 3 and 4 applied against #711's core, the suite still fails only #1516's 4 tests.

  4. Print the TS view's text as written (#1519). Ripple's TS view prints template text that Ripple decoded, so >, <, &gt; and &#123;x&#125; reach TypeScript bare or as an expression. That's an existing bug on every core version, and #711 fixes it only in core's printer. #1519 has the fix: keep the text as written on the node and escape <, >, { and } in the TS-view printer. It needs #711's raw, which leaves out comments, so it belongs with this upgrade. Checked against #711's core, it removes the TS-view syntax errors from 260 of 269 sources, and it doesn't change client output, server output, or the suite.

  5. Keep spread children in the TS view (#1518). Since 0.4.0 (tsrx-org/tsrx#495), <div>{...items}</div> parses and is reported as unsupported, for every target. Ripple's TS view wraps the spread child in an IIFE, which adds four TSX syntax errors. <>{...items}</> makes compile_to_volar_mappings throw No source map entry for position "2:3". On the pinned 0.3.3 it's a parse error, so this shows up with the upgrade. #1518 has a checked fix.

  6. Optional: tests for a > in container text ({c && <b>a > b</b>}, {c && <b>{y} a > b</b>}) and in an unbraced attribute value, so a regression like the one on tsrx main shows up.

Decoded template text value in 0.5.2 (tsrx-org/tsrx#710)

tsrx-org/tsrx#710 decides that JSXText follows the JSX AST standard: value has its character references decoded, and raw is the text as written, without comments (#711 already did the raw half). tsrx-org/tsrx#972 implements it, and it ships in @tsrx/core 0.5.2. It decodes the way the simulation below did, with acorn-typescript's jsx_readEntity, and value also reads each CRLF line break as LF. Core's own whitespace rules now read raw, so a reference such as &nbsp; or &#10; at the edge of multi-line text is text there.

Where Ripple reads text. Everything goes through get_template_text_value. It trims text that holds a line break, then decodes it with its own decode_jsx_text_entities, which knows &amp;, &quot;, &apos;, &lt;, &gt;, and numeric references. Its result is the rendered string:

  • get_template_expression turns it into a string literal. The client passes that to _$_.template_el, whose runtime inserts it with createTextNode, or HTML-escapes it into a _$_.template string.
  • The server JSXText visitor escapes it into the HTML output.
  • The analyzer's JSXText visitor uses it to drop whitespace.
  • The TS view prints it decoded, which is #1519.
  • The client's JSXText visitor reads node.value without decoding. No Ripple or generated source in the comparison reaches it in a client build.

So value goes into both string literals and HTML templates, always as the rendered text. That is the right model for a decoded value, but Ripple would then decode it a second time.

Measured. The core's parser was patched to decode template text's value the way acorn-typescript's jsx_readEntity does, with its 253-entry XHTML table, and keep raw as written. Against #711:

  • Double decoding. &amp;lt; renders < instead of &lt;. The same happens to &amp;gt;, &amp;amp;, &amp;quot;, &amp;apos;, &amp;#123; and the other escaped references, in all 22 places in the comparison where the text is template text. Without #1519's fix, the TS view also prints a bare < for &amp;lt; (22