Repository navigation
perf(core): render Text and Heading in React Server Components - #11105
imdreamrunner wants to merge 4 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
PR Analysis Report🔎 Preview ·
|
| Component | Size | LoC | Visual · A11y · RTL |
|---|---|---|---|
| ChatLayout | 84.2 kB (+206 B) · 10.5 kB CSS (0) | — | — · — · — |
| DropdownMenuSubMenu | 71.5 kB (+203 B) · 9.7 kB CSS (0) | — | — · — · — |
| lab/EmojiPicker | 88.2 kB (+199 B) · 751 B CSS (0) | — | — · — · — |
99 more components
| Component | Size | LoC | Visual · A11y · RTL |
|---|---|---|---|
| lab/TransferListSelector | 111.3 kB (+197 B) · 1.4 kB CSS (0) | — | — · — · — |
| RadioListItem | 68.7 kB (+195 B) · 10.1 kB CSS (0) | — | — · — · — |
| ChatComposer | 79.7 kB (+191 B) · 12.0 kB CSS (0) | — | — · — · — |
| ListItem | 71.6 kB (+191 B) · 11.4 kB CSS (0) | — | — · — · — |
| TabMenu | 73.2 kB (+191 B) · 11.1 kB CSS (0) | — | — · — · — |
| ChatDictationButton | 62.0 kB (+190 B) · 10.1 kB CSS (0) | — | — · — · — |
| CheckboxListItem | 72.6 kB (+190 B) · 11.4 kB CSS (0) | — | — · — · — |
| lab/ChatEmojiPicker | 107.6 kB (+190 B) · 773 B CSS (0) | — | — · — · — |
| richtext/RichTextView | 277.9 kB (+190 B) · 2.3 kB CSS (0) | — | — · — · — |
| SideNavHeading | 77.0 kB (+189 B) · 11.3 kB CSS (0) | — | — · — · — |
| Lightbox | 123.9 kB (+188 B) · 10.6 kB CSS (0) | — | — · — · — |
| richtext/RichTextEditor | 299.8 kB (+186 B) · 2.6 kB CSS (0) | — | — · — · — |
| CheckboxList | 69.9 kB (+185 B) · 7.7 kB CSS (0) | — | — · — · — |
| NumberInput | 73.0 kB (+185 B) · 11.4 kB CSS (0) | — | — · — · — |
| IconButton | 61.5 kB (+184 B) · 10.0 kB CSS (0) | — | — · — · — |
| MobileNavToggle | 61.8 kB (+184 B) · 10.0 kB CSS (0) | — | — · — · — |
| TextInput | 69.1 kB (+184 B) · 11.2 kB CSS (0) | — | — · — · — |
| ChatToolCalls | 33.9 kB (+183 B) · 8.3 kB CSS (0) | — | — · — · — |
| DateInput | 188.8 kB (+183 B) · 17.0 kB CSS (0) | — | — · — · — |
| TopNavHeading | 76.6 kB (+183 B) · 11.2 kB CSS (0) | — | — · — · — |
| Typeahead | 82.0 kB (+183 B) · 12.4 kB CSS (0) | — | — · — · — |
| ChatSendButton | 61.9 kB (+182 B) · 10.0 kB CSS (0) | — | — · — · — |
| InputGroup | 57.8 kB (+182 B) · 7.8 kB CSS (0) | — | — · — · — |
| Thumbnail | 65.8 kB (+182 B) · 11.6 kB CSS (0) | — | — · — · — |
| TimeInput | 164.0 kB (+182 B) · 16.0 kB CSS (0) | — | — · — · — |
| lab/DiffViewer | 88.6 kB (+182 B) · 2.1 kB CSS (0) | — | — · — · — |
| Popover | 92.4 kB (+181 B) · 14.2 kB CSS (0) | — | — · — · — |
| Timestamp | 34.8 kB (+181 B) · 10.2 kB CSS (0) | — | — · — · — |
| BreadcrumbItem | 86.0 kB (+180 B) · 12.1 kB CSS (0) | — | — · — · — |
| ChatMessageList | 30.0 kB (+180 B) · 7.0 kB CSS (0) | — | — · — · — |
| TopNavMenu | 76.0 kB (+180 B) · 11.2 kB CSS (0) | — | — · — · — |
| lab/ChatReactionBar | 108.7 kB (+180 B) · 1.1 kB CSS (0) | — | — · — · — |
| ChatLayoutScrollButton | 62.0 kB (+179 B) · 10.2 kB CSS (0) | — | — · — · — |
| Banner | 63.4 kB (+178 B) · 10.5 kB CSS (0) | — | — · — · — |
| ChatComposerTokenElement | 77.5 kB (+178 B) · 11.3 kB CSS (0) | — | — · — · — |
| Link | 54.2 kB (+178 B) · 7.0 kB CSS (0) | — | — · — · — |
| Stepper | 63.1 kB (+178 B) · 10.1 kB CSS (0) | — | — · — · — |
| Switch | 105.0 kB (+178 B) · 9.9 kB CSS (0) | — | — · — · — |
| ToggleButton | 87.9 kB (+178 B) · 10.1 kB CSS (0) | — | — · — · — |
| ChatComposerInput | 77.4 kB (+176 B) · 11.3 kB CSS (0) | — | — · — · — |
| ComplexSelector | 72.3 kB (+176 B) · 11.8 kB CSS (0) | — | — · — · — |
| FileInput | 70.4 kB (+176 B) · 10.9 kB CSS (0) | — | — · — · — |
| Text · Storybook | 13.6 kB (+176 B) · 5.4 kB CSS (0) | 801 (+84) | ✓ · ✓ · — |
| Button | 61.5 kB (+175 B) · 10.0 kB CSS (0) | — | — · — · — |
| TableSelectionToolbar | 71.7 kB (+174 B) · 13.2 kB CSS (0) | — | — · — · — |
| Calendar | 72.4 kB (+173 B) · 10.6 kB CSS (0) | — | — · — · — |
| SideNavCollapseButton | 62.3 kB (+173 B) · 10.0 kB CSS (0) | — | — · — · — |
| Carousel | 71.2 kB (+172 B) · 10.9 kB CSS (0) | — | — · — · — |
| CommandPaletteInput | 33.6 kB (+171 B) · 7.5 kB CSS (0) | — | — · — · — |
| Timer | 15.7 kB (+171 B) · 6.0 kB CSS (0) | — | — · — · — |
| lab/TransferList | 103.6 kB (+171 B) · 1.2 kB CSS (0) | — | — · — · — |
| CheckboxInput | 65.5 kB (+169 B) · 9.2 kB CSS (0) | — | — · — · — |
| CodeBlock | 76.6 kB (+169 B) · 11.3 kB CSS (0) | — | — · — · — |
| SideNavItem | 71.8 kB (+169 B) · 11.1 kB CSS (0) | — | — · — · — |
| Spinner | 26.6 kB (+168 B) · 6.2 kB CSS (0) | — | — · — · — |
| lab/CommentComposer | 153.8 kB (+168 B) · 1.9 kB CSS (0) | — | — · — · — |
| BaseTypeahead | 73.2 kB (+167 B) · 10.9 kB CSS (0) | — | — · — · — |
| TextArea | 63.6 kB (+167 B) · 9.3 kB CSS (0) | — | — · — · — |
| lab/TabBarMoreList | 93.8 kB (+167 B) · 1.8 kB CSS (0) | — | — · — · — |
| RadioList | 57.5 kB (+166 B) · 7.3 kB CSS (0) | — | — · — · — |
| Toast | 99.3 kB (+166 B) · 10.3 kB CSS (0) | — | — · — · — |
| lab/SelectableCardGroup | 65.6 kB (+166 B) · 162 B CSS (0) | — | — · — · — |
| lab/ListInput | 89.5 kB (+165 B) · 922 B CSS (0) | — | — · — · — |
| DateTimeInput | 210.4 kB (+164 B) · 18.7 kB CSS (0) | — | — · — · — |
| Slider | 110.4 kB (+164 B) · 8.8 kB CSS (0) | — | — · — · — |
| Tokenizer | 93.8 kB (+164 B) · 18.8 kB CSS (0) | — | — · — · — |
| TopNavMegaMenu | 71.0 kB (+163 B) · 11.8 kB CSS (0) | — | — · — · — |
| CommandPalette | 74.5 kB (+162 B) · 12.7 kB CSS (0) | — | — · — · — |
| DateRangeInput | 94.4 kB (+159 B) · 12.5 kB CSS (0) | — | — · — · — |
| Field | 56.1 kB (+157 B) · 7.2 kB CSS (0) | — | — · — · — |
| charts/Chart | 206.3 kB (+72 B) · 494 B CSS (0) | — | — · — · — |
| charts/ChartTooltip | 183.5 kB (+72 B) · 422 B CSS (0) | — | — · — · — |
| AlertDialog | 106.8 kB (+69 B) · 14.6 kB CSS (0) | — | — · — · — |
| Pagination | 111.7 kB (+62 B) · 17.8 kB CSS (0) | — | — · — · — |
| lab/CommentThread | 347.5 kB (+59 B) · 2.4 kB CSS (0) | — | — · — · — |
| richtext/RichTextEditorToolbar | 280.2 kB (+57 B) · 454 B CSS (0) | — | — · — · — |
| lab/Schedule | 107.3 kB (+56 B) · 3.9 kB CSS (0) | — | — · — · — |
| Heading | 14.1 kB (+49 B) · 5.4 kB CSS (0) | — | — · — · — |
| AppShell | 93.0 kB (+48 B) · 13.5 kB CSS (0) | — | — · — · — |
| MoreMenu | 98.7 kB (+46 B) · 17.6 kB CSS (0) | — | — · — · — |
| DropdownMenu | 98.4 kB (+44 B) · 17.6 kB CSS (0) | — | — · — · — |
| TableCell | 111.5 kB (+36 B) · 17.9 kB CSS (0) | — | — · — · — |
| lab/TourStep | 98.5 kB (+33 B) · 590 B CSS (0) | — | — · — · — |
| lab/DialogHeroHeader | 84.3 kB (+29 B) · 372 B CSS (0) | — | — · — · — |
| TopNav | 73.6 kB (+28 B) · 10.9 kB CSS (0) | — | — · — · — |
| charts/ChartLegend | 53.4 kB (+27 B) · 224 B CSS (0) | — | — · — · — |
| DialogHeader | 64.1 kB (+27 B) · 11.5 kB CSS (0) | — | — · — · — |
| Selector | 101.6 kB (+24 B) · 17.4 kB CSS (0) | — | — · — · — |
| SideNav | 116.0 kB (+23 B) · 11.4 kB CSS (0) | — | — · — · — |
| DrawerHeader | 64.3 kB (+22 B) · 12.9 kB CSS (0) | — | — · — · — |
| MultiSelector | 96.3 kB (+20 B) · 16.8 kB CSS (0) | — | — · — · — |
| TableHeaderCell | 111.1 kB (+20 B) · 17.6 kB CSS (0) | — | — · — · — |
| MobileNav | 71.8 kB (+19 B) · 10.6 kB CSS (0) | — | — · — · — |
| PowerSearch | 291.8 kB (+18 B) · 24.2 kB CSS (0) | — | — · — · — |
| Table | 127.1 kB (+15 B) · 18.4 kB CSS (0) | — | — · — · — |
| Markdown | 190.0 kB (+10 B) · 20.7 kB CSS (0) | — | — · — · — |
| ContextMenu | 110.2 kB (+5 B) · 17.4 kB CSS (0) | — | — · — · — |
| lab/LineClamp | 15.6 kB (0) · 168 B CSS (0) | — | — · — · — |
| lab/Comments | 354.4 kB (−2 B) · 2.5 kB CSS (0) | — | — · — · — |
Package size: @astryxdesign/core 7.29 MB packed (+4.3 kB); no new dependencies.
API changes: none in this pull request
Committed API report behind this build: cli 57 rows, core 36 rows; run pnpm api:report.
Touched components checked; add ci:run-visual, ci:run-a11y or ci:run-rtl to run the full suites.
Generated by PR Enrichment workflow | View full report
There was a problem hiding this comment.
Approval waits on an engineering owner's decision, because no current spec record owns the React Server Components boundary that this pull request moves for Text and Heading. An engineering owner approves that boundary or names the record that governs it by commenting /approve-spec <full head SHA> on this pull request (the author may do so, as an engineering owner), and the decision has to cover two consequences for Server Components: passing Text itself as a prop to a client component now fails next build, though it builds on main, and a server re-render that moves maxLines between unset and a number remounts the element.
Required change:
- The changeset says a Server Component that renders Text or Heading without
maxLines"ships no client JavaScript for them", but in a Next.js 16 production build with the default Turbopack bundler such a page still loads theTruncatableTextchunks (about 9.1 KB gzip, against 11.3 KB onmain, and the same as a page withmaxLines={2}), so please narrow the wording in.changeset/server-render-text-heading.mdand theText.tsxandHeading.tsxfile headers to what holds, for example that the browser hydrates nothing for them and that a bundler which loads only rendered client modules, such as webpack, loads none of their code.
Also:
- If the owner accepts the prop-passing change, the changeset should say so.
CI was refused admission on this head ("CI is full"), so please re-run it.
[Automated review]
There was a problem hiding this comment.
Approval waits on an engineering owner's decision, because no current spec record owns the React Server Components boundary that this pull request moves for Text and Heading. An engineering owner approves that boundary, or names the record that governs it, by commenting /approve-spec <full head SHA> on this pull request (the author may do so as an engineering owner). The decision covers two consequences for Server Components: passing Text or Heading itself as a prop to a client component now fails next build, though it builds on main, and a server re-render that moves maxLines between unset and a number, or turns the tooltip on or off while maxLines is set, remounts the element.
The changeset now matches what each bundler loads, and nothing else blocks; one optional wording suggestion is inline. CI is still running on this head.
[Automated review]
| '@astryxdesign/core': patch | ||
| --- | ||
|
|
||
| [perf] Text and Heading render in React Server Components. Their modules no longer carry `'use client'`, so in a Server Component they render on the server and the browser hydrates nothing for them. Only an explicit `maxLines` with the truncation tooltip on renders a client part, which measures overflow and mounts the tooltip, as before; a clamped Text with the tooltip off renders only a small part that tells a nested Link it is in clamped text. A bundler that loads only the client modules a page renders, such as webpack, loads none of their code for a page without truncation; one that loads every client module a page's server code imports, such as Turbopack, still loads the truncation part. Imported from `@astryxdesign/core/Text` or `@astryxdesign/core/Heading`, they render on the server now; imported from the package root, once the root entry is no longer a client module. A Server Component can no longer pass these `Text` or `Heading` themselves as a prop to a client component; import them in the client component instead. In client components, Text and Heading render as before, and a change of `maxLines` or `hasTruncateTooltip` keeps the element and its children mounted. No API changes. |
There was a problem hiding this comment.
Non-blocking: "loads none of their code for a page without truncation" reads as covering maxLines={0}, which the docs call no truncation. A Server Component page whose only Text is <Text maxLines={0}> (tooltip on by default) renders TruncatableText and downloads its chunk under webpack (about 11 KB gzip in a Next.js 16 build). Consider "for a page whose Text and Heading leave maxLines unset or turn the tooltip off".
Text and Heading carried 'use client' only for truncation: measuring overflow, the full-text tooltip and, for Text, the clamp context that a nested Link reads. That work moves into a TruncatableText client part, and Text.tsx, Heading.tsx and Text/index.ts become server modules. In a Server Component, Text and Heading without maxLines render the plain element and reference no client code. Any explicit maxLines, 0 included, renders the client part. Every other render always takes the client part, so a change of maxLines or hasTruncateTooltip keeps the element and its children mounted. utils/isReactServer tells the two apart: React's react-server build has no useState. Public APIs and the client output are unchanged. serverSafeComponents.test.ts lists the client part as a client island and checks that Text.tsx and Heading.tsx are server modules. Co-authored-by: Royi Hagigi <[email protected]>
…nt HTML serverRender.test.ts loads the Text and Heading entries under React's react-server build, with each 'use client' module swapped for a client reference, as an RSC bundler does. Without maxLines they render with no client reference; any explicit maxLines references only TruncatableText, with serializable props. The test then renders that output with the client build and the real client part: the HTML equals the client render in every case, and hydrating it reports no mismatch. Co-authored-by: Royi Hagigi <[email protected]>
…n part on the server In a Server Component, Text and Heading now render TruncatableText only for an explicit maxLines with the truncation tooltip on. With the tooltip off, Heading and a Text that does not clamp render the plain element. A clamped Text with the tooltip off renders only TextClampScope, a new client part that provides the clamp context a nested Link reads, so the Link renders the same HTML as in the client build. Client renders still always take TruncatableText. The changeset and the file headers now say what holds per bundler: webpack loads none of their code for a page without truncation, and Turbopack still loads the truncation part that Text imports. The changeset also notes that a Server Component can no longer pass these Text or Heading as a prop to a client component. Co-authored-by: Royi Hagigi <[email protected]>
…e first frame serverRender.test.ts now lists the exact client references of each prop shape, nests a Link in clamped and unclamped Text, and hydrates the renderToString output of the server render. A first-frame check hydrates plain and truncated Text and Heading and a clamped Text with the tooltip off. After the overflow measurement and the Tooltip module load, every DOM node is the node of the server HTML, and only the first hover mounts the tooltip. Co-authored-by: Royi Hagigi <[email protected]>
65f765a to
952673d
Compare
There was a problem hiding this comment.
Approval waits on an engineering owner's decision, because no current spec record owns the React Server Components boundary that this pull request moves for Text and Heading. An engineering owner approves that boundary, or names the record that governs it, by commenting /approve-spec <full head SHA>; the author can do so as an engineering owner. The decision covers four Server Component consequences: passing Text or Heading itself to a client component fails next build, a re-render that moves maxLines between unset and a number remounts the element, Turbopack still downloads the truncation part with plain Text, and a client parent that clones its child now receives the rendered element instead of Text.
Blocking, independent of that decision:
- Miss: when a Server Component passes
<Text maxLines={1}>or<Heading maxLines={1}>(tooltip on) to a client component that clones its child, such as a Slot orasChildtrigger, every prop the parent adds exceptrefis dropped, becauseTruncatableTextreads only its own props while Text and Heading nest the element's props inelementProps(packages/core/src/Text/TruncatableText.tsx:60-68); pass the element props flat, compose the pointer and focus handlers from them, and add aserverRender.test.tscase that clones the server output.
The earlier note on the changeset's maxLines={0} wording still applies.
[Automated review]
| export function TruncatableText({ | ||
| as: Component, | ||
| elementProps, | ||
| maxLines, | ||
| hasTruncateTooltip, | ||
| isClamped, | ||
| ref, | ||
| children, | ||
| }: TruncatableTextProps) { |
There was a problem hiding this comment.
In a Server Component, a client parent that clones its child (a Slot or asChild trigger) receives this element for <Text maxLines={1}> or <Heading maxLines={1}>, and every prop it adds except ref is dropped here: handlers, ARIA, data attributes, className and style. In a Next.js 16 build, a cloneElement(child, {'data-state': 'closed', 'aria-describedby': 'tip'}) parent prerenders neither attribute on a truncated Text or Heading, while main (where the child is the Text element) and the plain path keep both. Passing the element props flat would let them through:
export function TruncatableText({as: Component, maxLines, hasTruncateTooltip, isClamped, ref, children, ...elementProps}: TruncatableTextProps) {with Text and Heading rendering <TruncatableText as={Component} maxLines={maxLines} hasTruncateTooltip={hasTruncateTooltip} ref={ref} {...elementProps}>, plus a serverRender.test.ts case that clones the server output.
Primary intent
Performance: a Server Component that renders
TextorHeadingrenders them on the server, and the browser hydrates nothing for them. This ports the Text and Heading part of #8443 onto currentmain, co-authored with Royi Hagigi (every commit carries hisCo-authored-bytrailer). No other template fits: nothing is broken, nothing looks different, and no prop, type, default or export changes; unlike pure maintenance, it changes where these components render and when their code loads.The rule, as in #8443: the presentational path renders on the server, and truncation lives in a client part that loads only when its props ask for it.
User or maintainer impact
Today
Text.tsx,Heading.tsxandText/index.tsstart with'use client'. A Server Component that renders<Text>or<Heading>can only emit a client reference, so the browser loads the whole client implementation (overflow measurement, the tooltip's first-interaction tracking, the clamp context) and hydrates every instance, even a plain line of text.After this change, in a Server Component:
maxLinesmaxLineswithhasTruncateTooltip={false}: Heading, or a Text that does not clamp (maxLines={0}, or capsize with more than one line)maxLinesof 1 or more withhasTruncateTooltip={false}on TextTextClampScopeonly (below)maxLines, 0 included, with the truncation tooltip onTruncatableText: measures, and mounts the Tooltip on the first hover, tap or focus. The Tooltip module stays a lazy chunk.In client components nothing changes: the same markup, the same hooks, the same tooltip behavior.
Import path.
import {Text} from '@astryxdesign/core/Text'(and@astryxdesign/core/Heading) gets the server render at once.import {Text} from '@astryxdesign/core'gets it only once the package root entry stops being a'use client'module (the AST-113 FR4 gap in #11050). #11106 drops that directive from the root and the barrels; this PR does not touch the root entry. Both PRs remove the same two lines fromText/index.ts, so they merge cleanly in either order.Bundle check (FR10)
A Next.js 16.3.6 production build of the repository's Next fixture (
packages/build/__fixtures__/next-app.mjs, Core linked from source throughwithAstryx()), with three Server Component pages that importTextandHeadingfrom their subpaths. The table is the client JavaScript a page loads beyond a page that renders no Astryx component, gzip, and the Text/Heading client components its RSC payload renders. "Before" is the same build with Core's source atmain(7882c6028).--webpack), before/plain: 2 Headings, 2 Texts,Text maxLines={0}andHeading maxLines={2}with the tooltip off/clamped:Text maxLines={2} hasTruncateTooltip={false}TextClampScope)/truncated:Text maxLines={2},Heading maxLines={1}TruncatableText)Text.tsxmust import its client parts to render them formaxLines, so a Turbopack page that imports Text loads them even when it renders none. The browser still hydrates nothing for them. FR10's "zero in each supported bundler" cannot hold under Turbopack for any component whose server module renders a client part conditionally (it would apply to the Button and TopNav gates too). I did not change the wording of FR10; that is the spec owner's call.TextClampScopeandTruncatableTextin one route chunk, so the clamp-only page loads the same chunk as the tooltip page today. A bundler with one chunk per client module loads 0.5 KB gzip for the clamp scope alone (esbuild over source).The one case routed to client code (FR6, FR12)
A
TextwithmaxLinesof 1 or more tells a nestedLinkthat it is in clamped text, so the link renders inline (Link's clamped-text styles;mainadded this after #8443's base). Only a client component can provide a context. So a clamped Text with the tooltip off rendersTextClampScope, a client part that only provides that context and adds no DOM. Without it, a nested Link would render different HTML on the server than in the client build (FR6) and behave differently before hydration (FR12); the parity and hydration cases with a nested Link fail without it (mutation-checked). Heading provides no clamp context, so a Heading with the tooltip off renders nothing on the client.No remount in client renders
In #8443, Text and Heading rendered the plain element when
maxLineswasundefined(or the tooltip was off) and the client part otherwise, in client renders too. A caller that toggledmaxLinesto or fromundefined, or toggledhasTruncateTooltip, changed the element type and remounted the element and its children.Here the choice also depends on where the component renders:
react-serverbuild (the build React Server Components render with), Text and Heading pick the plain element or a client part as the table above shows.isReactServerreads whetherreacthasuseState: thereact-serverbuild omits it. The check calls nothing.TruncatableText, the same tree as today. No prop change swaps the element type, so nothing remounts.Text/TruncatableText.test.tsxtogglesmaxLinesbetweenundefined, 0 and numbers, andhasTruncateTooltipbetween on, off and a placement, and checks that the element and a child keep their DOM nodes. It fails on perf(core): render Text, Heading, Kbd, Button, IconButton and TopNav in React Server Components #8443's rule (mutation-checked).Known limitations (need an owner decision)
maxLinesbetween unset and a number, or the tooltip on and off withmaxLinesset), React mounts a new element there: the first render has no client part, which is the saving. Changes between numbers with the tooltip on keep the element. A Server Component that toggles truncation can passmaxLines={0}instead ofundefined. This rule is in no record or doc yet.Textitself as a prop. A Server Component that passes the subpath'sTextorHeadingcomponent (not an element) to a client component, as in<Renderer component={Text} />, now failsnext buildwith "Functions cannot be passed directly to Client Components". Onmainthe subpath'sTextis a client reference, so it builds. Any server module has this property; the fix for such a caller is to importTextin the client component. The changeset says so.architecture:component-style-authoringleaves it to a future RSC owner; AST-113 is a draft). An engineering owner decides whether Text and Heading become server modules with the two consequences above.Problem and solution fit
'use client', so the server emits a client reference and the browser loads and hydrates the component.Deltas:
Text/Text.tsx,Heading/Heading.tsxandText/index.tsdrop'use client'. They compute the element's props as before and render the plain element or a client part.Text/TruncatableText.tsx(new,'use client'): the truncation hooks, handlers and tooltip, moved unchanged fromText.tsxandHeading.tsx.Text/TextClampScope.tsx(new,'use client'): Text's clamp context, moved unchanged fromText.tsx.utils/isReactServer.ts(new): tells a React Server Components render from every other render.serverSafeComponents.test.tslists both client parts as client islands and checks thatText.tsxandHeading.tsxare server modules;serverRender.test.tsandText/TruncatableText.test.tsx(new); theuseTruncation.tsheader; a changeset.Authority
No current record governs React Server Components rendering. AST-113 (#11050) is a draft that records the owner's decision (DEC-1: server builds with small client parts) and lists "FR5 gap: Text and Heading begin with
'use client'". This PR closes that gap and follows FR1, FR2, FR3, FR5, FR6, FR8, FR11 and FR12 for Text and Heading; FR10 holds under webpack and not under Turbopack (above).Every component contract stays as it is:
component:TextFR1 to FR5, AR1, AR2 and PR1 (truncation is measured only with a positivemaxLinesand the tooltip on), andcomponent:Heading. No behavior change in client renders or in the HTML: the same props, defaults, markup and interaction. The Server Component consequences are listed under Known limitations.Review receipt:
node scripts/review-global-baselines.mjs, authority7882c6028be5dd71bee7e90eb2b947af16a32a4e, head65f765a3596e869061369e45186f8e47fd39249a, triggersaccessibility,behavior,layout,public-api,theming,react-runtime.architecture:public-component-apiTruncatableText,TextClampScopeandisReactServerare not exported. No API report row changes.architecture:react-component-runtimearchitecture:component-theming-surfacetextandheadingtargets, classes and data attributes render as before on both paths.architecture:internationalizationdesign:bidirectionalityarchitecture:component-size-cascade,architecture:container-padding,architecture:layer-runtime,architecture:theme-application,architecture:theme-authoring-contract,architecture:theme-compilationspec:AST-002,spec:AST-009,spec:AST-012,spec:AST-020,spec:AST-055tospec:AST-059Direct owners resolved first:
component:Textandcomponent:Heading. No knowledge record is created or changed.Change and evidence
Tests
serverRender.test.ts(new, 75 tests). It loads React'sreact-serverbuild and swaps each'use client'module for a client reference, as an RSC bundler does.react-dom/servercannot load under that condition, so a small resolver renders the tree, as in perf(core): render Text, Heading, Kbd, Button, IconButton and TopNav in React Server Components #8443. Then it loads the client build and the real client parts, and renders the server output as the browser does.isReactServerreadstrueunder thereact-serverbuild andfalseunder the client build.as,accessibilityLevel, callerclassName,style,id, ARIA,data-*, nested elements;maxLineswith the tooltip off on Heading and on non-clamping Text);TextClampScopefor a clamped Text with the tooltip off;TruncatableTextfor every explicitmaxLineswith the tooltip on; plusLinkwhere a Link is nested. Every prop that crosses into a client part is serializable.renderToStaticMarkupof the client component.renderToStringof the server output, thenhydrateRootwith anonRecoverableErrorhandler: no recoverable error, the HTML is unchanged, and it equalsrenderToStringof the client component.Text/TruncatableText.test.tsx(new): the remount check above, for Text and Heading.serverSafeComponents.test.ts:TruncatableText.tsxandTextClampScope.tsxare client islands;Text.tsxandHeading.tsxcarry no directive and reach no client-only API (a separate check, because Text's folder also holds its client hooks);Text/index.tsandHeading/index.tscarry no directive; a check that a client API exists ('useState' in React) is not a client API call.Text.tsxfails the server-module checks; a clamped Text withoutTextClampScopefails the nested-Link parity and hydration cases.Not in this PR (dropped from #8443)
Kbd (
PlatformKbd), Button, IconButton, TopNav and TopNavItem, theirreact-serverexport conditions and server shells,scripts/sync-exports.js, the pressable split, and__tests__/serverEntryClientParts.ts(it listsreact-serverentries; Text and Heading have none). This PR is scoped to Text and Heading, phase 1 of AST-113. They read no context on the server path, so one directive-free module serves both environments and needs no separate server entry.Scope
Components: Text, Heading
Testing
pnpm vitest run --project uionserverRender.test.ts,serverSafeComponents.test.ts,Text/,Heading.test.tsx,Link.test.tsxandTooltip/: all pass. Also the Table, EmptyState, Banner, Card, List and CommandPalette suites: 27 files, 618 tests pass.pnpm -F @astryxdesign/core typecheck(tscand the docs typecheck): passes.eslintandprettier --checkon every changed file: no errors or warnings.scripts/check-use-client.mjs: passes.next buildandnext build --webpackof the fixture, atmainand at this head.pnpm review:pre: 0 findings; merges cleanly intomain..changeset/server-render-text-heading.md([perf], patch).