Skip to content

fix(solid, vue): report a yield in a template as TSRX2034 - #1280

Merged
jonkwheeler merged 29 commits into
tsrx-org:mainfrom
jonkwheeler:fix/solid-vue-yield-in-jsx
Nov 12, 2026
Merged

jonkwheeler merged 29 commits into
tsrx-org:mainfrom
jonkwheeler:fix/solid-vue-yield-in-jsx

Conversation

@jonkwheeler

@jonkwheeler jonkwheeler commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Summary

On Solid and Vue, a yield in a template value that the target's own JSX compiler moves into an effect, a getter or a callback is now a TSRX compile error, TSRX2034. It's reported at the authored yield, in strict, collect and editor mode:

export function* field(bag: { title: string }) {
	return <input title={yield bag.title} />;
	//                   ^^^^^^^^^^^^^^^ TSRX2034
}
Solid TSRX does not support `yield` in this part of the template: Solid's JSX compiler evaluates it in an effect, a getter or a callback, which cannot yield from the enclosing generator. Yield the value before the template, as in `const value = yield …;`, and use `value` in it.

Vue gets the same message with its own name. Before, TSRX compiled these without an error and the build failed later in babel-preset-solid or vue-jsx-vapor output, pointing at compiled code. A yield those compilers leave in place still compiles, so everything that builds today still builds. Real Vite builds (@tsrx/vite-plugin-solid + vite-plugin-solid, @tsrx/vite-plugin-vue):

Source Solid on main → this PR Vue on main → this PR
title={yield bag.title} [builtin:vite-transform] A 'yield' expression is only allowed in a generator body. → TSRX2034 the same parse error → TSRX2034
title={yield* bag.titles()} [PARSE_ERROR] The keyword 'yield' is reserved → TSRX2034 the same parse error → TSRX2034
onClick={yield h} ref={yield r} title={yield t} builds → builds parse error → TSRX2034
{...(yield attrs)} on a host element parse error → TSRX2034 builds → builds
const title = yield bag.title; return <input title={title} />; builds → builds builds → builds

