Repository navigation
fix(compiler): fold tsx string-literal children for hydration - #972
Merged
Merged
Conversation
Leave {" "} and other string-literal expression children in extracted
.tsx fragments so the client bakes them like .tsrx and the server.
That keeps hole counts aligned and stops hydration from duplicating
the following element.
Fixes #965
Co-authored-by: Jon Wheeler <[email protected]>
jonkwheeler
marked this pull request as ready for review
September 6, 2026 13:53
leonidaz
approved these changes
Sep 6, 2026
14 of 21 tasks
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.
Fixes #965
Summary
.tsxreturn-form extraction treated string-literal children such as Prettier's{" "}as dynamichNholes, while the server and.tsrxcompilers baked them into the template.itemsitems).extractFragmentnow leaves string-literal expression children in place soemitElementHtmlfolds them throughstaticTextLiteral, matching.tsrxand the server.Why
.tsrx/ server contract and avoids a runtime text hole for constant whitespace.Changes
packages/octane/src/compiler/compile.js: do not hoiststaticTextLiteralchildren inextractFragment.{" "}, adjacent/{""}literals, and still-dynamic{expr as string}holes.Validation
packages/octane/tests/compiler/tsx-static-string-child.test.ts,packages/octane/tests/hydration/tsx-string-literal-hydrate.test.ts(12 passed, includingoctane-prod)ssr-tsx-children,text-sibling-hydrate,markerless-text-hydrate,value-jsx-hydrate,component-children-hydrate(88 passed)pnpm format:files:checkon changed files./node_modules/.bin/tsgo --noEmit -p packages/octane/tsconfig.jsonpnpm format:check(CI lint on31b2912df)pnpm typecheck(CI typecheck on31b2912df)pnpm test(CI test shards + test (24) on31b2912df)pnpm sync(no extra generated diff)Risk / follow-ups
Literal/StringLiteralchildren are folded, the same setstaticTextLiteralalready bakes on the template path.{expr as string}, numbers, and other expressions stay holes.Reviewers
Requested: @leonidaz @trueadm
READY FOR REVIEW
Provenance
agent-authored)Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.