Repository navigation
Test every JSX text for spaces Next's compiler drops - #263
Merged
Merged
Conversation
Next 16.2.6's compiler drops the leading space of a JSX text that spans
more than one line and contains an HTML entity, so policybench.org renders
"52 frontier modelson 100 households" on /expand and four run-together
phrases on the home page. An explicit {" "} puts each space back. A new
test applies the compiler's trigger to every page component, and the
expansion-page test no longer reads React's text separators as spaces.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
The test renders with renderToStaticMarkup, which emits no <!-- --> separators, so the added .replace(/<!-- -->/g, "") changed nothing and its comment named the wrong cause. The test never saw the /expand defect because Bun's transpiler keeps the leading space that Next's compiler drops. The line returns to what main has; a compiler-backed check for the five fixed spaces follows in the spacing guard test. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
… SWC The guard's rule cases were checked against Next's compiler only by hand. The test now loads Next's own SWC binding, compiles each case with it and with TypeScript, and requires the case to record what Next renders and whether that drops a space TypeScript keeps. A second check compiles ExpandCoverageCopy, ModelLeaderboard and Methodology with Next's SWC and requires whitespace before each of the five phrases policybench.org ran together. Run against main's three files, it fails on all five and the guard names the five lines. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The guard's /&(#\d+|#x[0-9a-f]+|[a-z][a-z0-9]*);/i matched any &name;,
so `{x} after\n one¬AnEntity;s` failed it although Next keeps that
space: the compiler leaves unknown names as written and only a decoded
entity triggers the drop. Probing Next 16.2.6's SWC with 2,425 candidate
names (TypeScript's JSX table, the HTML5 names, case variants) showed it
decodes exactly TypeScript's 253 names, case-sensitively, plus decimal
and lowercase-x hex references with at most nine characters between &
and ;. The guard now reads entities that way. A new test compiles every
listed name and a set of near misses and requires the guard to agree with
the compiler on each; rule cases add an unknown name and a miscased one
(space kept, not flagged) and a named, decimal and hex entity (flagged).
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The guard required a previous sibling and a literal LF, and looked only
at leading spaces, so it passed three shapes Next 16.2.6's SWC mangles:
a text that opens an element (`before<span> after\n one's</span>`
renders "beforeafter one's"), a lone CR or U+2028 as the line break, and
an encoded line break at a text's edge (`{x} word\n next` renders
"{x}word next"). Probing the compiler showed two mechanisms. Next deletes
the leading spaces and tabs of a text that has a decoded entity and any
line break, literal or encoded; @swc/core 1.16.22 keeps them. Every SWC
probed also reads an encoded line break as a source line break, so at
either end of a text it vanishes with the whitespace around it, where
TypeScript and Bun keep it. Whitespace the compiler never trims ( ,
, a literal no-break space) keeps the words apart in both.
The guard now reads each text as the compiler does and applies both
rules, stated in the test's header. New rule cases cover each shape and
the kept-whitespace exceptions, each compiled with Next's SWC and checked
against TypeScript's output. No text under src/ matches the wider rule,
and against main's files the guard still names exactly the five lines.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
MaxGhenis
added a commit
that referenced
this pull request
Nov 14, 2026
…264) Next 16.2.6's compiler drops the leading space of a JSX text that spans more than one line and contains an HTML entity. Five phrases on the home page and the expansion page lost the space between two words. Each space moves into an explicit {" "}. No word of the copy changes. The guard test for this defect is in #263. Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>
The spacing guard predicted dropped whitespace from a hand-fitted model of Next's compiler, and the round-2 review found a shape the model missed: an encoded space after a line break at the end of a text (`a'\n `), which Next drops and TypeScript keeps. The guard now compiles each JSX text under src/ with Next's SWC and with TypeScript and fails wherever Next shows no whitespace at a place TypeScript does, or renders other characters, so it no longer depends on the model. The rule cases gain the reviewer's shape and still pin the compiler's behavior. SRC now goes through fileURLToPath, so a checkout path with a space works. Each SWC test gets a 60-second limit. Against src/ from before #264 the guard names exactly the five lines #264 fixed; on this head all 207 app tests pass. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Author
|
Round 2 of the independent review (Subfleet job |
This branch was successfully deployed
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.
#264 restored five spaces that Next 16.2.6's compiler dropped from policybench.org, such as "frontier modelson 100 households" on /expand. The branch adds
app/tests/jsxTextSpacing.test.ts, which fails CI on the next such space before it reaches the site.The test compiles every JSX text under
src/with Next's own SWC and with TypeScript, which applies JSX's whitespace rules to the text as written. It fails wherever Next's output has no whitespace at a place TypeScript's has some, or shows other characters. Againstsrc/from before #264 it names the five lines #264 fixed and no others, and it passes on main.Its rule cases pin the shapes Next mishandles, so a compiler upgrade that changes them fails the test too:
) at either end of a text; ) after a line break at the end of a text.A third test compiles the three components #264 fixed and requires a space before each of the five phrases. Bun's transpiler keeps the spaces Next drops, so the page test
expandPage.test.tscannot catch them, and the guard compiles with Next's compiler instead.Lint and
bun test tests(207 pass) pass locally at da20531. No file undersrc/changes.🤖 Generated with Claude Code