#1525·ripple

[Bug]: Render template comments like {/* */} and read // like JavaScript, for the next @tsrx/core

Author: leonidazCreated Sep 27, 2026Updated Sep 27, 2026
Labelsbug

[!NOTE] The tree changes further in the same release (tsrx-org/tsrx#869, 2026-09-27): the parser keeps whitespace-only text and gives every comment between children an empty {} of its own, even with nothing rendering around it. Where this issue says a comment with nothing rendering on one side gets no {}, or that whitespace with a line break is left out, #869 replaces that; the rendering rules here are unchanged. What that means here is in #1526; do both together.

[!WARNING] Don't start until the @tsrx/core release that includes tsrx-org/tsrx#858 is published (0.5.0). The plan this issue described before, joining text nodes around comments, was dropped: see "What changes" below.

Issue Category

Other (preparing for the next @tsrx/core)

Bug Description

The next @tsrx/core changes how comments between template children render and how // is read. It delivers both through the parse tree, so Ripple gets them from parseModule with no parser change of its own.

What changes in @tsrx/core

Two rules for comments between template children change (tsrx-org/tsrx#858). They replace the plan in tsrx-org/tsrx#841 to join the text around comments.

1. A comment between children renders like {/* … */} in TSX. The text on each side of it follows JSX's whitespace rules on its own. Before, a comment was invisible, and the text on both sides was joined first. The pages that change are the ones where TSX's own {/* */} behavior shows:

tsrx
<p>
  a
  // c
  b
</p>

This used to render a b, and now renders ab, as TSX does around {// c}.

tsrx
<div>
  <b>t</b>
  /* c */ <i />
</div>

This used to render nothing between <b> and <i>, and now renders a space, as TSX does for {/* c */} <i />.

2. // reads like JavaScript's. A // starts a line comment where whitespace comes right before it, at the start of a line, or right after a tag, an expression container (}), or a block. It runs to the end of the line, a closing tag on it included. A // that touches other text stays text: https://…, a//b, /* a */// b.

Source Now Before
a // c, then a line break comment text
<p> a //comment </p> comment to the end of the line, then an unclosed-tag error for <p> text
https://x.dev, a//b text text

How core delivers it: the parse tree. parseModule gives text with comments the children TSX has for {/* … */}:

tsrx
<p>a /* c */ b</p>
children of <p>
before JSXText "a b" (the comment cut out of it and attached to it)
now JSXText "a ", {}, JSXText " b"
  • The {} is a JSXExpressionContainer whose expression is a JSXEmptyExpression. It spans the comments between the two pieces; there are no braces in the source. The comments are the JSXEmptyExpression's innerComments, as in TSX.
  • Each piece is exactly its source (value and raw).
  • A piece that is whitespace with a line break renders nothing and is left out, as such text is anywhere. So a comment with nothing rendering on one side gets no {}, and attaches to a child next to it as before: <p> + a line break + // c + a line break + <b /> has the one child <b />.
  • The exception is a tooling comment (// @ts-expect-error, /* @ts-ignore */, /** @ts-expect-error */, or any // comment starting with @). It always gets a {} of its own, and the text around it keeps its line breaks (children "⏎ ", {}, "⏎ ", <b />), so that a TypeScript view can write it as {/* @ts-expect-error */} on the line before the child. The whitespace pieces render nothing under JSX's rules.

analyzeTsrx doesn't change these children.

What Ripple needs to do

  • Render an empty {} child as nothing, and never merge text across it. The text pieces on each side follow JSX's whitespace rules on their own. These places read template text, at 83ed5615:

    Any step that combines adjacent text children (a single-text shortcut, a static template string) must treat the {} as a boundary. Whitespace-only text with a line break (around a tooling comment) must render nothing, as JSX's rules say.

  • Anything that reads comments from text (a comment attached to a JSXText) now finds them in the {}'s JSXEmptyExpression.innerComments, or on a neighbouring child.

  • In the TS view, write a tooling comment of a JSXEmptyExpression inside its braces, as {/* @ts-expect-error */}, so the directive reaches TypeScript as it does in core's TSX (core's tsx_with_ts_locations does this).

  • Update the tests and fixtures that pinned the old rendering (a + // c + b rendering a b).

Reproduction Steps

After upgrading:

tsrx
<p>
  a
  // c
  b
</p>

This renders ab, and <div><b>t</b> + a line break + /* c */ <i /></div> renders a space between <b> and <i>, as the same TSX with {/* c */} does.

Environment

  • Ripple main at 83ed5615, @tsrx/core 0.3.x

Additional Context

  • tsrx-org/tsrx#858: the change, with the rendering check.
  • tsrx-org/tsrx#841: the earlier plan, superseded for the rendering.
  • Octane and @tsrx/oxc are tracked in octanejs/octane#1338 and tsrx-org/oxc#118.

Checklist

  • I've searched for existing issues