Skip to content

feat(hono): add Hono JSX compiler target - #92

Merged
leonidaz merged 10 commits into
tsrx-org:mainfrom
kotarotaniguchi0523:feature/tsrx-hono
Sep 16, 2026
Merged

leonidaz merged 10 commits into
tsrx-org:mainfrom
kotarotaniguchi0523:feature/tsrx-hono

Conversation

@kotarotaniguchi0523

@kotarotaniguchi0523 kotarotaniguchi0523 commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

closes #91

Summary

Add Hono as a TSRX target with separate server (hono/jsx) and DOM (hono/jsx/dom) compiler modes, Vite/Bun integrations, and TypeScript/MCP tooling.

The website playground now offers Hono (server) and Hono (DOM). Supported shared examples are available for both, with seven additional Hono examples covering server routes, streaming, DOM state and refs, context, Suspense, keyed lists with empty states, and dynamic tags. Target choices are shared between the UI and compile API.

Hono's own runtime APIs handle rendering, streaming, hooks, context, refs, CSS, and ErrorBoundary behavior. No changes are made under packages/tsrx/**.

Compiler behavior

  • Server components may be async. DOM components remain synchronous; use use(promise) with a pending boundary for asynchronous work.
  • DOM validation only diagnoses explicit async references that can be resolved statically in the same module. It respects later object-property overrides and stops at uncertain spreads, computed keys, or accessors instead of rejecting an overwritten async value.
  • Select @tsrx/hono/dom explicitly with tsrx.compiler for DOM editor diagnostics. Vite and Bun select their compiler through a build-wide mode: 'server' | 'dom' option.
  • Hono mode is independent of the shared tsrx.platform setting. The integrations read platform configuration from tsconfig and support an explicit matching override.
  • @catch (error) is supported; Hono does not provide a reset callback.

Requires Hono ^4.13.7; the Vite integration requires Vite ^8.0.0.

