Skip to content

Commit 2b49a90

Browse files
committed
Update on "[compiler] add fixture for optimization across scopes"
Adds a fixture based on internal case where our current output is quite a bit more verbose than the original memoization. See the comment in the fixture for more about the heuristic we can apply. [ghstack-poisoned]
2 parents 137e4f0 + ea7c988 commit 2b49a90

File tree

92 files changed

+417
-272
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+417
-272
lines changed

.circleci/config.yml

-47
Original file line numberDiff line numberDiff line change
@@ -74,38 +74,6 @@ parameters:
7474
default: ''
7575

7676
jobs:
77-
yarn_lint:
78-
docker: *docker
79-
environment: *environment
80-
81-
steps:
82-
- checkout
83-
- setup_node_modules
84-
- run: node ./scripts/prettier/index
85-
- run: node ./scripts/tasks/eslint
86-
- run: ./scripts/circleci/check_license.sh
87-
- run: ./scripts/circleci/test_print_warnings.sh
88-
89-
yarn_flow:
90-
docker: *docker
91-
environment: *environment
92-
parallelism: 5
93-
94-
steps:
95-
- checkout
96-
- setup_node_modules
97-
- run: node ./scripts/tasks/flow-ci
98-
99-
100-
yarn_flags:
101-
docker: *docker
102-
environment: *environment
103-
104-
steps:
105-
- checkout
106-
- setup_node_modules
107-
- run: yarn flags
108-
10977
scrape_warning_messages:
11078
docker: *docker
11179
environment: *environment
@@ -464,26 +432,11 @@ workflows:
464432
build_and_test:
465433
unless: << pipeline.parameters.prerelease_commit_sha >>
466434
jobs:
467-
- yarn_flags:
468-
filters:
469-
branches:
470-
ignore:
471-
- builds/facebook-www
472-
- yarn_flow:
473-
filters:
474-
branches:
475-
ignore:
476-
- builds/facebook-www
477435
- check_generated_fizz_runtime:
478436
filters:
479437
branches:
480438
ignore:
481439
- builds/facebook-www
482-
- yarn_lint:
483-
filters:
484-
branches:
485-
ignore:
486-
- builds/facebook-www
487440
- yarn_test:
488441
filters:
489442
branches:

