diff --git a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/call-spread.expect.md b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/call-spread.expect.md index 7a3ddf443f43f..2d7bc3f046e45 100644 --- a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/call-spread.expect.md +++ b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/call-spread.expect.md @@ -2,22 +2,31 @@ ## Input ```javascript +import {makeArray} from 'shared-runtime'; + function Component(props) { - const x = foo(...props.a, null, ...props.b); + const x = makeArray(...props.a, null, ...props.b); return x; } +export const FIXTURE_ENTRYPOINT = { + fn: Component, + params: [{a: [1, 2], b: [2, 3, 4]}], +}; + ``` ## Code ```javascript import { c as _c } from "react/compiler-runtime"; +import { makeArray } from "shared-runtime"; + function Component(props) { const $ = _c(3); let t0; if ($[0] !== props.a || $[1] !== props.b) { - t0 = foo(...props.a, null, ...props.b); + t0 = makeArray(...props.a, null, ...props.b); $[0] = props.a; $[1] = props.b; $[2] = t0; @@ -28,5 +37,12 @@ function Component(props) { return x; } +export const FIXTURE_ENTRYPOINT = { + fn: Component, + params: [{ a: [1, 2], b: [2, 3, 4] }], +}; + ``` - \ No newline at end of file + +### Eval output +(kind: ok) [1,2,null,2,3,4] \ No newline at end of file diff --git a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/call-spread.js b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/call-spread.js index 5e73773bd1d24..8b7767c3bf890 100644 --- a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/call-spread.js +++ b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/call-spread.js @@ -1,4 +1,11 @@ +import {makeArray} from 'shared-runtime'; + function Component(props) { - const x = foo(...props.a, null, ...props.b); + const x = makeArray(...props.a, null, ...props.b); return x; } + +export const FIXTURE_ENTRYPOINT = { + fn: Component, + params: [{a: [1, 2], b: [2, 3, 4]}], +}; diff --git a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-fun-alias-captured-mutate-2.expect.md b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-fun-alias-captured-mutate-2.expect.md index f9ce3f2e98cf5..061e64222eef0 100644 --- a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-fun-alias-captured-mutate-2.expect.md +++ b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-fun-alias-captured-mutate-2.expect.md @@ -2,7 +2,9 @@ ## Input ```javascript -function component(foo, bar) { +import {mutate} from 'shared-runtime'; + +function Component({foo, bar}) { let x = {foo}; let y = {bar}; const f0 = function () { @@ -15,14 +17,28 @@ function component(foo, bar) { return x; } +export const FIXTURE_ENTRYPOINT = { + fn: Component, + params: [{foo: 2, bar: 3}], + sequentialRenders: [ + {foo: 2, bar: 3}, + {foo: 2, bar: 3}, + {foo: 2, bar: 4}, + {foo: 3, bar: 4}, + ], +}; + ``` ## Code ```javascript import { c as _c } from "react/compiler-runtime"; -function component(foo, bar) { +import { mutate } from "shared-runtime"; + +function Component(t0) { const $ = _c(3); + const { foo, bar } = t0; let x; if ($[0] !== bar || $[1] !== foo) { x = { foo }; @@ -44,5 +60,21 @@ function component(foo, bar) { return x; } +export const FIXTURE_ENTRYPOINT = { + fn: Component, + params: [{ foo: 2, bar: 3 }], + sequentialRenders: [ + { foo: 2, bar: 3 }, + { foo: 2, bar: 3 }, + { foo: 2, bar: 4 }, + { foo: 3, bar: 4 }, + ], +}; + ``` - \ No newline at end of file + +### Eval output +(kind: ok) {"foo":2} +{"foo":2} +{"foo":2} +{"foo":3} \ No newline at end of file diff --git a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-fun-alias-captured-mutate-2.js b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-fun-alias-captured-mutate-2.js index a83acfcdb0e46..8579e8c4943f6 100644 --- a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-fun-alias-captured-mutate-2.js +++ b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-fun-alias-captured-mutate-2.js @@ -1,4 +1,6 @@ -function component(foo, bar) { +import {mutate} from 'shared-runtime'; + +function Component({foo, bar}) { let x = {foo}; let y = {bar}; const f0 = function () { @@ -10,3 +12,14 @@ function component(foo, bar) { mutate(y); return x; } + +export const FIXTURE_ENTRYPOINT = { + fn: Component, + params: [{foo: 2, bar: 3}], + sequentialRenders: [ + {foo: 2, bar: 3}, + {foo: 2, bar: 3}, + {foo: 2, bar: 4}, + {foo: 3, bar: 4}, + ], +}; diff --git a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-fun-alias-captured-mutate-arr-2.expect.md b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-fun-alias-captured-mutate-arr-2.expect.md index 38590d1559bb5..fb44f2c7b8f24 100644 --- a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-fun-alias-captured-mutate-arr-2.expect.md +++ b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-fun-alias-captured-mutate-arr-2.expect.md @@ -2,7 +2,9 @@ ## Input ```javascript -function component(foo, bar) { +import {mutate} from 'shared-runtime'; + +function Component({foo, bar}) { let x = {foo}; let y = {bar}; const f0 = function () { @@ -15,14 +17,28 @@ function component(foo, bar) { return x; } +export const FIXTURE_ENTRYPOINT = { + fn: Component, + params: [{foo: 2, bar: 3}], + sequentialRenders: [ + {foo: 2, bar: 3}, + {foo: 2, bar: 3}, + {foo: 2, bar: 4}, + {foo: 3, bar: 4}, + ], +}; + ``` ## Code ```javascript import { c as _c } from "react/compiler-runtime"; -function component(foo, bar) { +import { mutate } from "shared-runtime"; + +function Component(t0) { const $ = _c(3); + const { foo, bar } = t0; let x; if ($[0] !== bar || $[1] !== foo) { x = { foo }; @@ -44,5 +60,21 @@ function component(foo, bar) { return x; } +export const FIXTURE_ENTRYPOINT = { + fn: Component, + params: [{ foo: 2, bar: 3 }], + sequentialRenders: [ + { foo: 2, bar: 3 }, + { foo: 2, bar: 3 }, + { foo: 2, bar: 4 }, + { foo: 3, bar: 4 }, + ], +}; + ``` - \ No newline at end of file + +### Eval output +(kind: ok) {"foo":2} +{"foo":2} +{"foo":2} +{"foo":3} \ No newline at end of file diff --git a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-fun-alias-captured-mutate-arr-2.js b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-fun-alias-captured-mutate-arr-2.js index 2a30bfbce197d..24dddd4910e08 100644 --- a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-fun-alias-captured-mutate-arr-2.js +++ b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-fun-alias-captured-mutate-arr-2.js @@ -1,4 +1,6 @@ -function component(foo, bar) { +import {mutate} from 'shared-runtime'; + +function Component({foo, bar}) { let x = {foo}; let y = {bar}; const f0 = function () { @@ -10,3 +12,14 @@ function component(foo, bar) { mutate(y); return x; } + +export const FIXTURE_ENTRYPOINT = { + fn: Component, + params: [{foo: 2, bar: 3}], + sequentialRenders: [ + {foo: 2, bar: 3}, + {foo: 2, bar: 3}, + {foo: 2, bar: 4}, + {foo: 3, bar: 4}, + ], +}; diff --git a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-func-alias-captured-mutate-arr.expect.md b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-func-alias-captured-mutate-arr.expect.md index 7c94c33e495a8..e9cb3c4fd145b 100644 --- a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-func-alias-captured-mutate-arr.expect.md +++ b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-func-alias-captured-mutate-arr.expect.md @@ -2,7 +2,8 @@ ## Input ```javascript -function component(foo, bar) { +import {mutate} from 'shared-runtime'; +function Component({foo, bar}) { let x = {foo}; let y = {bar}; const f0 = function () { @@ -15,14 +16,27 @@ function component(foo, bar) { return y; } +export const FIXTURE_ENTRYPOINT = { + fn: Component, + params: [{foo: 2, bar: 3}], + sequentialRenders: [ + {foo: 2, bar: 3}, + {foo: 2, bar: 3}, + {foo: 2, bar: 4}, + {foo: 3, bar: 4}, + ], +}; + ``` ## Code ```javascript import { c as _c } from "react/compiler-runtime"; -function component(foo, bar) { +import { mutate } from "shared-runtime"; +function Component(t0) { const $ = _c(3); + const { foo, bar } = t0; let y; if ($[0] !== bar || $[1] !== foo) { const x = { foo }; @@ -44,5 +58,21 @@ function component(foo, bar) { return y; } +export const FIXTURE_ENTRYPOINT = { + fn: Component, + params: [{ foo: 2, bar: 3 }], + sequentialRenders: [ + { foo: 2, bar: 3 }, + { foo: 2, bar: 3 }, + { foo: 2, bar: 4 }, + { foo: 3, bar: 4 }, + ], +}; + ``` - \ No newline at end of file + +### Eval output +(kind: ok) {"bar":3,"wat0":"joe"} +{"bar":3,"wat0":"joe"} +{"bar":4,"wat0":"joe"} +{"bar":4,"wat0":"joe"} \ No newline at end of file diff --git a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-func-alias-captured-mutate-arr.js b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-func-alias-captured-mutate-arr.js index 5b7665498dfd6..f757078e73266 100644 --- a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-func-alias-captured-mutate-arr.js +++ b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-func-alias-captured-mutate-arr.js @@ -1,4 +1,5 @@ -function component(foo, bar) { +import {mutate} from 'shared-runtime'; +function Component({foo, bar}) { let x = {foo}; let y = {bar}; const f0 = function () { @@ -10,3 +11,14 @@ function component(foo, bar) { mutate(y); return y; } + +export const FIXTURE_ENTRYPOINT = { + fn: Component, + params: [{foo: 2, bar: 3}], + sequentialRenders: [ + {foo: 2, bar: 3}, + {foo: 2, bar: 3}, + {foo: 2, bar: 4}, + {foo: 3, bar: 4}, + ], +}; diff --git a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-func-alias-computed-mutate.expect.md b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-func-alias-computed-mutate.expect.md index 1a561453a915e..513718ba8606b 100644 --- a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-func-alias-computed-mutate.expect.md +++ b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-func-alias-computed-mutate.expect.md @@ -2,7 +2,8 @@ ## Input ```javascript -function component(a) { +import {mutate} from 'shared-runtime'; +function Component({a}) { let x = {a}; let y = {}; const f0 = function () { @@ -13,14 +14,22 @@ function component(a) { return y; } +export const FIXTURE_ENTRYPOINT = { + fn: Component, + params: [{a: 2}], + sequentialRenders: [{a: 2}, {a: 2}, {a: 3}], +}; + ``` ## Code ```javascript import { c as _c } from "react/compiler-runtime"; -function component(a) { +import { mutate } from "shared-runtime"; +function Component(t0) { const $ = _c(2); + const { a } = t0; let y; if ($[0] !== a) { const x = { a }; @@ -39,5 +48,15 @@ function component(a) { return y; } +export const FIXTURE_ENTRYPOINT = { + fn: Component, + params: [{ a: 2 }], + sequentialRenders: [{ a: 2 }, { a: 2 }, { a: 3 }], +}; + ``` - \ No newline at end of file + +### Eval output +(kind: ok) {"x":{"a":2},"wat0":"joe"} +{"x":{"a":2},"wat0":"joe"} +{"x":{"a":3},"wat0":"joe"} \ No newline at end of file diff --git a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-func-alias-computed-mutate.js b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-func-alias-computed-mutate.js index a66039c9ad283..daa4fffb28df8 100644 --- a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-func-alias-computed-mutate.js +++ b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-func-alias-computed-mutate.js @@ -1,4 +1,5 @@ -function component(a) { +import {mutate} from 'shared-runtime'; +function Component({a}) { let x = {a}; let y = {}; const f0 = function () { @@ -8,3 +9,9 @@ function component(a) { mutate(y); return y; } + +export const FIXTURE_ENTRYPOINT = { + fn: Component, + params: [{a: 2}], + sequentialRenders: [{a: 2}, {a: 2}, {a: 3}], +}; diff --git a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-func-alias-mutate.expect.md b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-func-alias-mutate.expect.md index 386cbec42db64..ae145f4d9e2eb 100644 --- a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-func-alias-mutate.expect.md +++ b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-func-alias-mutate.expect.md @@ -2,7 +2,8 @@ ## Input ```javascript -function component(a) { +import {mutate} from 'shared-runtime'; +function Component({a}) { let x = {a}; let y = {}; const f0 = function () { @@ -13,14 +14,22 @@ function component(a) { return y; } +export const FIXTURE_ENTRYPOINT = { + fn: Component, + params: [{a: 2}], + sequentialRenders: [{a: 2}, {a: 2}, {a: 3}], +}; + ``` ## Code ```javascript import { c as _c } from "react/compiler-runtime"; -function component(a) { +import { mutate } from "shared-runtime"; +function Component(t0) { const $ = _c(2); + const { a } = t0; let y; if ($[0] !== a) { const x = { a }; @@ -39,5 +48,15 @@ function component(a) { return y; } +export const FIXTURE_ENTRYPOINT = { + fn: Component, + params: [{ a: 2 }], + sequentialRenders: [{ a: 2 }, { a: 2 }, { a: 3 }], +}; + ``` - \ No newline at end of file + +### Eval output +(kind: ok) {"x":{"a":2},"wat0":"joe"} +{"x":{"a":2},"wat0":"joe"} +{"x":{"a":3},"wat0":"joe"} \ No newline at end of file diff --git a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-func-alias-mutate.js b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-func-alias-mutate.js index f528a8c02bc9a..524dc8af35601 100644 --- a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-func-alias-mutate.js +++ b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-func-alias-mutate.js @@ -1,4 +1,5 @@ -function component(a) { +import {mutate} from 'shared-runtime'; +function Component({a}) { let x = {a}; let y = {}; const f0 = function () { @@ -8,3 +9,9 @@ function component(a) { mutate(y); return y; } + +export const FIXTURE_ENTRYPOINT = { + fn: Component, + params: [{a: 2}], + sequentialRenders: [{a: 2}, {a: 2}, {a: 3}], +}; diff --git a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-func-alias-receiver-computed-mutate.expect.md b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-func-alias-receiver-computed-mutate.expect.md index 90df65c6ae425..d65e9cca92740 100644 --- a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-func-alias-receiver-computed-mutate.expect.md +++ b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-func-alias-receiver-computed-mutate.expect.md @@ -2,7 +2,9 @@ ## Input ```javascript -function component(a) { +import {mutate} from 'shared-runtime'; + +function Component({a}) { let x = {a}; let y = {}; const f0 = function () { @@ -14,14 +16,23 @@ function component(a) { return y; } +export const FIXTURE_ENTRYPOINT = { + fn: Component, + params: [{a: 2}], + sequentialRenders: [{a: 2}, {a: 2}, {a: 3}], +}; + ``` ## Code ```javascript import { c as _c } from "react/compiler-runtime"; -function component(a) { +import { mutate } from "shared-runtime"; + +function Component(t0) { const $ = _c(2); + const { a } = t0; let y; if ($[0] !== a) { const x = { a }; @@ -41,5 +52,15 @@ function component(a) { return y; } +export const FIXTURE_ENTRYPOINT = { + fn: Component, + params: [{ a: 2 }], + sequentialRenders: [{ a: 2 }, { a: 2 }, { a: 3 }], +}; + ``` - \ No newline at end of file + +### Eval output +(kind: ok) {"x":{"a":2},"wat0":"joe"} +{"x":{"a":2},"wat0":"joe"} +{"x":{"a":3},"wat0":"joe"} \ No newline at end of file diff --git a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-func-alias-receiver-computed-mutate.js b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-func-alias-receiver-computed-mutate.js index d0a1f62320605..b4f645846c5be 100644 --- a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-func-alias-receiver-computed-mutate.js +++ b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-func-alias-receiver-computed-mutate.js @@ -1,4 +1,6 @@ -function component(a) { +import {mutate} from 'shared-runtime'; + +function Component({a}) { let x = {a}; let y = {}; const f0 = function () { @@ -9,3 +11,9 @@ function component(a) { mutate(y); return y; } + +export const FIXTURE_ENTRYPOINT = { + fn: Component, + params: [{a: 2}], + sequentialRenders: [{a: 2}, {a: 2}, {a: 3}], +}; diff --git a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-func-alias-receiver-mutate.expect.md b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-func-alias-receiver-mutate.expect.md index e26f048efba9a..deb78c79e08ed 100644 --- a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-func-alias-receiver-mutate.expect.md +++ b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-func-alias-receiver-mutate.expect.md @@ -2,7 +2,9 @@ ## Input ```javascript -function component(a) { +import {mutate} from 'shared-runtime'; + +function Component({a}) { let x = {a}; let y = {}; const f0 = function () { @@ -14,14 +16,23 @@ function component(a) { return y; } +export const FIXTURE_ENTRYPOINT = { + fn: Component, + params: [{a: 2}], + sequentialRenders: [{a: 2}, {a: 2}, {a: 3}], +}; + ``` ## Code ```javascript import { c as _c } from "react/compiler-runtime"; -function component(a) { +import { mutate } from "shared-runtime"; + +function Component(t0) { const $ = _c(2); + const { a } = t0; let y; if ($[0] !== a) { const x = { a }; @@ -41,5 +52,15 @@ function component(a) { return y; } +export const FIXTURE_ENTRYPOINT = { + fn: Component, + params: [{ a: 2 }], + sequentialRenders: [{ a: 2 }, { a: 2 }, { a: 3 }], +}; + ``` - \ No newline at end of file + +### Eval output +(kind: ok) {"x":{"a":2},"wat0":"joe"} +{"x":{"a":2},"wat0":"joe"} +{"x":{"a":3},"wat0":"joe"} \ No newline at end of file diff --git a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-func-alias-receiver-mutate.js b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-func-alias-receiver-mutate.js index e34a03ec87742..a82df6b27fff8 100644 --- a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-func-alias-receiver-mutate.js +++ b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-func-alias-receiver-mutate.js @@ -1,4 +1,6 @@ -function component(a) { +import {mutate} from 'shared-runtime'; + +function Component({a}) { let x = {a}; let y = {}; const f0 = function () { @@ -9,3 +11,9 @@ function component(a) { mutate(y); return y; } + +export const FIXTURE_ENTRYPOINT = { + fn: Component, + params: [{a: 2}], + sequentialRenders: [{a: 2}, {a: 2}, {a: 3}], +}; diff --git a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-func-simple-alias.expect.md b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-func-simple-alias.expect.md index bdee721b5820e..0e2d77023996a 100644 --- a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-func-simple-alias.expect.md +++ b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-func-simple-alias.expect.md @@ -2,7 +2,9 @@ ## Input ```javascript -function component(a) { +import {mutate} from 'shared-runtime'; + +function Component({a}) { let x = {a}; let y = {}; const f0 = function () { @@ -13,14 +15,23 @@ function component(a) { return y; } +export const FIXTURE_ENTRYPOINT = { + fn: Component, + params: [{a: 2}], + sequentialRenders: [{a: 2}, {a: 2}, {a: 3}], +}; + ``` ## Code ```javascript import { c as _c } from "react/compiler-runtime"; -function component(a) { +import { mutate } from "shared-runtime"; + +function Component(t0) { const $ = _c(2); + const { a } = t0; let y; if ($[0] !== a) { const x = { a }; @@ -39,5 +50,15 @@ function component(a) { return y; } +export const FIXTURE_ENTRYPOINT = { + fn: Component, + params: [{ a: 2 }], + sequentialRenders: [{ a: 2 }, { a: 2 }, { a: 3 }], +}; + ``` - \ No newline at end of file + +### Eval output +(kind: ok) {"a":2,"wat0":"joe"} +{"a":2,"wat0":"joe"} +{"a":3,"wat0":"joe"} \ No newline at end of file diff --git a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-func-simple-alias.js b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-func-simple-alias.js index 39e87de8c089d..22764fec72e6e 100644 --- a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-func-simple-alias.js +++ b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-func-simple-alias.js @@ -1,4 +1,6 @@ -function component(a) { +import {mutate} from 'shared-runtime'; + +function Component({a}) { let x = {a}; let y = {}; const f0 = function () { @@ -8,3 +10,9 @@ function component(a) { mutate(y); return y; } + +export const FIXTURE_ENTRYPOINT = { + fn: Component, + params: [{a: 2}], + sequentialRenders: [{a: 2}, {a: 2}, {a: 3}], +}; diff --git a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-function-capture-ref-before-rename.expect.md b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-function-capture-ref-before-rename.expect.md index 4087dc53c98f2..6364e83deb9a2 100644 --- a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-function-capture-ref-before-rename.expect.md +++ b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-function-capture-ref-before-rename.expect.md @@ -2,7 +2,9 @@ ## Input ```javascript -function component(a, b) { +import {mutate} from 'shared-runtime'; + +function Component({a, b}) { let z = {a}; (function () { mutate(z); @@ -17,14 +19,28 @@ function component(a, b) { return y; } +export const FIXTURE_ENTRYPOINT = { + fn: Component, + params: [{a: 2, b: 3}], + sequentialRenders: [ + {a: 2, b: 3}, + {a: 2, b: 3}, + {a: 2, b: 4}, + {a: 3, b: 4}, + ], +}; + ``` ## Code ```javascript import { c as _c } from "react/compiler-runtime"; -function component(a, b) { +import { mutate } from "shared-runtime"; + +function Component(t0) { const $ = _c(7); + const { a, b } = t0; let z; if ($[0] !== a) { z = { a }; @@ -37,27 +53,43 @@ function component(a, b) { } let y = z; - let t0; + let t1; if ($[2] !== b) { - t0 = { b }; + t1 = { b }; $[2] = b; - $[3] = t0; + $[3] = t1; } else { - t0 = $[3]; + t1 = $[3]; } - const z_0 = t0; - let t1; + const z_0 = t1; + let t2; if ($[4] !== y || $[5] !== z_0) { - t1 = { y, z: z_0 }; + t2 = { y, z: z_0 }; $[4] = y; $[5] = z_0; - $[6] = t1; + $[6] = t2; } else { - t1 = $[6]; + t2 = $[6]; } - y = t1; + y = t2; return y; } +export const FIXTURE_ENTRYPOINT = { + fn: Component, + params: [{ a: 2, b: 3 }], + sequentialRenders: [ + { a: 2, b: 3 }, + { a: 2, b: 3 }, + { a: 2, b: 4 }, + { a: 3, b: 4 }, + ], +}; + ``` - \ No newline at end of file + +### Eval output +(kind: ok) {"y":{"a":2,"wat0":"joe"},"z":{"b":3}} +{"y":{"a":2,"wat0":"joe"},"z":{"b":3}} +{"y":{"a":2,"wat0":"joe"},"z":{"b":4}} +{"y":{"a":3,"wat0":"joe"},"z":{"b":4}} \ No newline at end of file diff --git a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-function-capture-ref-before-rename.js b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-function-capture-ref-before-rename.js index ad1a1f03c105c..b13e563ea820f 100644 --- a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-function-capture-ref-before-rename.js +++ b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-function-capture-ref-before-rename.js @@ -1,4 +1,6 @@ -function component(a, b) { +import {mutate} from 'shared-runtime'; + +function Component({a, b}) { let z = {a}; (function () { mutate(z); @@ -12,3 +14,14 @@ function component(a, b) { } return y; } + +export const FIXTURE_ENTRYPOINT = { + fn: Component, + params: [{a: 2, b: 3}], + sequentialRenders: [ + {a: 2, b: 3}, + {a: 2, b: 3}, + {a: 2, b: 4}, + {a: 3, b: 4}, + ], +}; diff --git a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-function-conditional-capture-mutate.expect.md b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-function-conditional-capture-mutate.expect.md index 2f827d699a90c..c42aa4c48c5fd 100644 --- a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-function-conditional-capture-mutate.expect.md +++ b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-function-conditional-capture-mutate.expect.md @@ -2,8 +2,7 @@ ## Input ```javascript -// @debug -function component(a, b) { +function useHook(a, b) { let z = {a}; let y = b; let x = function () { @@ -22,8 +21,8 @@ function component(a, b) { ## Code ```javascript -import { c as _c } from "react/compiler-runtime"; // @debug -function component(a, b) { +import { c as _c } from "react/compiler-runtime"; +function useHook(a, b) { const $ = _c(5); let t0; if ($[0] !== a) { diff --git a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-function-conditional-capture-mutate.js b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-function-conditional-capture-mutate.js index 3a1a7d0d297a8..04d6ca29e1fea 100644 --- a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-function-conditional-capture-mutate.js +++ b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-function-conditional-capture-mutate.js @@ -1,5 +1,4 @@ -// @debug -function component(a, b) { +function useHook(a, b) { let z = {a}; let y = b; let x = function () { diff --git a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-function-renamed-ref.expect.md b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-function-renamed-ref.expect.md index edc6fb6d6cba4..034e9781b2356 100644 --- a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-function-renamed-ref.expect.md +++ b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-function-renamed-ref.expect.md @@ -2,7 +2,9 @@ ## Input ```javascript -function component(a, b) { +import {mutate} from 'shared-runtime'; + +function useHook({a, b}) { let z = {a}; { let z = {b}; @@ -13,23 +15,37 @@ function component(a, b) { return z; } +export const FIXTURE_ENTRYPOINT = { + fn: useHook, + params: [{a: 2, b: 3}], + sequentialRenders: [ + {a: 2, b: 3}, + {a: 2, b: 3}, + {a: 2, b: 4}, + {a: 3, b: 4}, + ], +}; + ``` ## Code ```javascript import { c as _c } from "react/compiler-runtime"; -function component(a, b) { +import { mutate } from "shared-runtime"; + +function useHook(t0) { const $ = _c(2); - let t0; + const { a, b } = t0; + let t1; if ($[0] !== a) { - t0 = { a }; + t1 = { a }; $[0] = a; - $[1] = t0; + $[1] = t1; } else { - t0 = $[1]; + t1 = $[1]; } - const z = t0; + const z = t1; const z_0 = { b }; @@ -37,5 +53,21 @@ function component(a, b) { return z; } +export const FIXTURE_ENTRYPOINT = { + fn: useHook, + params: [{ a: 2, b: 3 }], + sequentialRenders: [ + { a: 2, b: 3 }, + { a: 2, b: 3 }, + { a: 2, b: 4 }, + { a: 3, b: 4 }, + ], +}; + ``` - \ No newline at end of file + +### Eval output +(kind: ok) {"a":2} +{"a":2} +{"a":2} +{"a":3} \ No newline at end of file diff --git a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-function-renamed-ref.js b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-function-renamed-ref.js index 1022a8604ab9c..49595f19d7e6f 100644 --- a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-function-renamed-ref.js +++ b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-function-renamed-ref.js @@ -1,4 +1,6 @@ -function component(a, b) { +import {mutate} from 'shared-runtime'; + +function useHook({a, b}) { let z = {a}; { let z = {b}; @@ -8,3 +10,14 @@ function component(a, b) { } return z; } + +export const FIXTURE_ENTRYPOINT = { + fn: useHook, + params: [{a: 2, b: 3}], + sequentialRenders: [ + {a: 2, b: 3}, + {a: 2, b: 3}, + {a: 2, b: 4}, + {a: 3, b: 4}, + ], +}; diff --git a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-function-runs-inference.expect.md b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-function-runs-inference.expect.md index 344b9439078ca..dc0961c61264c 100644 --- a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-function-runs-inference.expect.md +++ b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-function-runs-inference.expect.md @@ -2,11 +2,17 @@ ## Input ```javascript -function component(a, b) { +import {Stringify} from 'shared-runtime'; +function Component({a, b}) { let z = {a}; - let p = () => {z}; + let p = () => {z}; return p(); } +export const FIXTURE_ENTRYPOINT = { + fn: Component, + params: [{a: 1}], + sequentialRenders: [{a: 1}, {a: 1}, {a: 2}], +}; ``` @@ -14,36 +20,48 @@ function component(a, b) { ```javascript import { c as _c } from "react/compiler-runtime"; -function component(a, b) { +import { Stringify } from "shared-runtime"; +function Component(t0) { const $ = _c(6); - let t0; + const { a } = t0; + let t1; if ($[0] !== a) { - t0 = { a }; + t1 = { a }; $[0] = a; - $[1] = t0; + $[1] = t1; } else { - t0 = $[1]; + t1 = $[1]; } - const z = t0; - let t1; + const z = t1; + let t2; if ($[2] !== z) { - t1 = () => {z}; + t2 = () => {z}; $[2] = z; - $[3] = t1; + $[3] = t2; } else { - t1 = $[3]; + t2 = $[3]; } - const p = t1; - let t2; + const p = t2; + let t3; if ($[4] !== p) { - t2 = p(); + t3 = p(); $[4] = p; - $[5] = t2; + $[5] = t3; } else { - t2 = $[5]; + t3 = $[5]; } - return t2; + return t3; } +export const FIXTURE_ENTRYPOINT = { + fn: Component, + params: [{ a: 1 }], + sequentialRenders: [{ a: 1 }, { a: 1 }, { a: 2 }], +}; + ``` - \ No newline at end of file + +### Eval output +(kind: ok)
{"children":{"a":1}}
+
{"children":{"a":1}}
+
{"children":{"a":2}}
\ No newline at end of file diff --git a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-function-runs-inference.js b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-function-runs-inference.js index c4335e757feac..d5a4bb842f96c 100644 --- a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-function-runs-inference.js +++ b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-function-runs-inference.js @@ -1,5 +1,11 @@ -function component(a, b) { +import {Stringify} from 'shared-runtime'; +function Component({a, b}) { let z = {a}; - let p = () => {z}; + let p = () => {z}; return p(); } +export const FIXTURE_ENTRYPOINT = { + fn: Component, + params: [{a: 1}], + sequentialRenders: [{a: 1}, {a: 1}, {a: 2}], +}; diff --git a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-function-shadow-captured.expect.md b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-function-shadow-captured.expect.md index 82012899616cd..d409bd32965f9 100644 --- a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-function-shadow-captured.expect.md +++ b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-function-shadow-captured.expect.md @@ -2,28 +2,58 @@ ## Input ```javascript -function component(a) { +import {mutate, Stringify} from 'shared-runtime'; +function Component({a}) { let z = {a}; let x = function () { let z; mutate(z); + return z; }; - return x; + return ; } +export const FIXTURE_ENTRYPOINT = { + fn: Component, + params: [{a: 1}], + sequentialRenders: [{a: 1}, {a: 1}, {a: 2}], +}; + ``` ## Code ```javascript -function component(a) { +import { c as _c } from "react/compiler-runtime"; +import { mutate, Stringify } from "shared-runtime"; +function Component(t0) { + const $ = _c(1); + const x = _temp; - return x; + let t1; + if ($[0] === Symbol.for("react.memo_cache_sentinel")) { + t1 = ; + $[0] = t1; + } else { + t1 = $[0]; + } + return t1; } function _temp() { let z_0; mutate(z_0); + return z_0; } +export const FIXTURE_ENTRYPOINT = { + fn: Component, + params: [{ a: 1 }], + sequentialRenders: [{ a: 1 }, { a: 1 }, { a: 2 }], +}; + ``` - \ No newline at end of file + +### Eval output +(kind: ok)
{"fn":{"kind":"Function"},"shouldInvokeFns":true}
+
{"fn":{"kind":"Function"},"shouldInvokeFns":true}
+
{"fn":{"kind":"Function"},"shouldInvokeFns":true}
\ No newline at end of file diff --git a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-function-shadow-captured.js b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-function-shadow-captured.js index 0361ef08bb13e..a0ce67e4d00b6 100644 --- a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-function-shadow-captured.js +++ b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-function-shadow-captured.js @@ -1,8 +1,16 @@ -function component(a) { +import {mutate, Stringify} from 'shared-runtime'; +function Component({a}) { let z = {a}; let x = function () { let z; mutate(z); + return z; }; - return x; + return ; } + +export const FIXTURE_ENTRYPOINT = { + fn: Component, + params: [{a: 1}], + sequentialRenders: [{a: 1}, {a: 1}, {a: 2}], +}; diff --git a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-reference-changes-type.expect.md b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-reference-changes-type.expect.md index 299aa5a31dff2..f5d4b94ae5410 100644 --- a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-reference-changes-type.expect.md +++ b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-reference-changes-type.expect.md @@ -2,7 +2,8 @@ ## Input ```javascript -function component(a) { +import {mutate} from 'shared-runtime'; +function Component({a}) { let x = {a}; let y = 1; (function () { @@ -12,14 +13,22 @@ function component(a) { return y; } +export const FIXTURE_ENTRYPOINT = { + fn: Component, + params: [{a: 2}], + sequentialRenders: [{a: 2}, {a: 2}, {a: 3}], +}; + ``` ## Code ```javascript import { c as _c } from "react/compiler-runtime"; -function component(a) { +import { mutate } from "shared-runtime"; +function Component(t0) { const $ = _c(2); + const { a } = t0; let y; if ($[0] !== a) { const x = { a }; @@ -36,5 +45,15 @@ function component(a) { return y; } +export const FIXTURE_ENTRYPOINT = { + fn: Component, + params: [{ a: 2 }], + sequentialRenders: [{ a: 2 }, { a: 2 }, { a: 3 }], +}; + ``` - \ No newline at end of file + +### Eval output +(kind: ok) {"a":2,"wat0":"joe"} +{"a":2,"wat0":"joe"} +{"a":3,"wat0":"joe"} \ No newline at end of file diff --git a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-reference-changes-type.js b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-reference-changes-type.js index 0a454b19b45e7..2b4b1b47ecc31 100644 --- a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-reference-changes-type.js +++ b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/capturing-reference-changes-type.js @@ -1,4 +1,5 @@ -function component(a) { +import {mutate} from 'shared-runtime'; +function Component({a}) { let x = {a}; let y = 1; (function () { @@ -7,3 +8,9 @@ function component(a) { mutate(y); return y; } + +export const FIXTURE_ENTRYPOINT = { + fn: Component, + params: [{a: 2}], + sequentialRenders: [{a: 2}, {a: 2}, {a: 3}], +}; diff --git a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/computed-store-alias.expect.md b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/computed-store-alias.expect.md index 6d8782f74b50c..9af46bbfd9889 100644 --- a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/computed-store-alias.expect.md +++ b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/computed-store-alias.expect.md @@ -2,7 +2,8 @@ ## Input ```javascript -function component(a, b) { +import {mutate} from 'shared-runtime'; +function useHook({a, b}) { let y = {a}; let x = {b}; x['y'] = y; @@ -10,14 +11,26 @@ function component(a, b) { return x; } +export const FIXTURE_ENTRYPOINT = { + fn: useHook, + params: [{a: 2, b: 3}], + sequentialRenders: [ + {a: 2, b: 3}, + {a: 2, b: 3}, + {a: 3, b: 3}, + ], +}; + ``` ## Code ```javascript import { c as _c } from "react/compiler-runtime"; -function component(a, b) { +import { mutate } from "shared-runtime"; +function useHook(t0) { const $ = _c(3); + const { a, b } = t0; let x; if ($[0] !== a || $[1] !== b) { const y = { a }; @@ -33,5 +46,19 @@ function component(a, b) { return x; } +export const FIXTURE_ENTRYPOINT = { + fn: useHook, + params: [{ a: 2, b: 3 }], + sequentialRenders: [ + { a: 2, b: 3 }, + { a: 2, b: 3 }, + { a: 3, b: 3 }, + ], +}; + ``` - \ No newline at end of file + +### Eval output +(kind: ok) {"b":3,"y":{"a":2},"wat0":"joe"} +{"b":3,"y":{"a":2},"wat0":"joe"} +{"b":3,"y":{"a":3},"wat0":"joe"} \ No newline at end of file diff --git a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/computed-store-alias.js b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/computed-store-alias.js index e28a2c0928c04..85d0c398bcffc 100644 --- a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/computed-store-alias.js +++ b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/computed-store-alias.js @@ -1,7 +1,18 @@ -function component(a, b) { +import {mutate} from 'shared-runtime'; +function useHook({a, b}) { let y = {a}; let x = {b}; x['y'] = y; mutate(x); return x; } + +export const FIXTURE_ENTRYPOINT = { + fn: useHook, + params: [{a: 2, b: 3}], + sequentialRenders: [ + {a: 2, b: 3}, + {a: 2, b: 3}, + {a: 3, b: 3}, + ], +}; diff --git a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/constant-propagation-into-function-expressions.expect.md b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/constant-propagation-into-function-expressions.expect.md index 8822eddcdb69f..503ee6d716813 100644 --- a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/constant-propagation-into-function-expressions.expect.md +++ b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/constant-propagation-into-function-expressions.expect.md @@ -2,27 +2,37 @@ ## Input ```javascript +import {Stringify, identity} from 'shared-runtime'; + function Component(props) { const x = 42; const onEvent = () => { - console.log(x); + return identity(x); }; - return ; + return ; } +export const FIXTURE_ENTRYPOINT = { + fn: Component, + params: [{}], + sequentialRenders: [{}, {}], +}; + ``` ## Code ```javascript import { c as _c } from "react/compiler-runtime"; +import { Stringify, identity } from "shared-runtime"; + function Component(props) { const $ = _c(1); const onEvent = _temp; let t0; if ($[0] === Symbol.for("react.memo_cache_sentinel")) { - t0 = ; + t0 = ; $[0] = t0; } else { t0 = $[0]; @@ -30,8 +40,17 @@ function Component(props) { return t0; } function _temp() { - console.log(42); + return identity(42); } +export const FIXTURE_ENTRYPOINT = { + fn: Component, + params: [{}], + sequentialRenders: [{}, {}], +}; + ``` - \ No newline at end of file + +### Eval output +(kind: ok)
{"onEvent":{"kind":"Function","result":42},"shouldInvokeFns":true}
+
{"onEvent":{"kind":"Function","result":42},"shouldInvokeFns":true}
\ No newline at end of file diff --git a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/constant-propagation-into-function-expressions.js b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/constant-propagation-into-function-expressions.js index c98bd9b670056..d1df503ad9736 100644 --- a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/constant-propagation-into-function-expressions.js +++ b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/constant-propagation-into-function-expressions.js @@ -1,7 +1,15 @@ +import {Stringify, identity} from 'shared-runtime'; + function Component(props) { const x = 42; const onEvent = () => { - console.log(x); + return identity(x); }; - return ; + return ; } + +export const FIXTURE_ENTRYPOINT = { + fn: Component, + params: [{}], + sequentialRenders: [{}, {}], +}; diff --git a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/bug-invalid-hoisting-functionexpr.expect.md b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/hoisting-functionexpr-conditional-dep.expect.md similarity index 95% rename from compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/bug-invalid-hoisting-functionexpr.expect.md rename to compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/hoisting-functionexpr-conditional-dep.expect.md index d6331db4e7ea3..e99e9e1c80226 100644 --- a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/bug-invalid-hoisting-functionexpr.expect.md +++ b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/hoisting-functionexpr-conditional-dep.expect.md @@ -90,4 +90,6 @@ export const FIXTURE_ENTRYPOINT = { }; ``` - \ No newline at end of file + +### Eval output +(kind: ok)
{"shouldInvokeFns":true,"callback":{"kind":"Function","result":null}}
\ No newline at end of file diff --git a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/bug-invalid-hoisting-functionexpr.tsx b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/hoisting-functionexpr-conditional-dep.tsx similarity index 100% rename from compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/bug-invalid-hoisting-functionexpr.tsx rename to compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/hoisting-functionexpr-conditional-dep.tsx diff --git a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/reduce-reactive-deps/bug-merge-uncond-optional-chain-and-cond.expect.md b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/reduce-reactive-deps/edge-case-merge-uncond-optional-chain-and-cond.expect.md similarity index 94% rename from compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/reduce-reactive-deps/bug-merge-uncond-optional-chain-and-cond.expect.md rename to compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/reduce-reactive-deps/edge-case-merge-uncond-optional-chain-and-cond.expect.md index fa265ae1f8d74..d9361bee322e3 100644 --- a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/reduce-reactive-deps/bug-merge-uncond-optional-chain-and-cond.expect.md +++ b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/reduce-reactive-deps/edge-case-merge-uncond-optional-chain-and-cond.expect.md @@ -85,4 +85,7 @@ export const FIXTURE_ENTRYPOINT = { }; ``` - \ No newline at end of file + +### Eval output +(kind: ok) {} +[[ (exception in render) TypeError: Cannot read properties of null (reading 'title_text') ]] \ No newline at end of file diff --git a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/reduce-reactive-deps/bug-merge-uncond-optional-chain-and-cond.ts b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/reduce-reactive-deps/edge-case-merge-uncond-optional-chain-and-cond.ts similarity index 100% rename from compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/reduce-reactive-deps/bug-merge-uncond-optional-chain-and-cond.ts rename to compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/reduce-reactive-deps/edge-case-merge-uncond-optional-chain-and-cond.ts diff --git a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/reduce-reactive-deps/bug-infer-function-cond-access-not-hoisted.expect.md b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/reduce-reactive-deps/infer-function-cond-access-not-hoisted.expect.md similarity index 82% rename from compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/reduce-reactive-deps/bug-infer-function-cond-access-not-hoisted.expect.md rename to compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/reduce-reactive-deps/infer-function-cond-access-not-hoisted.expect.md index f68c826507207..263dd4d2e78d0 100644 --- a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/reduce-reactive-deps/bug-infer-function-cond-access-not-hoisted.expect.md +++ b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/reduce-reactive-deps/infer-function-cond-access-not-hoisted.expect.md @@ -70,4 +70,8 @@ export const FIXTURE_ENTRYPOINT = { }; ``` - \ No newline at end of file + +### Eval output +(kind: ok) [[ (exception in render) TypeError: Cannot read properties of null (reading 'b') ]] +
{"fn":{"kind":"Function","result":null},"shouldInvokeFns":true}
+
{"fn":{"kind":"Function","result":4},"shouldInvokeFns":true}
\ No newline at end of file diff --git a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/reduce-reactive-deps/bug-infer-function-cond-access-not-hoisted.tsx b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/reduce-reactive-deps/infer-function-cond-access-not-hoisted.tsx similarity index 100% rename from compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/reduce-reactive-deps/bug-infer-function-cond-access-not-hoisted.tsx rename to compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/reduce-reactive-deps/infer-function-cond-access-not-hoisted.tsx diff --git a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/bug-try-catch-maybe-null-dependency.expect.md b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/try-catch-maybe-null-dependency.expect.md similarity index 95% rename from compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/bug-try-catch-maybe-null-dependency.expect.md rename to compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/try-catch-maybe-null-dependency.expect.md index 839821b349a6f..52b359839f220 100644 --- a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/bug-try-catch-maybe-null-dependency.expect.md +++ b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/try-catch-maybe-null-dependency.expect.md @@ -70,4 +70,9 @@ export const FIXTURE_ENTRYPOINT = { }; ``` - \ No newline at end of file + +### Eval output +(kind: ok) ["null"] +[null] +[null] +["null"] \ No newline at end of file diff --git a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/bug-try-catch-maybe-null-dependency.ts b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/try-catch-maybe-null-dependency.ts similarity index 100% rename from compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/bug-try-catch-maybe-null-dependency.ts rename to compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/try-catch-maybe-null-dependency.ts diff --git a/compiler/packages/snap/src/SproutTodoFilter.ts b/compiler/packages/snap/src/SproutTodoFilter.ts index f363fd922e51a..0817bbf89c582 100644 --- a/compiler/packages/snap/src/SproutTodoFilter.ts +++ b/compiler/packages/snap/src/SproutTodoFilter.ts @@ -229,31 +229,15 @@ const skipFilter = new Set([ 'builtin-jsx-tag-lowered-between-mutations', 'call-args-assignment', 'call-args-destructuring-assignment', - 'call-spread', 'call-with-independently-memoizable-arg', 'capture-param-mutate', - 'capturing-fun-alias-captured-mutate-2', - 'capturing-fun-alias-captured-mutate-arr-2', - 'capturing-func-alias-captured-mutate-arr', - 'capturing-func-alias-computed-mutate', - 'capturing-func-alias-mutate', - 'capturing-func-alias-receiver-computed-mutate', - 'capturing-func-alias-receiver-mutate', - 'capturing-func-simple-alias', - 'capturing-function-capture-ref-before-rename', 'capturing-function-conditional-capture-mutate', 'capturing-function-member-expr-arguments', 'capturing-function-member-expr-call', - 'capturing-function-renamed-ref', - 'capturing-function-runs-inference', - 'capturing-function-shadow-captured', - 'capturing-reference-changes-type', 'codegen-emit-imports-same-source', 'codegen-emit-make-read-only', 'computed-call-spread', 'computed-load-primitive-as-dependency', - 'computed-store-alias', - 'constant-propagation-into-function-expressions', 'destructuring-mixed-scope-declarations-and-locals', 'destructuring-property-inference', 'do-while-conditional-break', @@ -477,23 +461,15 @@ const skipFilter = new Set([ 'invalid-jsx-lowercase-localvar', // bugs - 'fbt/bug-fbt-plural-multiple-function-calls', - 'fbt/bug-fbt-plural-multiple-mixed-call-tag', - `bug-capturing-func-maybealias-captured-mutate`, 'bug-object-expression-computed-key-modified-during-after-construction-hoisted-sequence-expr', - 'bug-invalid-hoisting-functionexpr', + `bug-capturing-func-maybealias-captured-mutate`, 'bug-aliased-capture-aliased-mutate', 'bug-aliased-capture-mutate', 'bug-functiondecl-hoisting', - 'bug-try-catch-maybe-null-dependency', - 'bug-invalid-mixedreadonly-map-shape', 'bug-type-inference-control-flow', - 'reduce-reactive-deps/bug-infer-function-cond-access-not-hoisted', + 'fbt/bug-fbt-plural-multiple-function-calls', + 'fbt/bug-fbt-plural-multiple-mixed-call-tag', 'bug-invalid-phi-as-dependency', - 'reduce-reactive-deps/bug-merge-uncond-optional-chain-and-cond', - 'original-reactive-scopes-fork/bug-nonmutating-capture-in-unsplittable-memo-block', - 'original-reactive-scopes-fork/bug-hoisted-declaration-with-scope', - 'bug-codegen-inline-iife', // 'react-compiler-runtime' not yet supported 'flag-enable-emit-hook-guards',