[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
This commit is contained in:
mofeiZ
2025-05-08 11:18:16 -04:00
committed by GitHub
parent 9518f11856
commit fbe7bc21b9
4 changed files with 95 additions and 0 deletions

View File

@@ -0,0 +1,30 @@
## Input
```javascript
// @panicThreshold(none)
'use no memo';
function Foo() {
return <button onClick={() => alert('hello!')}>Click me!</button>;
}
```
## Code
```javascript
// @panicThreshold(none)
"use no memo";
function Foo() {
return <button onClick={() => alert("hello!")}>Click me!</button>;
}
function _temp() {
return alert("hello!");
}
```
### Eval output
(kind: exception) Fixture not implemented

View File

@@ -0,0 +1,6 @@
// @panicThreshold(none)
'use no memo';
function Foo() {
return <button onClick={() => alert('hello!')}>Click me!</button>;
}

View File

@@ -0,0 +1,48 @@
## Input
```javascript
// @noEmit
function Foo() {
'use memo';
return <button onClick={() => alert('hello!')}>Click me!</button>;
}
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 = <button onClick={_temp}>Click me!</button>;
$[0] = t0;
} else {
t0 = $[0];
}
return t0;
}
function _temp() {
return alert("hello!");
}
export const FIXTURE_ENTRYPOINT = {
fn: Foo,
params: [],
};
```
### Eval output
(kind: ok) <button>Click me!</button>

View File

@@ -0,0 +1,11 @@
// @noEmit
function Foo() {
'use memo';
return <button onClick={() => alert('hello!')}>Click me!</button>;
}
export const FIXTURE_ENTRYPOINT = {
fn: Foo,
params: [],
};