Skip to content

feat: Port React Compiler tracker from todoist-web#6

Merged
frankieyan merged 10 commits intomainfrom
frankie/react-compiler-tracker
Jan 10, 2026
Merged

feat: Port React Compiler tracker from todoist-web#6
frankieyan merged 10 commits intomainfrom
frankie/react-compiler-tracker

Conversation

@frankieyan
Copy link
Copy Markdown
Member

@frankieyan frankieyan commented Jan 10, 2026

This ports over the React Compiler tracker from https://github.com/Doist/todoist-web/tree/11bb6f8cd07c0134b503a441b0b3abe5c9ec57ea/tools/react-compiler-check

Aside from the added tests, the script can be tested manually with the included fixtures:

  • Navigate to src/__fixtures__/sample-project
  • Run npx tsx ../../index.mts --overwrite
  • It should generate a .react-compiler.rec.json

Or, run with the transpiled version:

  • Run npm run build
  • Navigate to src/__fixtures__/sample-project
  • Run node ../../../dist/index.mjs --overwrite

@frankieyan frankieyan added the 👀 Show PR PR must be reviewed before or after merging label Jan 10, 2026
Copy link
Copy Markdown

@doistbot-app doistbot-app Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pull request successfully ports the React Compiler tracker script and adds a solid set of tests and CI integration. I've identified two potential improvements in the main script logic: a correction to the regex used for component detection to improve accuracy, and an enhancement to error handling when parsing the results file to make the tool more robust against corrupted data. Both are non-blocking but would improve the tool's reliability.

Comment thread src/index.mts
) {
const current = compilerErrors.get(relativePath) || {}
current[event.kind] = (current[event.kind] ?? 0) + 1
compilerErrors.set(relativePath, current)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P1] Flawed regex for React component detection

The regular expression used to detect React components is flawed. It incorrectly identifies any file containing 'react' at the start of a line as a component, while also failing to match component files that use single quotes for the react import (e.g., import React from 'react'). This can lead to inaccurate processing of files.

Suggested change
compilerErrors.set(relativePath, current)
/^(import .* from ["']react["'])/m.test(fileContent) ||

Comment thread src/index.mts
await runCheckAllFiles()
}
} catch (error: unknown) {
if (error instanceof Error) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Unhandled JSON parsing error

The script reads and parses the existing .react-compiler.rec.json file without handling potential errors. If this file is empty or contains invalid JSON, JSON.parse will throw an unhandled exception and cause the script to crash. Adding a try...catch block would make the tool more robust by allowing it to gracefully handle a corrupted results file and start fresh.

Suggested change
if (error instanceof Error) {
let existingResults: Results = {}
if (existsSync(resultFilePath)) {
try {
const content = readFileSync(resultFilePath, "utf-8")
if (content) {
existingResults = JSON.parse(content)
}
} catch {
console.warn(`Corrupted ${RESULT_FILE_NAME}, starting from scratch.`)
}
}

Comment thread src/babel.mts
const babelConfigFn: ConfigFunction = require(babelConfigPath)
const babelConfig = babelConfigFn({
cache: {
using: (callback) => callback(),
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#7

@frankieyan frankieyan requested review from a team and pawelgrimm and removed request for a team January 10, 2026 07:28
@frankieyan frankieyan merged commit 8e8ec3b into main Jan 10, 2026
3 checks passed
@frankieyan frankieyan deleted the frankie/react-compiler-tracker branch January 10, 2026 07:36
Copy link
Copy Markdown

@pawelgrimm pawelgrimm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! I noticed that we didn't pin version for two of the deps, but renovate is on it: #10

Comment thread package.json
"@babel/preset-react": "7.28.5",
"@babel/preset-typescript": "7.28.5",
"@biomejs/biome": "2.3.11",
"@types/babel__core": "^7.20.5",
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💬 Let's pin this version:

Suggested change
"@types/babel__core": "^7.20.5",
"@types/babel__core": "7.20.5",

Comment thread package.json
"babel-plugin-react-compiler": "^1.0.0"
},
"dependencies": {
"glob": "^13.0.0"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💬 Let's pin this version:

Suggested change
"glob": "^13.0.0"
"glob": "13.0.0"

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was torn about this. It'd be nice to allow consumers to more easily resolve to newer patch versions and reduce the chances of having multiple versions of dependencies installed, but since pinning is Renovate's default behaviour, let's go with it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

👀 Show PR PR must be reviewed before or after merging

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants