Repository navigation
fix(core): import generated Suspense, Fragment and TsrxErrorBoundary under private names - #1175
Merged
jonkwheeler merged 8 commits intoNov 12, 2026
Merged
Conversation
…srx on HMR handleHotUpdate compiled every changed .tsrx file to refresh its stylesheet before checking whether a stylesheet module existed. A file imported only as `?raw` (an incomplete docs example, say) failed to compile, and Vite sent an HMR error instead of the raw update. Look the stylesheet module up first and compile only when it exists, as the Hono plugin already does. Fixes tsrx-org#566 Co-Authored-By: Claude Opus 5.5 <[email protected]>
The shared JSX import injector always added
`import { Suspense } from '<source>'` for `@try … @pending` and
`import { Fragment } from '<source>'` for keyed fragment bodies, even
when the module already imported that name from the same source. The
duplicate declaration failed the build with "Identifier `Suspense` has
already been declared".
Skip the injected import when the module already has a value import of
the same name and local from the same source. React, Preact and Hono
share this injector.
Fixes tsrx-org#862
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…privately
The import injector added `Suspense`, `Fragment` and `TsrxErrorBoundary`
under their public names, and the generated elements referenced those
names. Any other authored binding with one of them broke the build
("Identifier `Suspense` has already been declared") for a type-only,
default, namespace or other-source import, or silently replaced the
generated element for a setup local or a `@for (const Fragment of ...)`
loop variable.
Import them as `__Suspense`, `__Fragment` and `__TsrxErrorBoundary`, as
the injector already does for `mergeRefs`, and reference those aliases
from the generated elements, including Hono's `fallbackRender` boundary.
This replaces the same-name import reuse from tsrx-org#1102, which no longer has
anything to reuse.
Vue imports `TsrxErrorBoundary` itself for the core-generated boundary,
so its injector takes the alias too, and it no longer merges that value
import into an authored `import type` declaration, where it would be
erased.
Fixes tsrx-org#1141
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Contributor
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 68eb01d. Configure here.
…uspense
Every import injector put its imports at index 0, ahead of a
`'use client'` or `'use server'` directive, which then stopped being a
directive. Any module using `@pending`, `@catch`, a keyed fragment row,
a dynamic tag or another construct with a generated import lost its
directive; Next.js treated a `'use client'` .tsrx module as a server
component ("You're importing a module that depends on `useState` into
a React Server Component module").
Insert generated imports (and the type-only style anchors) after the
directive prologue in the core, Vue and Solid injectors.
Vue's `ensure_named_import` also counted an inline `type` specifier as
the value import, so `import { type Suspense } from 'vue'` with
`@pending` left `Suspense` unbound. Require a value specifier, and
import Vue's generated `Suspense` as `__Suspense` like the core
transform does, so the value import never redeclares an authored
binding. vue-jsx-vapor compiles the aliased element the same way.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
jonkwheeler
marked this pull request as ready for review
October 27, 2026 17:11
jonkwheeler
added a commit
to jonkwheeler/tsrx
that referenced
this pull request
Oct 28, 2026
The previous commit named Solid's generated control-flow components `__Show`, `__Switch`, `__Loading` and so on. The compiler counted a tag as a component only when it started with A-Z, so those looked like host tags. Solid vetoes hoisting a subtree that renders a component, and without the veto a static `@if`, `@switch` or `@pending` subtree went to one module-level node: a component rendered twice showed one copy. Decide as JSX does instead: a tag is a host element only when its first character is a lowercase ASCII letter. Compiled on every .tsrx file in the repo, React, Preact, Hono and Vue output is byte-identical before and after, and Solid output matches tsrx-org#1175's apart from the private names. Co-Authored-By: Claude Opus 5.5 <[email protected]>
jonkwheeler
added a commit
to jonkwheeler/tsrx
that referenced
this pull request
Nov 6, 2026
tsrx-org#1175 and tsrx-org#1222 import `Suspense` as `__Suspense`, so the test failed once either was merged with this branch. The name isn't what it's about. Co-Authored-By: Claude Opus 5.5 <[email protected]>
jonkwheeler
added a commit
that referenced
this pull request
Nov 12, 2026
…pins (#1296) * fix(vue): leave Vue's slot flag out of the type-only @pending boundary `vue-jsx-vapor` 3.2.29 types a component's `v-slots` from its real slots, so the `_` flag on `Suspense` is an excess property and every `@try` with `@pending` reports TS2322 in the editor. The flag only matters at runtime, so keep it in compiled output and drop it from the type-only print. * chore(vue): bump vue to 3.6.0-rc.14 and vue-jsx-vapor to 3.2.29 Moves every dev pin, and adds `vue-jsx-vapor` as a dev dependency of `@tsrx/vue` so its peer stops resolving to 3.2.14 in the lockfile. Runs the Vue runtime tests on the real `vue-jsx-vapor` runtime instead of a hand-copied shim. The shim had the #870 bug and lacked `normalizeVaporSlots`, which the new compiler output imports, so it would have hidden the fix. * test(vue): run the worker regression in a worker-like scope The test matched text: it looked only at the first mention of `__VUE_HMR_RUNTIME__` and rejected only uses at column 0, so an indented, unguarded `createRecord` after one guarded use passed. It now runs the served module with `self` and none of Vue's globals, and checks what it posted. * test(vue): pin the Suspense slot flag in compiled output Nothing failed when `_: 1` was dropped from compiled output. Pin it there and pin its absence from type-only output, for both ways `@pending` is lowered. Correct the changeset and 4a43094's message: `vue-jsx-vapor` rejects the flag from 3.2.20, not 3.2.29, and leaving it out clears the error from 3.2.22. 4a43094's "the flag only matters at runtime" is also unsupported: removing it fails no runtime test, and I haven't shown what depends on it. * chore(vue): drop an unused paths entry from the plugin test tsconfig Nothing in the project imports Vue's Vapor browser build. Only `vue-runtime-shim.js` does, and that file isn't part of the project. `tsc` reports the same with and without the entry. * test(vue): move the Suspense slot flag test to its own file At the end of `type-only-types.test.js` it conflicted with #1177, which changes the lines before it. * test(vue): stop the slot flag test passing on missing output The type-only assertion was only a negative match, so it also passed if the `Suspense` boundary was gone. Require the boundary, and no compile errors, before checking that the flag is absent. * test(vue): let the slot flag test accept a private Suspense name #1175 and #1222 import `Suspense` as `__Suspense`, so the test failed once either was merged with this branch. The name isn't what it's about. * style(vue): format the slot flag test * fix(vue): require vue 3.6 and vue-jsx-vapor 3.2.27 as peers Raise the floors in all five packages that declare them: `@tsrx/vue`, `@tsrx/vue-runtime`, `@tsrx/vite-plugin-vue`, `@tsrx/rspack-plugin-vue` and `@tsrx/bun-plugin-vue`. `vue >=3.6.0-0` admits the 3.6 prereleases and rejects 3.5, which has no Vapor. The old `>=3.5` rejected every 3.6 prerelease under npm, so no Vapor setup installed with npm's defaults. `vue-jsx-vapor` 3.2.27 is the first release with the fixes for both #186 (3.2.26) and #870 (3.2.27). Minor, because a project on `vue-jsx-vapor` 3.2.26 that installs today under pnpm's `strict-peer-dependencies` fails after this. * docs(vue): name Vue 3.6 in the install commands `vue` alone installs Vue's `latest`, 3.5.45, which has no Vapor: with pnpm, `vite build` then fails with MISSING_EXPORT. Name `vue@^3.6.0-0`, which picks the newest 3.6 prerelease now and stable 3.6 once it ships. * docs(changeset): drop the 3.2.20 to 3.2.22 notes from the slot flag changeset With `vue-jsx-vapor` 3.2.27 as the floor, every supported version rejects the flag, and every one accepts the output without it. * docs(changeset): say which Vue prereleases the new floor admits `>=3.6.0-0` admits 3.6.0's prereleases, not later ones such as 3.6.1-alpha. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The conflicts were export and import lists (kept both sides, sorted), Solid's control-flow import (main's createMemo specifiers placed after the directive prologue), main's removal of the inline-element error-boundary call (kept removed), and two adjacent turbopack loader tests (kept both). Main's newer Solid ref-prop imports and Vue's keyed-slot computed import now also go after directives, and Vue's ensure_named_import keeps main's type-only and namespace checks without the PR's duplicate. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01FRKmwAwuyPbGQ1ejNqiJ46
…tests This branch imports the generated Suspense and TsrxErrorBoundary as `__Suspense` and `__TsrxErrorBoundary`. Tests that main added since (the TsrxTryBody fallback, @Try site keys, inline @pending bodies, Vue's keyed-slot computed import and element-child boundary) matched the public names. They now match the aliases, the react-server import check reads the imported name of each specifier, and Vue's Suspense import tests expect the generated `Suspense as __Suspense` beside any authored `Suspense` import. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01FRKmwAwuyPbGQ1ejNqiJ46
Main's tsrx-org#1136 renamed keyed_fragment_to_jsx_element to keyed_fragment, which now takes the row's children. The renamed function keeps this branch's private `__Fragment` name. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01FRKmwAwuyPbGQ1ejNqiJ46
Main's tsrx-org#1136 added a test that matches `<Fragment key={group.id}>` for a keyed row that renders a nested @for. This branch imports the generated Fragment as `__Fragment`, so the test now matches that name. 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
Core's export list keeps this branch's DYNAMIC_FACTORY_LOCAL and DYNAMIC_IMPORT_LOCAL beside main's ERROR_BOUNDARY_INTERNAL_NAME. Main's tsrx-org#1175 now inserts Solid's generated imports after the directive prologue, so this branch's for_items / for_keyed_rows import goes through insert_after_directives as well instead of program.body.unshift. 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
The React and Preact runtime tests keep this branch's static-container harness import and call beside main's generated-import-bindings harness (tsrx-org#1175). 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
…e names (#1222) * fix(solid,vue): import generated control-flow components privately Solid imported Show, For, Switch, Match, Errored and Loading from solid-js under their public names, and Vue imported VaporFor the same way. An authored binding with one of those names either collided with the generated import (another module's import, a type-only import) or replaced the generated element (a module or setup local, or a `@for (const Match of rows)` loop variable). Import them as __Show, __For, __Switch, __Match, __Errored, __Loading and __VaporFor, the way #1175 imports Suspense, Fragment and TsrxErrorBoundary. Solid's compiler treats the aliased tags as plain components, and vue-jsx-vapor compiles <__VaporFor> exactly like <VaporFor> in DOM, SSR, HMR and interop output. defineVaporComponent keeps its public name: vue-jsx-vapor's macros, HMR registration, SSR registration and interop compile all find components by that callee name. * fix(vue): report authored defineVaporComponent bindings (TSRX2032) vue-jsx-vapor finds components by calls to `defineVaporComponent`, so the compiler's import of it can't take a private name the way VaporFor now does. An authored binding of that name either collided with the generated import (an import from another module) or replaced it (a module function or const), and vue-jsx-vapor's macros treat every call of the name as a component definition anyway. Report each such binding with a new code, TSRX2032: an import from anywhere but `vue-jsx-vapor`, a module function, const or class, and a local or parameter in any scope. In collect and editor mode a module-level binding keeps the name, and the compiler adds no import that would declare it again. A type-only import of `defineVaporComponent` from `vue-jsx-vapor` itself becomes the value import the components need. The error has an entry in the error tables, a row in the specification and an example the content mapper checks through TypeScript 7, which now covers Vue as well as React and Solid. * fix(core): treat any tag not starting with a-z as a component The previous commit named Solid's generated control-flow components `__Show`, `__Switch`, `__Loading` and so on. The compiler counted a tag as a component only when it started with A-Z, so those looked like host tags. Solid vetoes hoisting a subtree that renders a component, and without the veto a static `@if`, `@switch` or `@pending` subtree went to one module-level node: a component rendered twice showed one copy. Decide as JSX does instead: a tag is a host element only when its first character is a lowercase ASCII letter. Compiled on every .tsrx file in the repo, React, Preact, Hono and Vue output is byte-identical before and after, and Solid output matches #1175's apart from the private names. * fix(vue): cover the TSRX2032 edge cases - `declare function defineVaporComponent` declares the name, so it is reported too. - After any TSRX2032 the compiler adds no `defineVaporComponent` import. A `var` in a top-level block hoists to module scope, so the import redeclared it (TS2440) even though the binding is not at module level. - A namespace of types only binds no value, so it is not reported. - A quoted specifier, `{ "defineVaporComponent" as defineVaporComponent }` from `vue-jsx-vapor`, is the compiler's own import: it is not reported, and the compiler reuses it instead of adding the name again. * docs(changeset): note the component-name rule * test: expect the private Solid and Vue control-flow names in main's tests This branch imports Solid's Show, For, Switch, Match, Errored and Loading and Vue's VaporFor under `__` names. Tests main added since (the static @if fallbacks from #1129, the @{ } block bodies from #1128, the memoized @switch, the untracked @Try body, and the keyed-array @for from #1135) matched the public names; they now match the private ones. The memoized @switch also imports `createMemo` from solid-js, so the generated import no longer fits on one line and the printer wraps it. The shared generated-import check and the @switch memo test now read an import across lines. * test(vue): import defineVaporComponent from vue-jsx-vapor in the props params test Main's #1231 added a runtime test that imports `defineVaporComponent` from `vue` and calls it directly, so vue-jsx-vapor's props macro sees the patterns as written. This branch reports every binding of that name other than an import from `vue-jsx-vapor` (TSRX2032), because the compiler imports it from there for each component it wraps and a second binding would collide. Import it from `vue-jsx-vapor`, as the compiler does; the macro still finds the calls by name. 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
The Vue transform's import list keeps main's new ERROR_BOUNDARY_INTERNAL_NAME (tsrx-org#1175) and drops DIAGNOSTIC_CODES, which this PR leaves unused there. In for_of_statement_to_jsx_child, main's validate_for_of_head call (tsrx-org#1133) runs first, then this PR's check that skips an `@for await` the target already reported. The JSX transform imports find_first_top_level_await again beside this PR's find_top_level_awaits: this PR had dropped it, and main's tsrx-org#1133 calls it for an awaited `@for` head default. 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
The React and Preact runtime tests keep this branch's assigned-import-member harness import and call beside main's generated-import-bindings harness (tsrx-org#1175). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01FRKmwAwuyPbGQ1ejNqiJ46
This was referenced Nov 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Stacked on #1102; review the commits after 2cde29a; merge after #1102.
Summary
Generated components no longer collide with authored bindings (#1141). Before: the compiler imported
Suspense(for@try … @pending),TsrxErrorBoundary(for@try … @catch) andFragment(for keyed fragment rows) under their public names, and the generated elements referenced those names. #1102 handled one case, an authored value import with the same name and source. Every other authored binding with one of those names still broke:import type { Suspense } from 'react',import { type Suspense }, a default, namespace or other-module import, or an authoredTsrxErrorBoundaryimport failed the build withIdentifier `Suspense` has already been declared.@for (const Fragment of rows; key …) { <>…</> }built, then React threwElement type is invalid, because the generated<Fragment key>named the loop variable.const Suspense = …in setup built and rendered the local component in place of the boundary, with no error.After: the compiler imports them as
__Suspense,__TsrxErrorBoundaryand__Fragment, the way it already importsmergeRefsas__mergeRefs, and the generated elements use those names. Authored bindings keep their own meaning. React, Preact and Hono share the injector; Hono'sfallbackRenderboundary uses the alias too. This replaces #1102's same-name reuse, which no longer has anything to reuse.Vue. The core transform also emits the
@catchboundary that Vue renders without@pending, and Vue's own injector imports it, so Vue now importsTsrxErrorBoundary as __TsrxErrorBoundaryas well. Vue's generatedSuspensebecomes__Suspensetoo; vue-jsx-vapor compiles<__Suspense v-slots>exactly like<Suspense v-slots>, apart from the name. Vue's import merge no longer counts an authored type-only import as the value import: an inlineimport { type Suspense } from 'vue'with@pendingused to emit no value import, leavingSuspenseunbound at runtime, and a value specifier merged into animport typedeclaration would have been erased.Directives stay first. Before: every import injector (core, Vue, Solid) put its imports at index 0, ahead of a
'use client'or'use server'directive, which then became a plain string. Any module with@pending,@catch, a keyed fragment row, a dynamic tag or another construct that needs a generated import lost its directive. This is on main; #1102 avoided it only when the module importedSuspenseitself. Through the Turbopack plugin,next buildtreated a'use client'.tsrxas a server component. After: generated imports, and the type-only style anchors in editor output, go after the directive prologue.Not changed: Vue's
VaporForanddefineVaporComponentimports, and Solid'sShow/For/Switch/Match/Errored/Loadingimports, still use public names. They come from each target's own injector, not the shared one, so they are left for a follow-up.Verification
packages/tsrx/tests/shared/compile.js, run for React, Preact and Hono): for each ofSuspense,TsrxErrorBoundaryandFragment, an authored value import from the same source, a type-only import, an inline type import, a default, namespace and other-module import, a module-levelconst, and a setup local. Each asserts no TypeScript redeclaration diagnostic and that the generated element uses the private import. Plus the@for (const Fragment of rows; key Fragment)case. 25 cases per target, all failing on fix(react): skip raw-only .tsrx on HMR and reuse authored Suspense and Fragment imports #1102's head (Duplicate identifier 'Suspense'or the unaliased import).packages/tsrx/tests/shared/runtime/generated-import-bindings.js, React and Preact): a module function namedTsrxErrorBoundary, a setup localSuspenseand a loop variableFragmentbeside generated boundaries and keyed rows. Before the fix the generated elements rendered the authored components, and React threwElement type is invalidfor the loop.TsrxErrorBoundaryimport, an other-module import and a setup local each get the private import. ForSuspense, an inlineimport { type Suspense } from 'vue', animport typedeclaration and an other-module import each getSuspense as __Suspenseas a value import. The inline-type case emitted no value import before.'use client','use server', and'use client'plus'use strict'above a component that needs several generated imports, in normal andcollectmode, and checks the directives are still the first statements. All 15 failed before. A Turbopack loader test checks the same through@tsrx/turbopack-plugin-react.next build(Next 16.2.6, Turbopack) of a'use client'.tsrxpage withuseStateand@pending: before, Next reported "You're importing a module that depends onuseStateinto a React Server Component module". On this branch Next treats the file as a client boundary, and the build then stops at [Bug]: turbopack-plugin-react: next build fails for any .tsrx file that starts with 'use client' (Can't resolve './Client.tsrx.tsx') #1148 (Can't resolve './App.tsrx.tsx'), which is fixed in the fix(turbopack): scoped CSS in Next builds and TSX parsing for platform flags #1087 stack.@tsrx/vite-plugin-reactand rendered withrenderToStaticMarkup: on fix(react): skip raw-only .tsrx on HMR and reuse authored Suspense and Fragment imports #1102's head, six rows fail to build, theFragmentloop throws, and the localSuspenserenders<section>. On this branch every row builds and renders the boundary content.npx vitest run: 10071 passed, 26 failed. Every failure passes when rerun: 22 were 5s or 30s timeouts in tests that spawntscortsrx-tsc(load average 60 to 90 from parallel agents; the three React fixture typechecks exit 0 when run directly), and 4 were the TextMate grammar and Shiki highlighting tests, which also flake on fix(react): skip raw-only .tsrx on HMR and reuse authored Suspense and Fragment imports #1102's head.pnpm typecheckclean,pnpm changeset:checkpasses, Prettier clean on changed files.Related
Fixes #1141
Related: #862, #1102
🤖 Generated with Claude Code
Note
Medium Risk
Touches JSX lowering and import injection across all targets; behavior changes when user code shadows generated component names and when modules use directive prologues with
@try/@pending/@catch.Overview
Compiler-generated
Suspense,TsrxErrorBoundary, andFragmentnow import and render as__Suspense,__TsrxErrorBoundary, and__Fragment, so authored bindings (value/type imports, locals, or@forvariables with those names) no longer duplicate declarations or replace the lowered boundaries/fragment rows.insert_after_directivesinserts compiler-added imports (and related top-level anchors) after the module directive prologue, keeping'use client'/'use server'first—important for Next.js and Turbopack client boundaries.Core
inject_try_importsalways emits aliased imports (drops same-name reuse); Vue and Hono platform transforms use the shared boundary names; Solid/Vue injectors switched fromunshiftto directive-aware insertion. Shared compile/runtime tests and React/Preact Vite harnesses cover coexistence and directive ordering.Reviewed by Cursor Bugbot for commit 8d18993. Bugbot is set up for automated code reviews on this repo. Configure here.