Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
f7b1273
Flag for requestPaint (#31805)
rickhanlonii Dec 16, 2024
031230d
[Flight] Stack Parallel Components in Separate Tracks (#31735)
sebmarkbage Dec 16, 2024
909ed63
Clean up context access profiling experiment (#31806)
jackpope Dec 16, 2024
07facb5
[Flight] Sort Server Components Track Group ahead of Client Scheduler…
sebmarkbage Dec 16, 2024
bdf1871
[Flight] Emit Deduped Server Components Marker (#31737)
sebmarkbage Dec 16, 2024
54e86bd
[Flight] Color and badge non-primary environments (#31738)
sebmarkbage Dec 16, 2024
e30872a
[compiler][be] Playground now compiles entire program (#31774)
mofeiZ Dec 16, 2024
80b81fe
[compiler] Repro for aliased captures within inner function expressio…
mofeiZ Dec 16, 2024
ac17270
[compiler][ez] Clean up duplicate code in propagateScopeDeps (#31581)
mofeiZ Dec 16, 2024
d325f87
[compiler][be] Logger based debug printing in test runner (#31809)
mofeiZ Dec 16, 2024
308be6e
[compiler] Add option for firing effect functions (#31794)
jbrown215 Dec 16, 2024
c869063
[compiler] Add fire to known React APIs (#31795)
jbrown215 Dec 16, 2024
a78bbf9
[compiler] Context variables as dependencies (#31582)
mofeiZ Dec 16, 2024
8a7b306
[compiler][ez] Add shape for global Object.keys (#31583)
mofeiZ Dec 16, 2024
8dab592
Turn on useModernStrictMode in test renderers (#31769)
rickhanlonii Dec 17, 2024
49b1a95
Enable disableDefaultPropsExceptForClasses (#31804)
rickhanlonii Dec 17, 2024
975cea2
Enable debugRenderPhaseSideEffectsForStrictMode in test renderers (#3…
rickhanlonii Dec 17, 2024
d428725
[flags] Clean up scheduler flags (#31814)
rickhanlonii Dec 17, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
function TestComponent(t0) {
import { c as _c } from "react/compiler-runtime";
export default function TestComponent(t0) {
const $ = _c(2);
const { x } = t0;
let t1;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
function MyApp() {
import { c as _c } from "react/compiler-runtime";
export default function MyApp() {
const $ = _c(1);
let t0;
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
function TestComponent(t0) {
"use memo";
import { c as _c } from "react/compiler-runtime";
export default function TestComponent(t0) {
const $ = _c(2);
const { x } = t0;
let t1;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
function TestComponent({ x }) {
"use no memo";
export default function TestComponent({ x }) {
return <Button>{x}</Button>;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { c as _c } from "react/compiler-runtime";
function useFoo(propVal) {
  const $ = _c(2);
  const t0 = (propVal.baz: number);
  let t1;
  if ($[0] !== t0) {
    t1 = <div>{t0}</div>;
    $[0] = t0;
    $[1] = t1;
  } else {
    t1 = $[1];
  }
  return t1;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { c as _c } from "react/compiler-runtime";
function Foo() {
  const $ = _c(2);
  let t0;
  if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
    t0 = foo();
    $[0] = t0;
  } else {
    t0 = $[0];
  }
  const x = t0 as number;
  let t1;
  if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
    t1 = <div>{x}</div>;
    $[1] = t1;
  } else {
    t1 = $[1];
  }
  return t1;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
"use no memo";
function TestComponent({ x }) {
"use memo";
return <Button>{x}</Button>;
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { c as _c } from "react/compiler-runtime";
function TestComponent(t0) {
"use memo";
const $ = _c(2);
Expand All @@ -12,7 +13,7 @@ function TestComponent(t0) {
}
return t1;
}
function anonymous_1(t0) {
const TestComponent2 = (t0) => {
"use memo";
const $ = _c(2);
const { x } = t0;
Expand All @@ -25,4 +26,4 @@ function anonymous_1(t0) {
t1 = $[1];
}
return t1;
}
};
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
function anonymous_1() {
const TestComponent = function () {
"use no memo";
return <Button>{x}</Button>;
}
function anonymous_3({ x }) {
};
const TestComponent2 = ({ x }) => {
"use no memo";
return <Button>{x}</Button>;
}
};
41 changes: 33 additions & 8 deletions compiler/apps/playground/__tests__/e2e/page.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import {expect, test} from '@playwright/test';
import {encodeStore, type Store} from '../../lib/stores';
import {format} from 'prettier';

function print(data: Array<string>): Promise<string> {
function formatPrint(data: Array<string>): Promise<string> {
return format(data.join(''), {parser: 'babel'});
}

const DIRECTIVE_TEST_CASES = [
const TEST_CASE_INPUTS = [
{
name: 'module-scope-use-memo',
input: `
Expand Down Expand Up @@ -55,14 +55,34 @@ const TestComponent2 = ({ x }) => {
};`,
},
{
name: 'function-scope-beats-module-scope',
name: 'todo-function-scope-does-not-beat-module-scope',
input: `
'use no memo';
function TestComponent({ x }) {
'use memo';
return <Button>{x}</Button>;
}`,
},
{
name: 'parse-typescript',
input: `
function Foo() {
const x = foo() as number;
return <div>{x}</div>;
}
`,
noFormat: true,
},
{
name: 'parse-flow',
input: `
// @flow
function useFoo(propVal: {+baz: number}) {
return <div>{(propVal.baz as number)}</div>;
}
`,
noFormat: true,
},
];

test('editor should open successfully', async ({page}) => {
Expand Down Expand Up @@ -90,7 +110,7 @@ test('editor should compile from hash successfully', async ({page}) => {
});
const text =
(await page.locator('.monaco-editor').nth(1).allInnerTexts()) ?? [];
const output = await print(text);
const output = await formatPrint(text);

expect(output).not.toEqual('');
expect(output).toMatchSnapshot('01-user-output.txt');
Expand All @@ -115,14 +135,14 @@ test('reset button works', async ({page}) => {
});
const text =
(await page.locator('.monaco-editor').nth(1).allInnerTexts()) ?? [];
const output = await print(text);
const output = await formatPrint(text);

expect(output).not.toEqual('');
expect(output).toMatchSnapshot('02-default-output.txt');
});

DIRECTIVE_TEST_CASES.forEach((t, idx) =>
test(`directives work: ${t.name}`, async ({page}) => {
TEST_CASE_INPUTS.forEach((t, idx) =>
test(`playground compiles: ${t.name}`, async ({page}) => {
const store: Store = {
source: t.input,
};
Expand All @@ -135,7 +155,12 @@ DIRECTIVE_TEST_CASES.forEach((t, idx) =>

const text =
(await page.locator('.monaco-editor').nth(1).allInnerTexts()) ?? [];
const output = await print(text);
let output: string;
if (t.noFormat) {
output = text.join('');
} else {
output = await formatPrint(text);
}

expect(output).not.toEqual('');
expect(output).toMatchSnapshot(`${t.name}-output.txt`);
Expand Down
Loading
Loading