Skip to content

Support native TSRX components in Storybook - #1082

Merged
jonkwheeler merged 5 commits into
mainfrom
jon/storybook-tsrx-targets
Nov 12, 2026
Merged

jonkwheeler merged 5 commits into
mainfrom
jon/storybook-tsrx-targets

Conversation

@jonkwheeler

@jonkwheeler jonkwheeler commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

TSRX components can run in Storybook through their native target compilers and existing renderers, with stories kept in ordinary .stories.ts / .stories.tsx files. Add runnable React, Preact, Solid, Vue Vapor, Hono DOM, and Ripple examples in a private workspace package, plus a copyable setup guide. Octane continues to use its separate OctaneCompat example.

The examples use direct native components where supported and small native lifecycle adapters where needed. Controls update props without resetting component state. No Storybook repository changes, new published preset, or .stories.tsrx support are required.

The browser matrix exposed three compatibility problems, fixed here with regressions and patch changesets:

  • Compose explicit platform flags with Storybook's JSON environment defaults, applying Vite config after environment defaults while preserving compiler transform order.
  • Refresh Solid/Vue extracted CSS before hot reload requests so template and style edits share the current scope hash.
  • Preserve valid bindings for Vue components declared with a named default function export.

Add a dedicated CI job that checks native component/story props and tests all six development and static Storybook canvases. Declare the root DOM matcher dependency and the extension's development TypeScript provider so the expanded dependency graph preserves existing test and VSIX packaging contracts.

Validation:

  • Full repository suite: 176 files passed, 10,041 tests passed, 82 skipped.
  • Full repository typecheck.
  • Native component and story-args typechecks for all six targets, including negative cases.
  • Six Chromium journeys, each exercising development and static builds: native clicks, Controls, local state, template control flow, scoped CSS, and story replacement; development also checks template/CSS edits.
  • Repository formatting, changeset checks, frozen offline install, and whitespace checks.
  • Two independent code reviews found no actionable issues.

The examples cover browser canvases. SSR, hydration, native mobile hosts, automatic .tsrx docgen, and .stories.tsrx discovery remain outside this change. The guide records the pinned Solid/Vue prerelease versions and their upstream peer-range mismatches.


Note

Medium Risk
Touches build-time import.meta.env merging across all Vite target plugins and adds CI browser coverage; HMR/CSS changes affect Solid/Vue dev workflows but are well-tested.

Overview
Adds a private @tsrx/storybook-examples package with runnable Storybook setups for React, Preact, Solid, Vue Vapor, Hono DOM, and Ripple—ordinary .stories.ts(x) importing native .tsrx components, typed props tests, and Playwright journeys over dev and static builds. CI gains a storybook job (typecheck + browser tests, failure artifacts); docs/README/llms point consumers at the examples.

Fixes Storybook+Vite integration in core and all target Vite plugins: merge_platform_definitions now merges compatible JSON import.meta.env defaults with TSRX platform flags (and adds import.meta.env.platform for Vite dev), while still rejecting conflicts; plugin config hooks run order: 'post' so Storybook’s environment define is composed before platform specialization.

Solid and Vue plugins refresh extracted scoped CSS on HMR before virtual JS reload (clear cache when styles removed; keep last good CSS when compile fails). Vue compiler gains a regression for default-exported components that also re-export the same binding.

Minor tooling: root @testing-library/jest-dom, VS Code plugin dev typescript, patch changesets for affected packages.

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

jonkwheeler and others added 3 commits November 12, 2026 11:38
The Solid and Vue plugin tests keep main's #1250 module-id tests and this branch's HMR CSS test, with both sides' node:fs imports. Main's #1125 already keeps the binding of a default-exported Vue component (const App = ...; export default App), so main's transform and shared compile test are kept, this branch's equivalent export-specifier rewrite and its vue-default-function-export changeset are dropped, and its Vue regression test, which passes on main's output, is kept.

pnpm-lock.yaml is main's plus the entries this branch's lockfile added, re-resolved with the storybook-examples vue and vue-jsx-vapor pins moved to main's 3.6.0-rc.14 and 3.2.29 (#1296), so the README and llms.txt no longer list a Vue peer mismatch. Starting from main's lockfile alone resolved vue-component-meta 3.3.14, which brings @volar/* 2.4.30 and gives the VS Code extension two volar-service-typescript copies.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRKmwAwuyPbGQ1ejNqiJ46
In the Solid and Vue plugins, main's #1103 added a transform hook right before the handleHotUpdate this branch makes async to refresh CSS; both are kept. The other #1103 changes to the five plugins merged cleanly next to this branch's order: 'post' config hooks, and main changed no dependencies, so pnpm-lock.yaml stays as this branch had it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRKmwAwuyPbGQ1ejNqiJ46
Two import lists conflicted: tsrx-vue/tests/basic.test.js keeps main's TSRX_ERRORS import and this branch's typescript import, and tsrx/tests/utils/platform.test.js keeps main's createVolarMappingsResult and this branch's mergePlatformDefinitions. Main changed no dependencies, so pnpm-lock.yaml stays as this branch had it, with vue-component-meta 3.3.13 and one @volar 2.4.28.

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.

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 907fa5e. Configure here.

Comment thread packages/vite-plugin-solid/src/index.js Resolved
… doesn't compile

This branch made the Solid and Vue plugins compile a `.tsrx` file in
`handleHotUpdate`, to refresh its extracted CSS before the virtual JS
reloads. The compile had no error handling, so saving a file that
doesn't compile, such as one with an unclosed tag, threw out of the
hook. Vite then stopped the update: the virtual module wasn't
invalidated, so its `load` never ran to report the compile error as it
does on main, where the hook only invalidates.

The refresh now catches the error and keeps the last good CSS, as the
React and Preact plugins do since #1182, and the hook still returns the
virtual and CSS modules so the reload reports the error. A regression
test in each plugin saves a broken update after a good one and checks
both.

Reported by Cursor Bugbot on #1082.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRKmwAwuyPbGQ1ejNqiJ46
@jonkwheeler
jonkwheeler merged commit fe2c377 into main Nov 12, 2026
9 checks passed
@jonkwheeler
jonkwheeler deleted the jon/storybook-tsrx-targets branch November 12, 2026 21:30
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.

1 participant