Validation

  • 12 focused Vitest files: 918 passed, 17 skipped, covering the compiler, Vite/Bun integrations, DOM rendering, TypeScript/MCP integration, and website compile API.
  • pnpm typecheck, pnpm format:check, and pnpm changeset:check passed.
  • Website production build passed. All 29 Hono target/example combinations also compiled through the running website over HTTP; server-rendered markup includes both Hono target choices.
  • The Hono DOM compiler-resolution test now handles canonical filesystem paths on macOS.
  • packages/tsrx/** remains unchanged.

The website's separate standalone typecheck still reports pre-existing declaration/configuration errors; a before/after comparison found no new errors. Interactive browser testing was unavailable in this environment.

Closes #91.


Note

Medium Risk
Large new compiler surface (server vs DOM semantics, DOM async validation, and bundler CSS/HMR) plus MCP and editor resolution paths; mitigated by extensive tests but still a broad integration change.

Overview
Adds Hono as a first-class TSRX target with separate hono/jsx (server) and hono/jsx/dom (browser) compilers in @tsrx/hono, plus @tsrx/vite-plugin-hono and @tsrx/bun-plugin-hono that pick the mode at build time, run the matching JSX transform, and handle extracted <style> CSS (including Vite HMR and per-environment CSS caches).

The Hono platform layer adapts TSRX features to Hono’s contracts: class is preserved, error boundaries emit fallbackRender (no reset callback), server allows async components while DOM disables static hoisting, requires module-scoped hook helpers, and runs a conservative same-module validator for explicit async components (including destructuring and static object members, while later properties/spreads can override earlier async definitions).

Tooling and docs wire Hono through the TypeScript plugin (including explicit @tsrx/hono/dom), MCP (target: 'hono', mode: 'client' → DOM), README/llms.txt, a DOM playground, website playground targets/snippets/API tests, root typecheck/CI (including Bun native Hono tests), and a changeset for the new packages.

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

@vercel

vercel Bot commented Sep 7, 2026

Copy link
Copy Markdown

@kotarotaniguchi0523 is attempting to deploy a commit to the Ripple Team Team on Vercel.

A member of the Team first needs to authorize it.

@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.

Comment thread packages/tsrx-hono/src/platform.js Resolved

@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.

@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.

Comment thread packages/tsrx-hono/src/platform.js Resolved

@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.

Comment thread packages/vite-plugin-hono/src/index.js Resolved

@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.

Comment thread packages/vite-plugin-hono/src/index.js Resolved

@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.

Comment thread packages/vite-plugin-hono/src/index.js Resolved
Comment thread packages/tsrx-hono/src/platform.js Resolved
Comment thread packages/tsrx-hono/src/platform.js Resolved
@kotarotaniguchi0523
kotarotaniguchi0523 marked this pull request as draft September 9, 2026 16:13
@kotarotaniguchi0523
kotarotaniguchi0523 force-pushed the feature/tsrx-hono branch 3 times, most recently from ff2e0a3 to cea4efb Compare September 9, 2026 18:27
@kotarotaniguchi0523
kotarotaniguchi0523 marked this pull request as ready for review September 9, 2026 19:23
@kotarotaniguchi0523
kotarotaniguchi0523 force-pushed the feature/tsrx-hono branch 3 times, most recently from 7b216a6 to 3dc04d0 Compare September 11, 2026 07:14

@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.

Comment thread packages/tsrx-hono/src/platform.js Resolved

@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.

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 8f55456. Configure here.

Comment thread packages/bun-plugin-hono/src/index.js Resolved

kotarotaniguchi0523 commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor Author

@leonidaz, could you please review PR #92 when you have time?

This PR adds Hono support to TSRX, including the server and DOM compilers and the Vite and Bun integrations. It also incorporates the compile-time platform flags introduced in PR #98 into the Hono compiler, Vite plugin, and Bun plugin.

Since you also reviewed PR #98, I would greatly appreciate it if you could check whether its behavior and contracts have been carried over correctly to the Hono integration, especially:

  • the ordering of platform specialization and DOM validation in the compiler;
  • platform resolution and define merging in Vite and Bun;
  • the independence of Hono's server/dom mode from tsrx.platform;
  • any Hono-specific issues around async DOM validation, CSS/HMR, or Bun native builds.

The relevant Hono tests and typechecks are passing, and packages/tsrx/** remains unchanged.

There is no rush, and I would be very grateful for any feedback. Thank you very much for your time.

@leonidaz leonidaz 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.

thank you!

@leonidaz
leonidaz merged commit 0e3f36f into tsrx-org:main Sep 16, 2026
9 of 11 checks passed
@github-actions github-actions Bot mentioned this pull request Sep 16, 2026
jonkwheeler added a commit that referenced this pull request Nov 12, 2026
…OM async check (#1226)

* fix(hono): treat a registry that escapes as possibly written in the DOM async check

Hono DOM's async-component check stays silent on a value it cannot prove
(#92), but it only counted direct writes, writes through a tracked alias
and the first argument of Object.assign-like built-ins. A registry passed
to a function, or held by an object or array that is then written
through, was still reported, though the code renders a sync replacement.

The check now classifies every reference of every binding by where its
value goes. Reads, copies (spreads and rest elements), host JSX values and
calls to built-ins that only read (console.*, JSON.stringify, Object.keys
and similar) leave it alone. A write, an argument, a method call's object,
a returned or yielded value, a component prop, a tagged template and any
place the check does not know expose the value: members below the reached
path may be replaced. Exposures are path-aware, so memo(UI.App) or
register(App) keeps <UI.App /> and <App /> reported.

Aliases now record where they reach each root (the alias's value at
`held` is the root's value at `path`, with `*` for a dynamic key, array
element or iteration step). Object and array literals, sequences,
assignment values, parameter and destructuring defaults and for...of
heads create aliases, and an exposed alias exposes the part of each root
it reaches. This replaces the coarse written set: a write to x.k now
counts as replacing members of x only, so App.displayName = ... no longer
hides an async App.

* fix(hono): bound alias exposure paths and clear arrow-method calls

Review fixes for the DOM async check:

- Aliases reassigned from each other (`a = [b.a.a, b.b.b];
  b = [a.a.a, a.b.b]`) made a new member path for every order of their
  members, so compiling never finished. A binding's exposure now drops
  the paths a new one covers, propagates only the path it grew by, and
  past 16 paths keeps one path that covers them all, with `*` where they
  differ. Each widening covers more, so cycles end; the four-element
  cycle compiles as fast as the one-element one.
- A method call exposed its object even when the method was an arrow
  function, which can't reach it through `this`, so `UI.App()` silenced
  `<UI.App />`. A call whose callee resolves through known initializers
  to an arrow function no longer exposes the object.
- `Object.freeze`, `Object.values`, `Object.entries`,
  `Object.getOwnPropertyDescriptor(s)`, `Object.getPrototypeOf` and the
  matching `Reflect` readers join the read-only built-ins.
- Array literals and array patterns now match by index, so
  `const [, r] = [UI, Other]` links `r` to `Other` only. An element after
  a spread still matches any index.

* fix(hono): expose members handed on by built-ins, keep direct paths, cache method lookups

Review fixes for the DOM async check:

- `Object.freeze` returns its argument, and `Object.values`, `entries`,
  `getOwnPropertyDescriptor(s)` and `getPrototypeOf` (and the matching
  `Reflect` readers) return its members, so code can write members of
  those: `Object.values(UI)[1].App = …` replaced `UI.nested.App` but was
  still reported. These calls now expose every member (`*`). Only the
  built-ins that return no part of their argument stay read-only.
- The 16-path limit merged a binding's own exposures too, so 17
  `patch(UI.kN)` calls widened to `*` and silenced `<UI.nested.App />`,
  which nothing exposed. The limit now applies only to paths passed on
  through aliases; paths from the binding's own references are kept.
- Each arrow-method check walked the alias chain from scratch, copying
  the cycle guard at every step, so 1000 aliases with 1000 calls took
  tens of seconds. Resolution now keeps one guard stack and caches the
  function each initializer and member path resolve to: a step always
  leads to the same next step, so the result is the same from wherever
  it is reached. 1000 aliases with 1000 calls compile in about 190 ms.

* fix(hono): count the check's work in tests, honour stringify replacers, don't cache cycle cuts

Review fixes for the DOM async check:

- The two scaling tests compared wall-clock times against a baseline of
  about a millisecond, so a GC pause could fail them under load. The
  check now counts its resolution steps and exposure updates in an
  internal `hono_dom_validation_work` object, and the tests compare those
  counts: 1000 aliases with a call each take 2005 steps against 205 for
  100 (503503 against 5353 without the cache), and a branching alias
  cycle takes 191 exposure updates with four elements against 35 with
  one (it doesn't finish without the path limit).
- `JSON.stringify` with a function replacer passes the replacer every
  value, which can write `UI.App`. It is read-only now only without a
  replacer or with `null`, `undefined`, a literal or an array.
- A resolution the `seen` guard cut short was cached, but the same
  initializer can still resolve with another member path, so after
  `<A.x />` reached `A.y` mid-resolution, `<A.y />` was silenced. A null
  result is cached only when no cut happened while computing it.

* fix(hono): count a spread onto a component as handing on the registry

A component receives a spread's members as its props, so
`<Patch {...box} />` with `box = { ui: UI }` hands `UI` itself to
`Patch`, which can replace `UI.App` before render. The check counted
every `JSXSpreadAttribute` as a read, so it still reported
`<UI.App />` while `<Patch ui={box.ui} />` was silent.

A spread onto a component now exposes the members of what it spreads:
`<Patch {...box} />` and `<Patch {...{ ui: UI }} />` silence
`<UI.App />`, and `<Patch {...UI} />` silences `<UI.nested.App />` but
not `<UI.App />`, since the props hold a copy of `UI.App`. A spread
onto a host element is still a read.

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.

[Feature]: Add Hono JSX server and DOM targets with Vite and Bun integrations

2 participants