@samitouri / QOS-React-1 / commits / fbe7bc21b9

[compiler][be] repro edge cases for noEmit and module opt-outs (#33144)

see test fixtures --- [//]: # (BEGIN SAPLING FOOTER) Stack created with [Sapling](https://sapling-scm.com). Best reviewed with [ReviewStack](https://reviewstack.dev/facebook/react/pull/33144). * #33146 * #33145 * __->__ #33144

mofeiZ committed May 8, 2025 at 11:18 UTC fbe7bc21b9aa00afa230132b3f7eee6d2b5c94a7
4 files changed +95
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/repro-bailout-nopanic-shouldnt-outline.expect.md new
+30
@@ -0,0 +1,30 @@
1 +
2 +## Input
3 +
4 +```javascript
5 +// @panicThreshold(none)
6 +'use no memo';
7 +
8 +function Foo() {
9 + return <button onClick={() => alert('hello!')}>Click me!</button>;
10 +}
11 +
12 +```
13 +
14 +## Code
15 +
16 +```javascript
17 +// @panicThreshold(none)
18 +"use no memo";
19 +
20 +function Foo() {
21 + return <button onClick={() => alert("hello!")}>Click me!</button>;
22 +}
23 +function _temp() {
24 + return alert("hello!");
25 +}
26 +
27 +```
28 +
29 +### Eval output
30 +(kind: exception) Fixture not implemented
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/repro-bailout-nopanic-shouldnt-outline.js new
+6
@@ -0,0 +1,6 @@
1 +// @panicThreshold(none)
2 +'use no memo';
3 +
4 +function Foo() {
5 + return <button onClick={() => alert('hello!')}>Click me!</button>;
6 +}
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/use-memo-noemit.expect.md new
+48
@@ -0,0 +1,48 @@
1 +
2 +## Input
3 +
4 +```javascript
5 +// @noEmit
6 +
7 +function Foo() {
8 + 'use memo';
9 + return <button onClick={() => alert('hello!')}>Click me!</button>;
10 +}
11 +
12 +export const FIXTURE_ENTRYPOINT = {
13 + fn: Foo,
14 + params: [],
15 +};
16 +
17 +```
18 +
19 +## Code
20 +
21 +```javascript
22 +import { c as _c } from "react/compiler-runtime"; // @noEmit
23 +
24 +function Foo() {
25 + "use memo";
26 + const $ = _c(1);
27 + let t0;
28 + if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
29 + t0 = <button onClick={_temp}>Click me!</button>;
30 + $[0] = t0;
31 + } else {
32 + t0 = $[0];
33 + }
34 + return t0;
35 +}
36 +function _temp() {
37 + return alert("hello!");
38 +}
39 +
40 +export const FIXTURE_ENTRYPOINT = {
41 + fn: Foo,
42 + params: [],
43 +};
44 +
45 +```
46 +
47 +### Eval output
48 +(kind: ok) <button>Click me!</button>
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/use-memo-noemit.js new
+11
@@ -0,0 +1,11 @@
1 +// @noEmit
2 +
3 +function Foo() {
4 + 'use memo';
5 + return <button onClick={() => alert('hello!')}>Click me!</button>;
6 +}
7 +
8 +export const FIXTURE_ENTRYPOINT = {
9 + fn: Foo,
10 + params: [],
11 +};