Skip to content

fix!: use the Babel installed in the consuming project - #179

Merged
frankieyan merged 2 commits into
mainfrom
ricardo/babel-peer-dependencies
Aug 3, 2026
Merged

fix!: use the Babel installed in the consuming project#179
frankieyan merged 2 commits into
mainfrom
ricardo/babel-peer-dependencies

Conversation

@rfgamaral

Copy link
Copy Markdown
Member

Overview

Declares @babel/core, @babel/preset-react and @babel/preset-typescript as peer dependencies instead of bundling them, so the tracker compiles with the same Babel the consuming project builds with. They stay as dev dependencies for this package's own tests, and renovate.json now blocks @babel/** majors.

Babel 8 drops AssignmentPattern, RestElement and TSParameterProperty from its LVal alias. babel-plugin-react-compiler calls path.isLVal() and so reports violations for valid code on Babel 8, such as any destructured parameter default. Bundling Babel made this worse than a wrong count: the presets are named as bare strings and resolve from the consumer's working directory, so a project on Babel 7 fed its own presets to the bundled Babel 8 core, every compile threw, and the swallowed error left the tracker reporting zero violations for every file.

The peer range on @babel/core is ^7.26.0, matching the floor babel-plugin-react-compiler sets through its own @babel/types dependency. src/babel.ts moves back to the TransformOptions type name, which is what Babel 7 exports.

Test plan

  1. In a checkout of todoist-web on main, run node_modules/.bin/react-compiler-tracker with no flags
    • Observe that it reports no React Compiler errors at all, despite .react-compiler.rec.json listing several files
  2. Check out this branch and run npm install, npm run build and npm pack to produce a tarball
  3. Back in todoist-web, install that tarball with npm install --no-save <path-to-tarball>
    • Observe that node_modules/@doist/react-compiler-tracker no longer contains a nested node_modules/@babel
  4. Run node_modules/.bin/react-compiler-tracker with no flags again
    • Observe that the reported issue and file counts now match the totals recorded in .react-compiler.rec.json

Babel 8 drops AssignmentPattern, RestElement and TSParameterProperty from its LVal alias. babel-plugin-react-compiler relies on that alias, so on Babel 8 it reports violations for valid code such as destructured parameter defaults.

Bundling Babel also meant the presets, which resolve from the consumer's working directory, could come from a different major than the bundled core, and every compile then failed. Declaring Babel as a peer dependency keeps the tracker on the same toolchain the project builds with.
@rfgamaral rfgamaral added the 🙋 Ask PR PR must be reviewed before merging label Aug 3, 2026
@rfgamaral
rfgamaral requested a review from a team as a code owner August 3, 2026 13:52
@rfgamaral
rfgamaral requested review from pedroalves0 and removed request for a team August 3, 2026 13:52
@rfgamaral rfgamaral self-assigned this Aug 3, 2026
@rfgamaral
rfgamaral requested a review from frankieyan August 3, 2026 13:52

@doistbot doistbot left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This PR moves @babel/core, @babel/preset-react, and @babel/preset-typescript from bundled dependencies to peer dependencies so the tracker compiles with the consuming project's own Babel, pins Babel 7 via Renovate, and renames the imported type to TransformOptions for Babel 7 compatibility.

Few things worth tightening:

  • Pin the Babel installs in the README command to v7 (e.g. @babel/core@^7.26.0 @babel/preset-react@^7 @babel/preset-typescript@^7); as written npm can resolve Babel 8, which is unsupported and conflicts with the new peer range.

Share FeedbackReview Logs

Comment thread README.md Outdated

@frankieyan frankieyan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for taking care of this Ricardo! ❤️

@frankieyan
frankieyan merged commit 60def1c into main Aug 3, 2026
3 checks passed
@frankieyan
frankieyan deleted the ricardo/babel-peer-dependencies branch August 3, 2026 15:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🙋 Ask PR PR must be reviewed before merging

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants