[No QA] Rewrite React Compiler CI compliance check#87182
[No QA] Rewrite React Compiler CI compliance check#87182roryabraham wants to merge 17 commits intomainfrom
Conversation
Allow the last positional arg in a CLI config to be marked `variadic: true`, which collects all remaining positional args into a string[]. The type system correctly infers string[] for variadic args. Made-with: Cursor
New method returns {filename, status}[] using paginated GitHub API
in CI and git diff locally. Refactors getChangedFileNames() to be
a lightweight wrapper around it, fixing a pagination bug where
large PRs could have files silently dropped.
Made-with: Cursor
The compiler config was duplicated in babel.config.js and the eslint-plugin-react-compiler-compat. Now both import from a single source of truth at scripts/utils/reactCompilerConfig.js. Made-with: Cursor
Replace the 860-line script that shelled out to react-compiler-healthcheck and parsed stdout with regexes. The new implementation uses @babel/core's transformSync with babel-plugin-react-compiler directly (~200 lines). Two modes: - `check <files...>` -- local CLI for checking specific files - `check-changed` -- CI mode with two rules: 1. New files with components/hooks must compile 2. Modified files must not regress vs main Uses a three-state return (compiled/failed/no-components) to correctly skip non-React files without false positives. Made-with: Cursor
Hooks typically live in .ts files, not just .tsx. The path trigger now includes .ts, .tsx, and .jsx so the compliance check covers all files that could contain React components or hooks. Made-with: Cursor
The compliance check now uses babel-plugin-react-compiler directly, making the react-compiler-healthcheck package unnecessary. Made-with: Cursor
Simplify docs to reflect the rewritten tool: direct babel transform, two CI rules (new files must compile, no regressions on modified files), and simpler CLI usage. Made-with: Cursor
The repo has zero .jsx files — everything is TypeScript. Made-with: Cursor
Use `variadic?: true` literal type and explicit cast at the call site to work around TypeScript's inability to narrow conditional mapped types through tuple inference. Made-with: Cursor
Made-with: Cursor
Made-with: Cursor
The `check` command now accepts directories (recursively finds .ts/.tsx files) and glob patterns in addition to individual file paths. Inputs are deduplicated and non-.ts/.tsx files are filtered. Made-with: Cursor
chrispader
left a comment
There was a problem hiding this comment.
Looks good to me aside from minor requests! 🙌🏼
- Move resolveFilePaths to FileUtils.ts with configurable extensions - Cache fs.existsSync/statSync to avoid redundant calls - Use FILE_EXTENSIONS variable in log message Made-with: Cursor
…JS check The typecheck workflow blocks new .js files; add an exclusion for config/babel/*.js since this config must be plain JS (consumed by babel.config.js before TS compilation). Also rebuild GitHub Action bundles to reflect getChangedFilesWithStatus() changes in Git.ts. Made-with: Cursor
|
@parasharrajat Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
|
@mountiny do you think we should add this check as just a warning first, or just enable it? There might be some cases where it would be a bit confusing for people to fix. If we decide to merge through a failure, it will not continue to fail on subsequent PRs, because it only complains when:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 270c39d10d
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
For renamed files, the GitHub API provides previous_filename which we now surface through getChangedFilesWithStatus(). The regression check uses this to look up the file on main at its old path, correctly detecting regressions even when a file is renamed. Made-with: Cursor
Use -M flag in git diff to detect file renames locally. Without this, renames appeared as delete + add, incorrectly subjecting renamed files to the "new files must compile" rule. Now renames are properly detected with their previous path, matching the behavior of the GitHub API in CI. Made-with: Cursor
Explanation of Change
Rewrites the React Compiler compliance check CI workflow from scratch. The new implementation is much simpler and has much simpler requirements - it just enforces:
The previous implementation (~860 lines) shelled out to
npx react-compiler-healthcheck, parsed its stdout with regexes, and applied complex line-level diff analysis with manual memoization checking. The new implementation is ~200 lines and uses@babel/core'stransformSyncwithbabel-plugin-react-compilerdirectly, which is simpler, faster, and more reliable. The healthcheck is deprecated anyways.One key difference is that we _don't suppress
BuildHIRexceptions. In my experience it's pretty trivial to work around these, and I haven't really found any cases that are insurmountable. So I'm letting those surface so they can be fixed.Key changes:
compiled/failed/no-components(leverages the compiler's own component/hook detection)npm run react-compiler-compliance-check check <files...>ReactCompilerConfigto eliminate duplication across babel.config.js, ESLint plugin, and this scriptGit.getChangedFileNames()(was only fetching first page of GitHub API results)scripts/utils/CLI.tsreact-compiler-healthcheckdependency and its 3 patch files.tsand.jsxfiles (hooks live in.tsfiles)Fixed Issues
$ #68765
Tests
npm run react-compiler-compliance-check check src/components/Button/index.tsxand verify it reportsCOMPILEDnpm run react-compiler-compliance-check check src/CONST.tsand verify it skips (no components)npx jest tests/unit/CLIVariadicTest.ts tests/unit/ReactCompilerComplianceCheckTest.tsand verify all 9 tests passOffline tests
N/A - CI tooling only, no runtime behavior.
QA Steps
N/A - CI tooling only.
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectioncanBeMissingparam foruseOnyxtoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
N/A - CI tooling only
Android: mWeb Chrome
N/A - CI tooling only
iOS: Native
N/A - CI tooling only
iOS: mWeb Safari
N/A - CI tooling only
MacOS: Chrome / Safari
N/A - CI tooling only
Made with Cursor