.eslintrc.js

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ module.exports = {
1717
// Stop ESLint from looking for a configuration file in parent folders
1818
root: true,
1919

20+
reportUnusedDisableDirectives: true,
21+
2022
plugins: [
2123
'babel',
2224
'ft-flow',

.github/workflows/compiler-typescript.yml

-19
Original file line numberDiff line numberDiff line change
@@ -23,25 +23,6 @@ jobs:
2323
- id: set-matrix
2424
run: echo "matrix=$(find packages -mindepth 1 -maxdepth 1 -type d | sed 's!packages/!!g' | tr '\n' ',' | sed s/.$// | jq -Rsc '. / "," - [""]')" >> $GITHUB_OUTPUT
2525

26-
# Hardcoded to improve parallelism for babel-plugin-react-compiler
27-
prettier:
28-
name: Run prettier
29-
runs-on: ubuntu-latest
30-
steps:
31-
- uses: actions/checkout@v4
32-
- uses: actions/setup-node@v4
33-
with:
34-
node-version: 18.x
35-
cache: "yarn"
36-
cache-dependency-path: compiler/yarn.lock
37-
- name: Restore cached node_modules
38-
uses: actions/cache@v4
39-
with:
40-
path: "**/node_modules"
41-
key: ${{ runner.arch }}-${{ runner.os }}-modules-${{ hashFiles('compiler/**/yarn.lock') }}
42-
- run: yarn install --frozen-lockfile
43-
- run: yarn prettier:ci
44-
4526
# Hardcoded to improve parallelism
4627
lint:
4728
name: Lint babel-plugin-react-compiler

.github/workflows/flags.yml

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Flags
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
paths-ignore:
8+
- 'compiler/**'
9+
10+
jobs:
11+
flags:
12+
name: Check flags
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
- uses: actions/setup-node@v4
17+
with:
18+
node-version: 18.x
19+
cache: "yarn"
20+
cache-dependency-path: yarn.lock
21+
- name: Restore cached node_modules
22+
uses: actions/cache@v4
23+
id: node_modules
24+
with:
25+
path: "**/node_modules"
26+
key: ${{ runner.arch }}-${{ runner.os }}-modules-${{ hashFiles('yarn.lock') }}
27+
- run: yarn install --frozen-lockfile
28+
- run: yarn flags

.github/workflows/flow.yml

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Flow
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
paths-ignore:
8+
- 'compiler/**'
9+
10+
jobs:
11+
discover_flow_inline_configs:
12+
name: Discover flow inline configs
13+
runs-on: ubuntu-latest
14+
outputs:
15+
matrix: ${{ steps.set-matrix.outputs.result }}
16+
steps:
17+
- uses: actions/checkout@v4
18+
- uses: actions/github-script@v7
19+
id: set-matrix
20+
with:
21+
script: |
22+
const inlinedHostConfigs = require('./scripts/shared/inlinedHostConfigs.js');
23+
return inlinedHostConfigs.map(config => config.shortName);
24+
25+
flow:
26+
name: Flow check ${{ matrix.flow_inline_config_shortname }}
27+
needs: discover_flow_inline_configs
28+
runs-on: ubuntu-latest
29+
continue-on-error: true
30+
strategy:
31+
matrix:
32+
flow_inline_config_shortname: ${{ fromJSON(needs.discover_flow_inline_configs.outputs.matrix) }}
33+
steps:
34+
- uses: actions/checkout@v4
35+
- uses: actions/setup-node@v4
36+
with:
37+
node-version: 18.x
38+
cache: "yarn"
39+
cache-dependency-path: yarn.lock
40+
- name: Restore cached node_modules
41+
uses: actions/cache@v4
42+
id: node_modules
43+
with:
44+
path: "**/node_modules"
45+
key: ${{ runner.arch }}-${{ runner.os }}-modules-${{ hashFiles('yarn.lock') }}
46+
- run: yarn install --frozen-lockfile
47+
- run: node ./scripts/tasks/flow-ci-ghaction ${{ matrix.flow_inline_config_shortname }}

.github/workflows/lint.yml

+79
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: Lint
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
8+
jobs:
9+
prettier:
10+
name: Run prettier
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
- uses: actions/setup-node@v4
15+
with:
16+
node-version: 18.x
17+
cache: "yarn"
18+
cache-dependency-path: yarn.lock
19+
- name: Restore cached node_modules
20+
uses: actions/cache@v4
21+
with:
22+
path: "**/node_modules"
23+
key: ${{ runner.arch }}-${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
24+
- run: yarn install --frozen-lockfile
25+
- run: yarn prettier-check
26+
27+
eslint:
28+
name: Run eslint
29+
runs-on: ubuntu-latest
30+
steps:
31+
- uses: actions/checkout@v4
32+
- uses: actions/setup-node@v4
33+
with:
34+
node-version: 18.x
35+
cache: "yarn"
36+
cache-dependency-path: yarn.lock
37+
- name: Restore cached node_modules
38+
uses: actions/cache@v4
39+
with:
40+
path: "**/node_modules"
41+
key: ${{ runner.arch }}-${{ runner.os }}-modules-${{ hashFiles('yarn.lock') }}
42+
- run: yarn install --frozen-lockfile
43+
- run: node ./scripts/tasks/eslint
44+
45+
check_license:
46+
name: Check license
47+
runs-on: ubuntu-latest
48+
steps:
49+
- uses: actions/checkout@v4
50+
- uses: actions/setup-node@v4
51+
with:
52+
node-version: 18.x
53+
cache: "yarn"
54+
cache-dependency-path: yarn.lock
55+
- name: Restore cached node_modules
56+
uses: actions/cache@v4
57+
with:
58+
path: "**/node_modules"
59+
key: ${{ runner.arch }}-${{ runner.os }}-modules-${{ hashFiles('yarn.lock') }}
60+
- run: yarn install --frozen-lockfile
61+
- run: ./scripts/circleci/check_license.sh
62+
63+
test_print_warnings:
64+
name: Test print warnings
65+
runs-on: ubuntu-latest
66+
steps:
67+
- uses: actions/checkout@v4
68+
- uses: actions/setup-node@v4
69+
with:
70+
node-version: 18.x
71+
cache: "yarn"
72+
cache-dependency-path: yarn.lock
73+
- name: Restore cached node_modules
74+
uses: actions/cache@v4
75+
with:
76+
path: "**/node_modules"
77+
key: ${{ runner.arch }}-${{ runner.os }}-modules-${{ hashFiles('yarn.lock') }}
78+
- run: yarn install --frozen-lockfile
79+
- run: ./scripts/circleci/test_print_warnings.sh

.prettierignore

+24
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# react runtime
12
build
23

34
packages/react-devtools-core/dist
@@ -13,3 +14,26 @@ packages/react-devtools-shared/src/hooks/__tests__/__source__/__untransformed__/
1314
packages/react-devtools-shell/dist
1415
packages/react-devtools-timeline/dist
1516
packages/react-devtools-timeline/static
17+
18+
# react compiler
19+
compiler/**/dist
20+
compiler/**/__tests__/fixtures/**/*.expect.md
21+
compiler/**/__tests__/fixtures/**/*.flow.js
22+
compiler/**/.next
23+
24+
compiler/crates
25+
compiler/apps/playground/public
26+
27+
compiler/**/LICENSE
28+
compiler/.*
29+
compiler/*.md*
30+
compiler/*.json
31+
compiler/*.css
32+
compiler/*.webmanifest
33+
compiler/*.map
34+
compiler/*.sh
35+
compiler/*.txt
36+
compiler/*.ico
37+
compiler/*.svg
38+
compiler/*.lock
39+
compiler/*.toml

.prettierrc.js

+15
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
'use strict';
22

33
const {
4+
compilerPaths,
45
esNextPaths,
56
typescriptPaths,
67
} = require('./scripts/shared/pathsByLanguageVersion');
@@ -33,5 +34,19 @@ module.exports = {
3334
parser: 'typescript',
3435
},
3536
},
37+
{
38+
files: compilerPaths,
39+
options: {
40+
requirePragma: false,
41+
parser: 'babel-ts',
42+
semi: true,
43+
singleQuote: false,
44+
trailingComma: 'es5',
45+
bracketSpacing: true,
46+
bracketSameLine: false,
47+
printWidth: 80,
48+
arrowParens: 'always',
49+
},
50+
},
3651
],
3752
};

compiler/.eslintrc.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ module.exports = {
4343

4444
"multiline-comment-style": ["error", "starred-block"],
4545

46+
/**
47+
* We sometimes need to check for control characters in regexes for things like preserving input
48+
* strings
49+
*/
50+
"no-control-regex": "off",
51+
4652
"@typescript-eslint/no-empty-function": "off",
4753

4854
/*
@@ -82,7 +88,7 @@ module.exports = {
8288
],
8389
"@typescript-eslint/array-type": ["error", { default: "generic" }],
8490
"@typescript-eslint/triple-slash-reference": "off",
85-
"@typescript-eslint/no-var-requires": "off"
91+
"@typescript-eslint/no-var-requires": "off",
8692
},
8793
parser: "@typescript-eslint/parser",
8894
plugins: ["@typescript-eslint"],

compiler/.prettierignore

-21
This file was deleted.

compiler/.prettierrc.js

-9
This file was deleted.

compiler/apps/playground/components/TabbedWindow.tsx

+6-2
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,9 @@ function TabbedWindowItem({
7878
title="Minimize tab"
7979
aria-label="Minimize tab"
8080
onClick={toggleTabs}
81-
className={`p-4 duration-150 ease-in border-b cursor-pointer border-grey-200 ${hasChanged ? "font-bold" : "font-light"} text-secondary hover:text-link`}
81+
className={`p-4 duration-150 ease-in border-b cursor-pointer border-grey-200 ${
82+
hasChanged ? "font-bold" : "font-light"
83+
} text-secondary hover:text-link`}
8284
>
8385
- {name}
8486
</h2>
@@ -91,7 +93,9 @@ function TabbedWindowItem({
9193
aria-label={`Expand compiler tab: ${name}`}
9294
style={{ transform: "rotate(90deg) translate(-50%)" }}
9395
onClick={toggleTabs}
94-
className={`flex-grow-0 w-5 transition-colors duration-150 ease-in ${hasChanged ? "font-bold" : "font-light"} text-secondary hover:text-link`}
96+
className={`flex-grow-0 w-5 transition-colors duration-150 ease-in ${
97+
hasChanged ? "font-bold" : "font-light"
98+
} text-secondary hover:text-link`}
9599
>
96100
{name}
97101
</button>

0 commit comments

Comments
 (0)