dillon1000/react

Commit

Fix FBT whitespace handling (again (again))

Nice find, @mofeiZ! I really tried to thoroughly test all the examples I could 
think of for FBT whitespace but i missed the newline case. Initially Mofei found 
[this code potentially related to whitespace 
handling](https://github.com/facebook/fbt/blob/main/packages/babel-plugin-fbt/src/fbt-nodes/FbtImplicitParamNode.js#L230-L233) 
but Babel never seems to produce consecutive JsxText nodes — this looks like 
maybe a leftover from older babel versions. 

I noticed that code wasn't actually trimming the whitspace but clearly it was 
happening somewhere, so i grepped for 'trim' and found that [this 
code](https://github.com/facebook/fbt/blob/0b4e0d13c30bffd0daa2a75715d606e3587b4e40/packages/babel-plugin-fbt/src/babel-processors/JSXFbtProcessor.js#L143) 
calls a 
[normalizeSpaces](https://github.com/facebook/fbt/blob/0b4e0d13c30bffd0daa2a75715d606e3587b4e40/packages/babel-plugin-fbt/src/FbtUtil.js#L86C10-L86C45) 
helper. Updating our logic to handle whitespace similarly just for children of 
fbt nodes produces the expected result.
Browse files
Changed paths5 files
First-parent comparison
M compiler/packages/babel-plugin-react-forget/src/HIR/BuildHIR.ts ModifiedR compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/bug-fbt-preserve-whitespace.expect.md →compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/fbt-preserve-whitespace.expect.md RenamedR compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/bug-fbt-preserve-whitespace.tsx →compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/fbt-preserve-whitespace.tsx RenamedM compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/fbtparam-with-jsx-element-content.expect.md ModifiedM compiler/packages/sprout/src/SproutTodoFilter.ts Modified
Patch

Files changed

Rendering syntax-highlighted changes…