@samitouri / QOS-React-2 / commits / c129c2424b

[compiler][repro] Nested fbt test fixture (#32779)

Ideally we should detect and bail out on this case to avoid babel build failures.

mofeiZ committed May 5, 2025 at 11:52 UTC c129c2424b662a371865a0145c562a1cf934b023
2 files changed +94
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/fbt/error.todo-fbt-param-nested-fbt.expect.md new
+56
@@ -0,0 +1,56 @@
1 +
2 +## Input
3 +
4 +```javascript
5 +import fbt from 'fbt';
6 +import {Stringify} from 'shared-runtime';
7 +
8 +/**
9 + * MemoizeFbtAndMacroOperands needs to account for nested fbt calls.
10 + * Expected fixture `fbt-param-call-arguments` to succeed but it failed with error:
11 + * /fbt-param-call-arguments.ts: Line 19 Column 11: fbt: unsupported babel node: Identifier
12 + * ---
13 + * t3
14 + * ---
15 + */
16 +function Component({firstname, lastname}) {
17 + 'use memo';
18 + return (
19 + <Stringify>
20 + {fbt(
21 + [
22 + 'Name: ',
23 + fbt.param('firstname', <Stringify key={0} name={firstname} />),
24 + ', ',
25 + fbt.param(
26 + 'lastname',
27 + <Stringify key={0} name={lastname}>
28 + {fbt('(inner fbt)', 'Inner fbt value')}
29 + </Stringify>
30 + ),
31 + ],
32 + 'Name'
33 + )}
34 + </Stringify>
35 + );
36 +}
37 +
38 +export const FIXTURE_ENTRYPOINT = {
39 + fn: Component,
40 + params: [{firstname: 'first', lastname: 'last'}],
41 + sequentialRenders: [{firstname: 'first', lastname: 'last'}],
42 +};
43 +
44 +```
45 +
46 +
47 +## Error
48 +
49 +```
50 +Line 19 Column 11: fbt: unsupported babel node: Identifier
51 +---
52 +t3
53 +---
54 +```
55 +
56 +
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/fbt/error.todo-fbt-param-nested-fbt.js new
+38
@@ -0,0 +1,38 @@
1 +import fbt from 'fbt';
2 +import {Stringify} from 'shared-runtime';
3 +
4 +/**
5 + * MemoizeFbtAndMacroOperands needs to account for nested fbt calls.
6 + * Expected fixture `fbt-param-call-arguments` to succeed but it failed with error:
7 + * /fbt-param-call-arguments.ts: Line 19 Column 11: fbt: unsupported babel node: Identifier
8 + * ---
9 + * t3
10 + * ---
11 + */
12 +function Component({firstname, lastname}) {
13 + 'use memo';
14 + return (
15 + <Stringify>
16 + {fbt(
17 + [
18 + 'Name: ',
19 + fbt.param('firstname', <Stringify key={0} name={firstname} />),
20 + ', ',
21 + fbt.param(
22 + 'lastname',
23 + <Stringify key={0} name={lastname}>
24 + {fbt('(inner fbt)', 'Inner fbt value')}
25 + </Stringify>
26 + ),
27 + ],
28 + 'Name'
29 + )}
30 + </Stringify>
31 + );
32 +}
33 +
34 +export const FIXTURE_ENTRYPOINT = {
35 + fn: Component,
36 + params: [{firstname: 'first', lastname: 'last'}],
37 + sequentialRenders: [{firstname: 'first', lastname: 'last'}],
38 +};