Exempt positions, and why. These build today because the compiler evaluates the value in place, in the generator:

  • Solid, following babel-preset-solid's JSX compiler (dom-expressions):
    • A static value, with no member access, call, spread or in (the compiler's own test), in an attribute, a component prop, or a lone component child. A static value is assigned in place; a dynamic one goes in an effect or a getter.
    • Any event handler (onClick, on:click) on an element without a spread, and a ref that isn't an array. These are wired in place. Not exempt: a [handler, data] array on an event the compiler doesn't delegate (onScroll, on:click), which becomes e => handler(data, e), so both are reported. A delegated event (onClick) keeps both in place. Any later element is dropped.
    • A key of a class or style object whose value is static. The compiler splits such an object into one setting per key (and a ['static', { … }] class array the same way) and sets each in place unless its value is dynamic. An object it can't split (a computed key, or a key with a space or colon) is set whole, in an effect, unless babel can evaluate it. A class object with a method or accessor is split and also kept whole, in an effect, so its keys are reported.
    • Beside a host spread, any attribute but ref that isn't dynamic, class and event handlers included. The compiler passes them as props of the spread: a static one in place, a dynamic one in a getter (reported).
    • A value the compiler folds into a literal before it checks it, as in title={{ a: yield t, b: 'x'.length }}, and a yield it drops with the fold, as in title={false && (yield bag.x)}; an attribute that a later one of the same name replaces; the children of a void element or a <noscript>, which the compiler doesn't write; a <textarea>'s children when a literal value or defaultValue (or a bare value) replaces them; a children attribute on an element or component with children (or an element that writes none) and an element's first $key, which it drops; a tagged template inside a value, which the compiler counts as dynamic only as the whole value; and className, a plain attribute to it.
    • Elements nested in the returned or assigned one, which are created in the function's own code from one template. Any other host element is created in an immediately called arrow, so a yield anywhere in it is reported, except in what the compiler drops from it (as above).
    • A static @if test or @for iterable, which become <Show when> and <For each> props. [Bug]: Host spread plus ref moves yield outside its generator and fails Vite compilation #246's spread-plus-ref shape, t ? <input {...{}} ref={() => {}} title={yield 'title'} /> : null, builds for the same reason: its value is static.
    • A component ref that can't be assigned, such as ref={yield r}. The compiler drops it, so the yield never runs, but it builds. An assignable one, ref={(yield t).field}, is applied in a callback and reported.
    • Not exempt: a <select>'s value, which the compiler also assigns in a microtask, so <select value={yield t} /> is reported.
  • Vue: vue-jsx-vapor creates every element in an immediately called arrow, so any yield in an element or fragment is reported, event handlers and refs included. The exception is a host spread, which TSRX evaluates into a variable before the element. Vue spread attributes on components are reported.
  • Both: a yield in a nested generator function, in the setup statements of the function's own @{ … } body, or before the template.

React, Preact and Hono (server and DOM) evaluate templates eagerly. They don't implement the hook, and their output and diagnostics are byte-identical to main.

Fix.

  • Core runs a new findDeferredTemplateYields hook on the final output, the code the target's compiler reads, after the generated closures are suspended. It then reports what the hook returns as TSRX_ERRORS.TARGET_TEMPLATE_YIELD_UNSUPPORTED(target), in source order.
  • A yield* that delegates to a generator made from a generated closure ([Bug]: Host spread plus ref moves yield outside its generator and fails Vite compilation #246) now carries that generator in metadata.generated_delegation. It stands for the authored yields inside it.
  • A yield that already has an error at or inside it (TSRX2022, TSRX2023) gets no second one, so each mistake has one error.
  • @tsrx/solid and @tsrx/vue implement the hook in src/template-yield.js, following the rules above.
  • After review (79505d0 to 9ccc050), on Solid: the spread, <select>, class/style, className, duplicate-attribute, dropped-children, $key and event-array rules above, and the compiler's constant folding for host attribute values and children. The rule reads only literals for folding: templates, members of string and number literals, unary operators, short circuits, sequences, and arrays and objects of them. It adds no evaluator for bindings, arithmetic or calls.
  • TSRX2034 goes in DIAGNOSTIC_CODES, TSRX_ERRORS, the specification's code list, and @tsrx/content-mapper's error examples (a Solid source, shown once through TypeScript 7).

Verification

  • Real compilers. A corpus of 4009 shapes per target, which I ran through TSRX, then babel-preset-solid or vue-jsx-vapor's compiler, then a strict module parse. It covers 12 contexts × 20 positions × 16 value kinds, 9 TSRX directive and code-block shapes × 16 value kinds, and 25 others. The others include several yields, yield yield, nested generators, @switch in an expression, @try/@pending, [Bug]: Host spread plus ref moves yield outside its generator and fails Vite compilation #246's shapes, spreads, super, dynamic tags and <style> siblings. On both targets TSRX2034 appears exactly when the compiled output fails to parse: 0 false positives and 0 false negatives. The 19 shapes skipped per target are those with another error first (TSRX2022, TSRX2023), which keep main's single error.

  • New tests.

    • packages/tsrx-solid/tests/template-yield.test.js: 15 reported shapes and 13 exempt ones.
    • packages/tsrx-vue/tests/template-yield.test.js: 12 reported shapes and the host spread.
    • Each reported shape must give one TSRX2034 per yield, in source order, through collect and compile_to_volar_mappings, and strict mode must throw at the first. Each exempt shape must compile with no error.
    • Against main, the 27 reported-shape tests fail. Against this PR's first commit (one rule for every position), the 14 exempt-shape tests fail.
  • Version guard. packages/vite-plugin-solid/tests/template-yield-downstream.test.js (128 probes) and packages/vite-plugin-vue/tests/template-yield-downstream.test.js (17 probes) compile reported and exempt shapes that cover each rule branch. Each probe goes through TSRX, then the installed babel-preset-solid (with the options and parser plugins vite-plugin-solid passes) or vue-jsx-vapor's compiler, then Vite's TypeScript strip. Each asserts TSRX2034 exactly when the result fails a strict module parse. A compiler release that compiles a probe differently fails CI. Making on* handlers deferred in the Solid rule fails both handler probes. The rules record the versions they follow: @dom-expressions/babel-plugin-jsx 0.50.0-next.44 (babel-preset-solid 2.0.0-rc.2, vite-plugin-solid 3.0.0-next.5) and vue-jsx-vapor 3.2.14. Both files run in about a second, in the existing vite-plugin-solid and vite-plugin-vue projects, with no lockfile change.

  • Runtime, in the Vite pipeline. packages/vite-plugin-solid/tests/template-yield.runtime.test.tsrx builds and runs exempt shapes through tsrxSolid() + vite-plugin-solid: host title, class object, onClick and ref together; a static component prop and child; a static @if test; [Bug]: Host spread plus ref moves yield outside its generator and fails Vite compilation #246's shape; a value yielded first. packages/vite-plugin-vue/tests/template-yield.runtime.test.tsrx does the same for Vue's host spread and a value yielded first. Each test drives the generator and checks the rendered DOM.

  • The shared tests keep the accepting shapes on React, Preact and Hono. On Solid and Vue they skip only [Bug]: Host spread plus ref moves yield outside its generator and fails Vite compilation #246's no-error check (rejectsTemplateYield harness option).

  • Matrix: 40 shapes × 6 targets × strict, collect and editor. React, Preact, Hono and Hono DOM are byte-identical to main (160 of 160).

  • After review, checked against the DOM build. On a18c04a the first four were reported although the DOM output builds them, and the last two weren't although it fails:

    Source (in a generator) a18c04a Now DOM output
    <div {...bag} class={yield t} /> TSRX2034 no error builds
    <div title={{ a: yield t, b: 'x'.length }} /> TSRX2034 no error builds
    <div title={(yield t) + tag`x`} /> TSRX2034 no error builds
    <input title={false && (yield bag.x)} /> TSRX2034 no error builds
    <button {...bag} onClick={yield bag.onClick} /> no error TSRX2034 fails
    <select value={yield t} /> no error TSRX2034 fails

    Three Codex passes then found more of the same kind in class and style objects, className, sequences, evaluated values and duplicate attributes, e.g. class={{ active: yield t, big: bag.big }} (reported, builds) and class={{ [k]: yield t }} (not reported, fails). Those are fixed too.

    A re-review of 0740ad7 found four more against the DOM build, fixed in ff38e4c to 75935a6; three Codex passes then found more of the same kind (void and <noscript> children, later event-array elements, elements created in an arrow, a component's shadowed children, $key), fixed in 8b4cacc to 9ccc050:

    Source (in a generator) 0740ad7 Now DOM output
    <textarea value="x">{yield bag.t}</textarea> TSRX2034 no error builds (the literal replaces the children)
    <div children={yield bag.t}>x</div> TSRX2034 no error builds (the attribute is dropped)
    <div class={{ a: yield t, b() { return 1; } }} /> no error TSRX2034 fails
    <div onScroll={[bag.h, yield t]} /> no error TSRX2034 fails

    | t ? <input>{yield bag.t}</input> : null | TSRX2034 | no error | builds (no children written) |
    | <Comp children={yield bag.t}>x</Comp> | TSRX2034 | no error | builds (the prop is dropped) |
    | <div onScroll={[bag.h, yield t, ...bag.e]} /> | no error | TSRX2034 | fails |

    Over 8685 shapes (this corpus, 4128 spread, textContent, stateful-property and folding shapes from fix(solid): follow Solid's SSR output for TSRX2034 in a server build #1302, and 572 single probes, both re-reviews' and every Codex pass's included; 24 with another error first, and 6 that babel throws on whatever the yield, are left out), 72 are newly reported against a18c04a and the DOM build fails every one; 161 are no longer reported and the DOM build builds every one. Against the DOM build: the corpus stays at 0/0; the 4128 shapes go from 40 false positives and 35 false negatives to 0/0; the probes from 130/37 to 9/0 (65/19 on 0740ad7). Against 0740ad7, 19 are newly reported (the DOM build fails each) and 56 no longer are (it builds each).

    • Tests: packages/tsrx-solid/tests/template-yield.test.js now has 23 reported and 42 exempt shapes (15 and 13 on a18c04a), and the Solid downstream test 165 probes (57).
    • Mutations, with the new tests kept: reverting template-yield.js to a18c04a fails 94 of the two files' 230 tests, and to 0740ad7 50. Each of 16 targeted mutations of the follow-up fails at least one: keeping a textarea's replaced children 9, void children 8, <noscript> children 6; keeping a children attribute beside children 3 or where none are written 5, a component's shadowed children 4, $key 4; reporting an element created in an arrow whole 11, or not as moved 12; ignoring a kept class object 5 (methods only, no accessors, 1); not splitting event arrays 12, ignoring delegation 2, keeping later elements 5, moving a lone element 1, giving up on any hole or spread 5. Earlier, each of 17 targeted mutations failed at least one: the spread rule 7, the <select> rule 3, splitting class/style 12, dropping evaluated class keys 3, className 3, sequences 6, dropping folded yields 9, folding an object's values 3, the nested tagged template 4, reading literals at all 22, duplicates 2 and 1 (by renamed name), and five smaller ones 1 to 3 each.
    • Codex (gpt-5.6-sol, read-only) reviewed 79505d0 through 930cec1 in three passes, then 2732619 and d291591 on their own, then 0740ad7..6a35169, 8b4cacc, bf62582, and finally 0740ad7..9ccc050 as a whole. Each pass's findings are fixed in the commit after it; the last pass ran over 2,000 shapes through the same compile, DOM build and parse and found no mismatch. See Known gaps for what's left.
  • Cursor Bugbot, on 0740ad7, said a computed class or style key that babel folds is still reported. It doesn't reproduce: class={{ [(yield t, 'x'.length)]: true }} is dynamic to dom-expressions too (the key has a member access, and only values are folded), so the DOM build fails and TSRX2034 is right; [(yield t, 'a')] builds and isn't reported. Five such shapes agree with the DOM build. Rechecked on 9ccc050 with 76 class and style key shapes, returned and created in an arrow: TSRX2034 appears exactly when the DOM build fails, with hydratable off and on.

  • Cursor Bugbot, on 9ccc050, said the children skip counts JSX whitespace. It isn't a bug: dom-expressions makes the same check on the raw children, whitespace included (hasChildren = path.node.children.length > 0 in transformAttributes and transformComponent), and drops the attribute. 21 shapes give TSRX2034 exactly when the DOM build fails, on this PR and on fix(solid): follow Solid's SSR output for TSRX2034 in a server build #1302. They cover host and component, a newline, CRLF, space, comment or nothing inside, and returned or created in an arrow.

  • npx vitest run: 182 files, 10335 passed, 88 skipped. pnpm typecheck, prettier --check and pnpm changeset:check are clean. Against the open fork PRs that touch its files, the follow-up adds one conflict, with fix(solid): follow Solid's SSR output for TSRX2034 in a server build #1302, which is stacked on this PR and takes the merge. The PR as a whole conflicts with 11 open fork PRs, as it did on 0740ad7: nine add a diagnostic code beside TSRX2034 in diagnostics.js and the specification's list, refactor(core): read generic arrows by TypeScript's TSX rule (#183) #1124 touches source-mappings.js and fix(core): run generated closures in the enclosing function's context #1120 the JSX transform (Support native TSRX components in Storybook #1082's branch isn't on the fork).

Known gaps (follow the DOM build)

  • return (<input title={yield b} />) as any; fails Solid's DOM build without TSRX2034. vite-plugin-solid runs babel on the TypeScript as written, so dom-expressions sees the as wrapper, doesn't treat the element as the returned one, and creates it in an immediately called arrow. The rule looks through TypeScript wrappers there.
  • <input {...b} title={yield 1} /> builds for the DOM but fails Solid's SSR build (generate: 'ssr'), because the rule follows the DOM output. fix(solid): follow Solid's SSR output for TSRX2034 in a server build #1302 adds a check for server builds.
  • The rule follows the compiler's folding only through literals. A fold through a binding or a call isn't followed, so title={Math.max(1, 2) || (yield t)} is still reported though the DOM output builds it (7 probes, including title={1 > 2 && bag[yield t]} and a module-level const off = false guard).
  • The compiler drops xmlns from a template's top-level <svg> or <math> (or SVG or MathML element), so t ? <svg xmlns={yield t} /> : null builds but is reported (2 probes, found by Codex).
  • A children attribute before a dynamic textContent, as in <div children={yield bag.t} textContent={bag.x} />, is dropped by the DOM output (the textContent takes its place, though innerHTML or a later children doesn't), so it builds but is reported (found by Codex on fix(solid): follow Solid's SSR output for TSRX2034 in a server build #1302, after 9ccc050).
  • The namespace-import exception reads names, not bindings, so a parameter or local that shadows an imported namespace counts as one, which can miss a yield (found by Codex).
  • In the exempt shapes the yields run in the order the compiled code evaluates them, not the order written. For <button title={yield 'title'} onClick={yield 'onClick'} ref={yield 'ref'} /> that order is ref, onClick, then title. The runtime tests answer each yield by its key for that reason.

Related

Fixes #259
Related: #246, #887

🤖 Generated with Claude Code

https://claude.ai/code/session_01FRKmwAwuyPbGQ1ejNqiJ46


Note

Medium Risk
Large compile-time AST analysis tied to external JSX compiler behavior; misclassification could add false errors or miss broken yields, but it does not change runtime auth or data handling.

Overview
Adds TSRX2034 so Solid and Vue fail at compile time when yield appears in template spots their JSX compilers relocate into effects, getters, or callbacks—instead of breaking later in babel-preset-solid or vue-jsx-vapor.

The core JSX pipeline runs a new findDeferredTemplateYields hook on the final program (after closure suspension) and reports matches via report_deferred_template_yields. yield* on generated closures records metadata.generated_delegation so inner authored yields map back correctly. Vue host spreads that yield are no longer bound in place (yields_in_deferred_spread).

@tsrx/solid ships a large template-yield.js that mirrors dom-expressions rules (dynamic vs static attrs, class/style splitting, event arrays, folding, dropped children/attrs). @tsrx/vue uses a smaller rule set (any yield inside JSX except spreads TSRX hoists first). Tests, downstream compiler probes, runtime checks, the spec, and a changeset accompany the change; React/Preact/Hono are unchanged.

Reviewed by Cursor Bugbot for commit db3c425. Bugbot is set up for automated code reviews on this repo. Configure here.

babel-preset-solid and vue-jsx-vapor move template expressions into
reactive effect callbacks. A `yield` there no longer runs in its
generator, so the build failed later with `A 'yield' expression is only
allowed in a generator body.` (or, for `yield*`, `The keyword 'yield' is
reserved`), pointing at compiled code.

Solid and Vue now set `validation.templateYieldUnsupported`, and core
reports each `yield` in a template as TSRX2034
(TARGET_TEMPLATE_YIELD_UNSUPPORTED) at the authored `yield`, in source
order: attribute values, children, spread values, component props,
directive heads and bodies, including `yield*`. A `yield` in a nested
function, or in the setup statements of a function's own `@{ … }` body,
stays allowed.

A reported `yield` is recorded so the shared checks for a `yield` in a
generated callback (TSRX2022) and for the `super` such a callback can't
read (TSRX2023) don't report it a second time. React, Preact and Hono
evaluate templates eagerly and don't set the flag.

The error gets a Solid example in `@tsrx/content-mapper`'s error
examples, and a line in the specification's code list.

Fixes tsrx-org#259

Co-Authored-By: Claude Opus 5.5 <[email protected]>
jonkwheeler and others added 2 commits October 29, 2026 11:16
…es the yield

The previous commit reported every `yield` in a Solid or Vue template.
Some of them build today, because the target's JSX compiler leaves the
value in place, so the check now mirrors each compiler on TSRX's final
output, which is what that compiler reads.

Core runs the target's new `findDeferredTemplateYields` hook after the
generated closures are suspended, and reports what it returns. A
`yield*` that delegates to a generator made from a generated closure
now carries that generator in `metadata.generated_delegation`, and
stands for the authored `yield`s inside it. A `yield` that already has
an error at or inside it (TSRX2022, TSRX2023) gets no second one. The
source-level walk, the `templateYieldUnsupported` flag and the
`rejected_yields` set are gone.

- Solid (`template-yield.js`) follows babel-preset-solid's JSX compiler.
  An element returned or assigned as a whole, and the elements nested in
  it, are created in place; any other host element is created in an
  immediately called arrow. A dynamic value is evaluated in an effect,
  an inserted arrow or a prop getter, and a static one in place, using
  the compiler's own test (a member access, call, spread or `in`).
  `class` and `style` are always in an effect unless the value is an
  object literal. An array `ref` goes in an arrow; event handlers and
  other refs stay in place. An assignable component `ref` goes in a
  callback, and other component refs are passed on or dropped.
  Component children are passed in a getter when there are several, or
  one is an element or dynamic.
- Vue (`template-yield.js`) reports any `yield` in an element or
  fragment. vue-jsx-vapor creates every element in an immediately called
  arrow, but a host spread TSRX evaluates into a variable before the
  element stays allowed.

Checked against babel-preset-solid and vue-jsx-vapor on 4009 shapes per
target (contexts, positions, value kinds and TSRX directives): TSRX2034
appears exactly when the compiled output fails to parse. Exempt shapes
build and run in the Solid and Vue Vite runtime tests.

Related: tsrx-org#259

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The previous commit skipped tsrx-org#246's whole shared block on Solid and Vue.
Only its check that the shapes compile without errors depends on the
target, since those targets report some of them as TSRX2034. The
mapping check and the `@for` body check still apply there. Keeping
the block's `describe` line as it was also lets this merge cleanly
with tsrx-org#1220's tests next to it.

Related: tsrx-org#259

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@cursor cursor Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

The Solid rule mirrors dom-expressions' choices about which template
values it evaluates in place, and consumers get whatever compiler
their vite-plugin-solid brings. Two probe tests now run reported and
exempt shapes through TSRX, then the installed babel-preset-solid (as
vite-plugin-solid calls it) or vue-jsx-vapor, then Vite's TypeScript
strip. They assert that TSRX2034 appears exactly when the result fails
a strict module parse. The probes cover each branch of the rules: 43
for Solid and 17 for Vue. A compiler release that diverges now fails
CI instead of giving a false error.

The rules record the compiler versions they follow:
@dom-expressions/babel-plugin-jsx 0.50.0-next.44 (babel-preset-solid
2.0.0-rc.2) and vue-jsx-vapor 3.2.14.

Related: tsrx-org#259

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@jonkwheeler
jonkwheeler marked this pull request as ready for review October 29, 2026 16:42
…lid does

vite-plugin-solid hands babel the TypeScript as written, so
dom-expressions sees `as`, `satisfies` and `!` as ordinary expressions.
The Solid rule looked through them. As a result, it left out a returned
or declared element behind one (`return (<input title={yield t} />) as
any`), which the compiler creates in an immediately called arrow, and a
class or style object behind one, which goes in an effect. Both failed
the DOM build with no TSRX2034. The rule now looks through parentheses
only. The exceptions are where the compiler strips a wrapper itself: `as`
and `!` on a host ref, and `satisfies` too on a component ref.

A component whose `ref` is a call is created inside an immediately
called arrow, so every value on it is now deferred too. An optional
member ref, which the compiler drops, is left alone.

New guard probes: the TypeScript-wrapped elements and objects, the
component ref forms, and the Bugbot shapes (an assigned element, `open`,
`one` and a fragment inside the returned element). 6 of them fail on the
previous head.

Related: tsrx-org#259

Co-Authored-By: Claude Opus 5.5 <[email protected]>
jonkwheeler and others added 9 commits November 10, 2026 07:17
…ded values

Four false reports and two misses in tsrx-org#1280's DOM rule, each checked
against the installed babel-preset-solid's DOM output:

- Beside a host spread, every attribute but `ref` is a prop of the
  spread: a dynamic one in a getter, any other in place. So
  `<div {...bag} class={yield t} />` builds and is no longer reported,
  and `<button {...bag} onClick={yield bag.onClick} />` fails and is.
- A `<select>`'s value, unless it's a literal, is assigned in a
  microtask as well as in place, so `<select value={yield t} />` is
  reported.
- The compiler folds a host attribute value, or a value in an object
  there, into a literal when it evaluates to a string, number or
  boolean, and a host child into text when it evaluates to a string or
  number. `title={{ a: yield t, b: 'x'.length }}` is static after that,
  and the `yield` in `title={false && (yield bag.x)}` is dropped. The
  rule reads only literals for this: templates, members of string and
  number literals, unary operators and short circuits on them.
- dom-expressions counts a tagged template as dynamic only as the whole
  value, so `title={(yield t) + tag`x`}` builds and is no longer
  reported.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codex found more false reports in the DOM rule's class and style
handling, each checked against the installed babel-preset-solid:

- dom-expressions splits a `class` object, and a `['static', { … }]`
  array, into one attribute per key, drops a key whose value it can
  evaluate, and sets each remaining key in an effect only if its value
  is dynamic. So `class={{ active: yield t, big: bag.big }}` builds.
  A computed key, or one with a space or colon, keeps the object
  whole, set in an effect, which the rule missed.
- It inlines a `style` key whose value is a string or number, drops a
  `null` or `undefined` one, and splits off the rest the same way; a
  computed key or a spread keeps the object whole.
- `className` is a plain attribute to it, set in an effect only when
  dynamic.
- babel evaluates a sequence to its last value, so
  `title={(yield bag.x, 'a')}` folds into a literal.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…does

A second Codex pass found false reports where dom-expressions sets a
`class` or `style` value in place because babel can evaluate it:
`class={null && (yield t)}`, a computed key like
`[(yield t, 'active')]`, and a class key holding an array it
evaluates. A whole `class` or `style` value, or what stays in a style
object, is now set in an effect only when it is dynamic or can't be
evaluated, and literal values cover arrays and objects. An object's
nested values are checked as part of the object, so a tagged template
inside one isn't dynamic.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRKmwAwuyPbGQ1ejNqiJ46
A value that folds into a literal keeps no `yield`, since
`collect_folded_yields` drops them, so only an object's values need
folding in the dynamic test. Turning the check off failed no test.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRKmwAwuyPbGQ1ejNqiJ46
A third Codex pass found two more false reports: without a spread,
dom-expressions keeps only the last attribute of a name (but every
`ref`), so a `yield` in an earlier one is dropped; and babel evaluates
`typeof` a function or class to `'function'` without running it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRKmwAwuyPbGQ1ejNqiJ46
dom-expressions renames a stateful property set to something other than
a literal (`value`, `checked`, …) to `prop:…` before it drops duplicate
attributes, so `<input value={yield bag.value} value="kept" />` keeps
both and moves the `yield` into an effect. The previous commit dropped
the first one and missed it (found by Codex).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRKmwAwuyPbGQ1ejNqiJ46
A fifth Codex pass found edge cases in the stateful-property names: the
compiler looks the tag up in upper case, doesn't count a RegExp or
BigInt as a literal, and folds a textarea's literal value into its
content, which removes that attribute before duplicates are dropped.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRKmwAwuyPbGQ1ejNqiJ46

@cursor cursor Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

jonkwheeler added a commit to jonkwheeler/tsrx that referenced this pull request Nov 10, 2026
tsrx-org#1280's DOM rule now follows dom-expressions for spreads, `<select>`
values, `class` and `style` objects, duplicate attributes and literal
folding. In the shared visitor a server build adds the SSR rule on top:
a value the SSR output moves is visited whole, so it skips the DOM
output's `class`/`style` split. The SSR attribute rule reads the same
folding, with elements counting as dynamic, and a server build's folder
drops more folded `yield`s. Helpers both sides added (`DOM_WITH_STATE`,
`FOLDED_TYPES`, `collect_folded_yields`, `find_yields`,
`host_tag_name`) are kept once, with the stateful-property table looked
up by the tag in upper case as the compiler does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRKmwAwuyPbGQ1ejNqiJ46
jonkwheeler added a commit to jonkwheeler/tsrx that referenced this pull request Nov 10, 2026
…y scope

As decided in review, the SSR rule no longer copies babel's `evaluate`:
`read`, `evaluate`, `evaluate_quasis`, `call` and `BINARY_OPERATORS`
are gone, and the folder's `evaluate` is tsrx-org#1280's `literal_value`, which
reads only literals. A value the literals can't decide but that may
fold drops its `yield`s in a server build, and a `textContent` value
that may fold isn't grouped, which fixes the falsy-`textContent` false
report (`<p textContent={false} />` beside one with a `yield`).

`may_fold` now resolves a name where it's read, through a table of the
module's declarations by scope, so a parameter or loop variable of the
same name in another function no longer makes a call or constant look
unfoldable (both false reports). A literal left side or test decides a
short circuit or conditional.

Three probes that pinned the evaluator's reports are dropped: a
constant like `{1 + 1}` between grouped values, and a `var` in a
nested block. Those are misses now.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRKmwAwuyPbGQ1ejNqiJ46
jonkwheeler added a commit to jonkwheeler/tsrx that referenced this pull request Nov 10, 2026
jonkwheeler and others added 5 commits November 10, 2026 09:32
Two false reports from the re-review, each checked against the DOM
build: a textarea's literal `value` or `defaultValue` (or a bare
`value`) replaces its children, so `<textarea value="x">{yield bag.t}</textarea>`
builds; and without a spread, a `children` attribute is dropped when
the element has children of its own, so
`<div children={yield bag.t}>x</div>` builds too.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRKmwAwuyPbGQ1ejNqiJ46
dom-expressions never writes children for a void element, so a
`children` attribute there is dropped too:
`<input children={yield bag.t} />` builds.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRKmwAwuyPbGQ1ejNqiJ46
Two misses from the re-review, each checked against the DOM build:

- A `class` object with a method or accessor keeps the whole object,
  which dom-expressions sets in an effect beside the split keys, so
  `class={{ a: yield t, b() { return 1; } }}` fails to build.
- On an event it doesn't delegate (`onScroll`, `on:click`), a
  `[handler, data]` array becomes `e => handler(data, e)`, so both
  elements move into a new listener; a third element is dropped.
  Delegated events keep both in place.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRKmwAwuyPbGQ1ejNqiJ46
jonkwheeler and others added 3 commits November 10, 2026 09:53
From a Codex pass on 0740ad7..6a35169, each checked against the
DOM build:

- dom-expressions writes no children for a void element or a
  `<noscript>`, so `<input>{yield bag.t}</input>` builds.
- A `[handler, data]` array on an event it doesn't delegate keeps only
  the first two elements whatever follows, so
  `onScroll={[bag.h, yield t, ...bag.e]}` fails; a spread for the data
  is passed as is. A hole or a spread handler, or a hole for the data,
  makes the compiler throw, so those stay unreported.

The changeset now names `defaultValue` and a bare `value` too.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRKmwAwuyPbGQ1ejNqiJ46
From a second Codex pass, on 8b4cacc, each checked against the DOM
build:

- A host element the compiler creates in an immediately called arrow
  (a ternary arm, a fragment, a dynamic child) was reported whole, so
  what it drops was reported too: `t ? <input>{yield bag.t}</input> : null`
  builds. It's now walked like an inline element, with everything it
  keeps moved.
- A `children` attribute is also dropped on a `<noscript>` and beside a
  textarea's literal value, which writes its own children.

The exempt-shape test title now says the DOM output leaves the `yield`
in place or drops it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRKmwAwuyPbGQ1ejNqiJ46
From a third Codex pass, on bf62582, each checked against the DOM
build:

- The compiler keeps only the first two elements of an event array on
  a delegated event too, so `t ? <button onClick={[h, d, yield x]} /> : null`
  builds.
- A component's `children` prop is dropped when the component has
  children: `<Comp children={yield bag.t}>x</Comp>` builds.
- The DOM output removes an element's first `$key`:
  `<div $key={yield bag.k} />` builds.

A top-level `<svg xmlns={yield …}>` is left as a known gap.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRKmwAwuyPbGQ1ejNqiJ46

@cursor cursor Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

jonkwheeler added a commit to jonkwheeler/tsrx that referenced this pull request Nov 10, 2026
Conflicts in template-yield.js: the attribute parts now come from
split_class_or_style or split_event_handler, still skipped when the
SSR output moves the whole value; the SSR spread-children branch stays
ahead of tsrx-org#1280's child loop, which skips what the DOM output drops.
tsrx-org#1280's VOID_ELEMENTS replaces this branch's copy.

Six server-build probes from tsrx-org#1280's follow-up fail here (a
`<noscript>`'s children and `$key`, which the SSR output renders);
the next commit fixes them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRKmwAwuyPbGQ1ejNqiJ46
jonkwheeler added a commit to jonkwheeler/tsrx that referenced this pull request Nov 10, 2026
With `ssr: true`, the server check counts a value babel might fold
through a binding as folded and drops its `yield`s. That also dropped
`yield`s the DOM output moves, so a server build missed what a client
build reports, though both builds fail:
`const on = true; … <input title={on && (yield bag.t)} />`.

A server build now checks the DOM output on its own, as a client build
does, and adds what the SSR check finds; the maybe-folded drop applies
only to the SSR check. Since the DOM check covers the arrow the DOM
output creates some elements in, the SSR check no longer counts it,
and it follows the SSR output where that differs from the DOM's: a
`<noscript>`'s children and `$key` are rendered, not dropped.

The downstream server probes now also check that every `yield` a
client build reports is reported. `<div {...bag} title={Math.max(1, 2) || (yield t)} />`
is reported in both builds now, tsrx-org#1280's literal-fold gap, so it leaves
the server probes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRKmwAwuyPbGQ1ejNqiJ46
jonkwheeler and others added 4 commits November 12, 2026 10:14
Main added TSRX2028, TSRX2029 and TSRX2031, so TSRX2034 follows them in diagnostics.js and the spec's code list. In suspend_generated_closures, the yield* delegation keeps this branch's generated_delegation metadata and passes main's new get_arguments_name to delegate_to_generated_generator.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRKmwAwuyPbGQ1ejNqiJ46
… now defers

Since main's tsrx-org#1232, Solid TSRX compiles a host element's className to class, which babel-preset-solid sets in an effect. Since tsrx-org#1107, it wraps a host spread in a normalize_spread_props call, so in a ternary arm (tsrx-org#246's shape) the compiler creates the element in an immediately called arrow. A yield in either place now leaves its generator, so TSRX2034 is right there. The downstream probes against the installed babel-preset-solid already agree.

Move both shapes to the reported list. The runtime test keeps a yield beside a host spread and a ref, on the returned element, which the compiler still evaluates in place.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRKmwAwuyPbGQ1ejNqiJ46
main now has the first merged PRs; merged against the old main so git doesn't redo that work.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRKmwAwuyPbGQ1ejNqiJ46
Main's tsrx-org#1108 binds Vue host spreads in place, as `{...(X = normalize(expr))}`, so vue-jsx-vapor's render effect reads the bag again when it changes. A `yield` in that bag would then run inside the effect, outside its generator, so TSRX2034 reported it and the runtime test's yielding spread stopped compiling.

A generator yields a value once, so an effect could never read a yielded bag again anyway. On a target that reports deferred template yields, a host spread whose bag yields keeps its setup declaration, evaluated before the element where the generator runs it, as every Vue spread was before tsrx-org#1108. Every other spread, including one beside it, is still bound in place, and React, Preact and Hono are unchanged. A new Vue test pins both forms.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRKmwAwuyPbGQ1ejNqiJ46

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

There are 2 total unresolved issues (including 1 from previous review).

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 1e3f424. Configure here.

: undefined;
}
case 'UnaryExpression': {
if (expression.operator === 'void') return { value: undefined };

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

void folds without checking its operand

Low Severity

literal_value treats every void expression as constantly undefined without folding its operand, unlike the other unaries and unlike the comment that only void of literals is constant. A static yield under void then looks like a folded class or style value, so is_host_attribute_deferred skips TSRX2034. Solid still puts a non-constant class/style in an effect, and the build fails later with the parse error this diagnostic is meant to replace.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 1e3f424. Configure here.

jonkwheeler and others added 3 commits November 12, 2026 13:43
Main added TSRX2032 (tsrx-org#1222), so this branch's TSRX2034 follows it in diagnostics.js and the spec's code list.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRKmwAwuyPbGQ1ejNqiJ46
Main now has TSRX2030 (tsrx-org#1223) and TSRX2033 (tsrx-org#1255) besides TSRX2032, so this branch's TSRX2034 follows TSRX2033 in diagnostics.js and the spec's code list.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRKmwAwuyPbGQ1ejNqiJ46
…raps it

Since main's tsrx-org#1134, Solid TSRX passes an @for iterable to `for_items(...)`, so `each={__for_items(yield t)}` is a call. babel-preset-solid reads such a <For> prop in a getter, where the `yield` no longer runs in its generator. The compiled output fails to parse, and the downstream probe against the installed babel-preset-solid agrees. TSRX2034 is right there now.

Move the case from "allows" to "reports", as with the className and tsrx-org#246 shapes. A yield in a static @if test still runs in place.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRKmwAwuyPbGQ1ejNqiJ46
@jonkwheeler
jonkwheeler merged commit 190f797 into tsrx-org:main Nov 12, 2026
8 checks passed
jonkwheeler added a commit to jonkwheeler/tsrx that referenced this pull request Nov 12, 2026
main now has tsrx-org#1280's squash commit; merged against the parent commit this branch has so git doesn't redo that work.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRKmwAwuyPbGQ1ejNqiJ46
jonkwheeler added a commit to jonkwheeler/tsrx that referenced this pull request Nov 12, 2026
Main now has TSRX2034 (tsrx-org#1280), so this branch's TSRX2035 follows it in diagnostics.js and the spec's code list.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRKmwAwuyPbGQ1ejNqiJ46
jonkwheeler added a commit to jonkwheeler/tsrx that referenced this pull request Nov 12, 2026
Main now has tsrx-org#1235's squash, which matches the tsrx-org#1235 this branch had merged in. The conflicts are where both sides added the same tsrx-org#1235 lines: this branch keeps its own versions. Those are the GenericArrowFunction doc that also covers this PR's `arrowRead`, and the `.mts` expectation in tsrx-org#1235's held-errors test, which throws at the `)` after `y =` because this PR reads `.mts` without JSX. shared/source-mappings.js keeps main's `@tsrx/core` import with DIAGNOSTIC_CODES (tsrx-org#1280) and this PR's TSRX_ERRORS import.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRKmwAwuyPbGQ1ejNqiJ46
jonkwheeler added a commit that referenced this pull request Nov 12, 2026
…1302)

* fix(solid): follow Solid's SSR output for TSRX2034 in a server build

`compile` takes a new `ssr` option. With it, TSRX2034 also reports a
`yield` that babel-preset-solid's SSR output moves into an arrow
(`generate: 'ssr'`, `hydratable: true`, as vite-plugin-solid compiles a
server build with its `ssr` option on), as well as one the DOM output
moves, since the app's client build fails then too. The SSR output:

- renders a host element with a spread through `ssrElement`, with its
  children in an arrow and, when it has other attributes or a dynamic
  spread, its props merged in an arrow;
- evaluates an attribute value in an arrow when it is dynamic, counting
  an element in it as dynamic;
- groups each run of two or more dynamic template values, `textContent`
  included, in one arrow;
- leaves out refs, event handlers and `prop:` values, renames stateful
  DOM properties, and renders a textarea's value as its content.

Without the option, `compile` uses the same transform as before, so its
output and errors are unchanged, and so are the editor's.

Fixes the Vite part of #1291.

* fix(vite-plugin-solid): pass Vite's ssr flag to compile

A module loaded for a server build is compiled with `{ ssr: true }`, so
TSRX2034 follows the SSR output that vite-plugin-solid compiles it to.
The plugin reads the environment's consumer on Vite 6+, and the hook's
`ssr` flag before that, which is the flag vite-plugin-solid reads. A
client build and the dependency scan compile as before.

* docs(solid): say which builds TSRX2034 follows

The Vite plugin checks a server build against Solid's SSR output as
well; the editor and the Rspack and Bun plugins follow the DOM output
only, so a server build there isn't covered.

* test(solid): cover duplicate attributes in the server-build check

The SSR output keeps only the last attribute of a name, so a `yield` in
an earlier one never runs, and a dynamic one no longer groups with a
`textContent` beside it. The rule already followed this; nothing
tested it.

Also drop the rule's lone-spread case. The SSR output passes a lone
spread as is, but TSRX's host spread is always a call, which the DOM
output moves anyway, so the case changed no result.

* refactor(solid): simplify the SSR attribute roles

Read the folded textarea value from its role instead of a filtered
copy of the attributes; no result changes. Import the server hook on
its own line, which keeps the import block clear of #1228's edit.

* fix(solid): count a neighbour that folds to a constant as static when grouping

babel-preset-solid folds an attribute value it can evaluate into a
literal before it groups the SSR template's dynamic values, and folds
an object's values one by one. So `title={{ x: 'a'.length }}`,
`title={String(1)}` and `title={true || bag.x}` are static there, and a
`textContent` `yield` beside them stays in the generator. The rule
called them dynamic and reported that `yield` (found by Codex).

A neighbour now counts as dynamic only when babel's `evaluate` can't
fold it. The check errs towards folding, which can only miss a group.

* fix(solid): drop a yield the compiler folds away in a server build

babel-preset-solid folds a host attribute value, or a value in an
object there, into a literal when it evaluates to a string, number or
boolean, and a child into text when it evaluates to a string or number.
A `yield` in a branch that never runs, as in `true || (yield t)`, goes
with it, in both outputs, so a server build no longer reports it (found
by Codex). The evaluator covers the part of babel's `evaluate` that
needs no scope; what it misses is still reported, as before.

Also read void elements by the tag as written, as the compiler does,
and count `typeof` as a value that may fold.

* fix(solid): read constant bindings and calls as babel's evaluate does

The SSR rule's folding check now follows more of babel's `evaluate`:
a `const` or `let` declared once in the module and never assigned, the
global functions it calls, `String.raw`, arrays and objects. Bindings
are read by name, so a parameter never counts as a constant. This fixes
the three cases a third Codex pass found: a parameter named `Infinity`
hid a moved `yield`, `null && bag.x` beside `textContent` hid one too,
and `[1] + (true || (yield t))` was reported though the compiler drops
that `yield`. A constant between grouped values, like `{1 + 1}`, now
separates them only when the compiler folds it into the template.

* fix(solid): read a top-level var binding as babel's evaluate does

babel folds a `var` declared at the top of a module or function, as it
does a `const` or `let`, but one declared in a nested block only in some
cases. The rule now reads the first kind and leaves the second as not
constant. Tests also cover a constant whose name is declared again
elsewhere, which only `may_fold` can treat as static.

* fix(solid): tighten what the SSR rule thinks may fold

`may_fold` said yes for `typeof bag.x`, `Math.random()`, `"x"[bag.key]`,
any `String` tag and a reassigned binding, none of which babel folds, so
a dynamic value beside `textContent` didn't group with it and its
`yield` went unreported (found by a fourth Codex pass). The binding
table also reads TypeScript's `import x = …`, enums, namespaces and
declared functions, so `Number(false)` after `import Number = …` is no
longer folded as the global.

* fix(solid): a call to a declared name never folds

babel calls a global function only when no binding shadows its name, so
`Number(1)` after `import Number = …` stays dynamic and groups with a
`textContent` beside it. `may_fold` said it might fold.

* docs(changeset): note that a folded-away yield isn't reported

* feat(vite-plugin-solid): add an ssr option for Solid's SSR output

A server build follows babel-preset-solid's SSR output only with
`tsrxSolid({ ssr: true })`, set as `solid({ ssr: true })` is. Without
it, vite-plugin-solid compiles a server build to the DOM output, and
TSRX2034 keeps the DOM rules there: a plain `solid()` server build or a
Vitest `node` environment no longer reports #1291's shape, which builds
in it (found in review). A real Vite pipeline test transforms #1291's
shape for the client and server with the option off and on.

* test(vite-plugin-solid): keep the SSR pipeline test's cache in a temp dir

* fix(solid): fold only literals in a server build, and read bindings by scope

As decided in review, the SSR rule no longer copies babel's `evaluate`:
`read`, `evaluate`, `evaluate_quasis`, `call` and `BINARY_OPERATORS`
are gone, and the folder's `evaluate` is #1280's `literal_value`, which
reads only literals. A value the literals can't decide but that may
fold drops its `yield`s in a server build, and a `textContent` value
that may fold isn't grouped, which fixes the falsy-`textContent` false
report (`<p textContent={false} />` beside one with a `yield`).

`may_fold` now resolves a name where it's read, through a table of the
module's declarations by scope, so a parameter or loop variable of the
same name in another function no longer makes a call or constant look
unfoldable (both false reports). A literal left side or test decides a
short circuit or conditional.

Three probes that pinned the evaluator's reports are dropped: a
constant like `{1 + 1}` between grouped values, and a `var` in a
nested block. Those are misses now.

* feat(bun-plugin-solid): follow Solid's SSR output for TSRX2034

With `solid: { generate: 'ssr', hydratable: true }`, babel-preset-solid
compiles the hydratable SSR output, so the plugin compiles with
`ssr: true` and TSRX2034 reports a `yield` that output moves, as for
#1291's shape. Other options keep the DOM output's rules; the
non-hydratable SSR output builds that shape.

* docs(solid): describe the ssr options as they now work

The Vite plugin follows the SSR output only with `tsrxSolid({ ssr })`,
the Bun plugin with `generate: 'ssr'` and `hydratable: true`. A spread
moves every attribute but refs, event handlers and `prop:` values, and
a value that may fold drops its `yield`s only in a server build
(corrections from review).

* fix(solid): let the SSR attribute rule count a value that may fold as static

The SSR attribute rule now uses the same check as the grouping: a value,
or a value in an object, that may fold into a literal counts as static,
and a value in an object is checked as part of the object, so a tagged
template there isn't dynamic. `class={{ a: yield t, b: 'x'.length > 0 }}`
builds in both outputs and is no longer reported in a server build.

* refactor(solid): drop the unused tags parameter from the fold check

The SSR attribute rule no longer calls `is_folded_dynamic`, so it is
#1280's version again.

* test(solid): cover a conditional with a literal test beside textContent

* fix(solid): scope a namespace body, a static block and a function body

Codex found four more ways a name in another scope looked like it
shadowed a global call: a namespace body, a `var` in a static block, a
function body's `var` read from a parameter's default, and an ambient
`declare function`, which babel erases. Each is now scoped as
JavaScript does, so `String(1)` there folds and no longer groups a
`textContent` `yield` that both outputs leave in place.

* fix(solid): count an ambient const as a binding, and test scopes

babel's scope sees `declare const String: any;`, so `String(1)` after it
isn't folded, and a `textContent` beside it is grouped in the SSR
output. The previous commit skipped every ambient declaration; only a
`declare function`, which babel doesn't bind, stays out of the table.
Tests cover that and a parameter default beside the body's `var`.

* test(bun-plugin-solid): move the server-build tests to their own file

Three open PRs also append to `basic.test.js`, so the server-build tests
live in `ssr.test.js`, with their own small load helper.

* fix(solid): report every client-build yield in a server build too

With `ssr: true`, the server check counts a value babel might fold
through a binding as folded and drops its `yield`s. That also dropped
`yield`s the DOM output moves, so a server build missed what a client
build reports, though both builds fail:
`const on = true; … <input title={on && (yield bag.t)} />`.

A server build now checks the DOM output on its own, as a client build
does, and adds what the SSR check finds; the maybe-folded drop applies
only to the SSR check. Since the DOM check covers the arrow the DOM
output creates some elements in, the SSR check no longer counts it,
and it follows the SSR output where that differs from the DOM's: a
`<noscript>`'s children and `$key` are rendered, not dropped.

The downstream server probes now also check that every `yield` a
client build reports is reported. `<div {...bag} title={Math.max(1, 2) || (yield t)} />`
is reported in both builds now, #1280's literal-fold gap, so it leaves
the server probes.

* fix(solid): bind only what babel's scope binds in a server build

`collect_bindings` declared a TypeScript enum and namespace, which
babel's scope doesn't bind, so with `ssr: true`,
`enum String { A }` beside `<div title={String(1)} textContent={yield t} />`
counted `String(1)` as a call babel can't fold and reported the `yield`,
though both builds parse. Checked against babel's scope as
vite-plugin-solid runs it: an enum, a namespace (`module`, `declare`
or exported), a `declare function` and a `declare class` aren't
bound; `import x = …`, a class and a `declare const` are. The
`declare class` case was the same false report.

* docs(changeset): say a server build reports every client-build yield

* fix(solid): follow the SSR output's $key rename and babel's parameters

From a Codex pass on 3f41b19..fa8c581, each checked against both
builds with `ssr: true`:

- The SSR output renames an element's first `$key` to `_key` before it
  drops duplicate attributes, so `<div $key={yield bag.x} $key="second" />`
  fails the server build (missed) and
  `<div $key={yield bag.x} _key="second" />` builds (reported). The
  server check now renames it too.
- Babel's scope doesn't bind a parameter property
  (`constructor(public String: any)`), so it still folds `String(1)`
  inside; collect_bindings no longer binds one.

* fix(solid): follow the SSR output alone in a server build's own check

From a second Codex pass, on f03dc5b. A server build's own check
still mixed in the DOM output's names and rules, which the separate DOM
check already covers, so it missed or invented `yield`s where the two
outputs differ. Each checked against both builds with `ssr: true`:

- `<input value={yield bag.t} prop:value="x" />` fails the server
  build (the DOM output renames the first and drops it; the SSR output
  keeps it): missed.
- `<noscript>{bag.x && <button onClick={yield t} />}</noscript>` and
  `<select value={yield t} prop:value="x" />` build: reported.
- `<textarea value={bag.v}>{…}</textarea>`: the SSR output replaces
  the children with any default value; they were checked.

The check now follows the SSR model alone: it skips what the SSR output
leaves out (but a ref, which it evaluates where the element is, so in
a spread's children arrow too), and counts content (`textContent`,
`children`, `innerHTML`) as moved when it's dynamic, like a child, and
dropped when a later one of its name replaces it.

* fix(solid): one content slot in the SSR model

From a Codex pass on 8890b3c: the SSR output fills one content slot
from `textContent`, `innerHTML`, `innerText` and `children`, so only
the last of them is rendered. Each was counted as content, so in a
spread's children arrow
`<div {...bag}><p textContent={yield t} innerHTML="x" /></div>` was
reported with `ssr: true`, though both builds parse. Earlier content
properties now count as dropped, for all twelve ordered pairs.

Also renames is_surely_dynamic's new parameter to `elements`.

* fix(solid): a content property with no value doesn't fill the SSR slot

From a Codex pass on ec3a241: the SSR output ignores a content
property with no value (`innerHTML` alone), so it doesn't replace an
earlier one: `<div {...bag}><p textContent={yield t} innerHTML /></div>`
fails the server build and was missed with `ssr: true`, as was
`<p title={bag.x} textContent={yield t} innerHTML />`, where the
`textContent` groups with `title`. A later one of the same name still
replaces it, value or not.

* fix(solid): a textarea's value is SSR content without a spread too

From a Codex pass on 7f63715: the SSR output renders a textarea's
default value as its content, in an arrow when it's dynamic, spread or
not. The SSR check moved it only beside a spread, so
`<textarea value={yield bag.t} prop:value="x" />`, which the DOM output
drops (the later `prop:value` replaces it), failed the server build
unreported. It's now checked like content, grouping included.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRKmwAwuyPbGQ1ejNqiJ46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Solid and Vue fail with a parse error in compiled output for a yield inside JSX

1 participant