testJsxLayoutDoesntCountKeptTextDoes
JSX: layout between tags doesn't count, text React keeps does; the runtime is pinned.
import { analyzeTsx, dir, fakeReact } from "#codebase/tcmts/core/test/hash"; import assert from "node:assert/strict"; export const testJsxLayoutDoesntCountKeptTextDoes = () => { fakeReact(dir); const h = (src: string) => Object.fromEntries(analyzeTsx(src).defs.map((d) => [d.nameHint, d.hash])); const one = h(`export function Hi({ name }: { name: string }) { return <p className="hi">Hello, {name}!</p>; }`); const multi = h(`export function Hi({ name: who }: { name: string }) {\n return (\n <p className="hi">\n Hello, {who}!\n </p>\n );\n}`); assert.equal(one.Hi, multi.Hi, "reformatting and renaming a prop binding keep the hash"); assert.notEqual(one.Hi, h(`export function Hi({ name }: { name: string }) { return <p className="hi">Hello, {name}!</p>; }`).Hi, "spaces within a line are kept by React"); assert.notEqual(one.Hi, h(`export function Hi({ name }: { name: string }) { return <div className="hi">Hello, {name}!</div>; }`).Hi, "tags are structural"); assert.notEqual(one.Hi, h(`export function Hi({ name }: { name: string }) { return <p id="hi">Hello, {name}!</p>; }`).Hi, "attribute names are structural"); const d = analyzeTsx(`export function Hi() { return <br />; }`).defs[0]!; // pinned by compatible range: any React 19 assert.equal(d.jsx, "npm:react@19"); assert.match(d.ir, /\["Jsx","npm:react@19"\]/); }