From fbe7bc21b9aa00afa230132b3f7eee6d2b5c94a7 Mon Sep 17 00:00:00 2001
From: mofeiZ <34200447+mofeiZ@users.noreply.github.com>
Date: Thu, 8 May 2025 11:18:16 -0400
Subject: [PATCH] [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
---
...bailout-nopanic-shouldnt-outline.expect.md | 30 ++++++++++++
.../repro-bailout-nopanic-shouldnt-outline.js | 6 +++
.../compiler/use-memo-noemit.expect.md | 48 +++++++++++++++++++
.../fixtures/compiler/use-memo-noemit.js | 11 +++++
4 files changed, 95 insertions(+)
create mode 100644 compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/repro-bailout-nopanic-shouldnt-outline.expect.md
create mode 100644 compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/repro-bailout-nopanic-shouldnt-outline.js
create mode 100644 compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/use-memo-noemit.expect.md
create mode 100644 compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/use-memo-noemit.js
diff --git a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/repro-bailout-nopanic-shouldnt-outline.expect.md b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/repro-bailout-nopanic-shouldnt-outline.expect.md
new file mode 100644
index 0000000000..f24d949205
--- /dev/null
+++ b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/repro-bailout-nopanic-shouldnt-outline.expect.md
@@ -0,0 +1,30 @@
+
+## Input
+
+```javascript
+// @panicThreshold(none)
+'use no memo';
+
+function Foo() {
+ return ;
+}
+
+```
+
+## Code
+
+```javascript
+// @panicThreshold(none)
+"use no memo";
+
+function Foo() {
+ return ;
+}
+function _temp() {
+ return alert("hello!");
+}
+
+```
+
+### Eval output
+(kind: exception) Fixture not implemented
\ No newline at end of file
diff --git a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/repro-bailout-nopanic-shouldnt-outline.js b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/repro-bailout-nopanic-shouldnt-outline.js
new file mode 100644
index 0000000000..405295ee4c
--- /dev/null
+++ b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/repro-bailout-nopanic-shouldnt-outline.js
@@ -0,0 +1,6 @@
+// @panicThreshold(none)
+'use no memo';
+
+function Foo() {
+ return ;
+}
diff --git a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/use-memo-noemit.expect.md b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/use-memo-noemit.expect.md
new file mode 100644
index 0000000000..dfc831555f
--- /dev/null
+++ b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/use-memo-noemit.expect.md
@@ -0,0 +1,48 @@
+
+## Input
+
+```javascript
+// @noEmit
+
+function Foo() {
+ 'use memo';
+ return ;
+}
+
+export const FIXTURE_ENTRYPOINT = {
+ fn: Foo,
+ params: [],
+};
+
+```
+
+## Code
+
+```javascript
+import { c as _c } from "react/compiler-runtime"; // @noEmit
+
+function Foo() {
+ "use memo";
+ const $ = _c(1);
+ let t0;
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
+ t0 = ;
+ $[0] = t0;
+ } else {
+ t0 = $[0];
+ }
+ return t0;
+}
+function _temp() {
+ return alert("hello!");
+}
+
+export const FIXTURE_ENTRYPOINT = {
+ fn: Foo,
+ params: [],
+};
+
+```
+
+### Eval output
+(kind: ok)
\ No newline at end of file
diff --git a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/use-memo-noemit.js b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/use-memo-noemit.js
new file mode 100644
index 0000000000..04ec880761
--- /dev/null
+++ b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/use-memo-noemit.js
@@ -0,0 +1,11 @@
+// @noEmit
+
+function Foo() {
+ 'use memo';
+ return ;
+}
+
+export const FIXTURE_ENTRYPOINT = {
+ fn: Foo,
+ params: [],
+};