Skip to content

[compiler][snap] More minimization improvements#463

Closed
everettbu wants to merge 1 commit into
mainfrom
more-snap-improvements-3
Closed

[compiler][snap] More minimization improvements#463
everettbu wants to merge 1 commit into
mainfrom
more-snap-improvements-3

Conversation

@everettbu

Copy link
Copy Markdown

Mirror of facebook/react#35689
Original author: josephsavona


  • A few new minimization strategies, removing function params and array/object pattern elements
  • Ensure that we preserve the same set of errors based on not just category+reason but also description.

* A few new minimization strategies, removing function params and array/object pattern elements
* Ensure that we preserve the same set of errors based on not just category+reason but also description.
@everettbu everettbu added CLA Signed React Core Team Opened by a member of the React Core Team labels Feb 4, 2026
@greptile-apps

greptile-apps Bot commented Feb 4, 2026

Copy link
Copy Markdown

Greptile Overview

Greptile Summary

This PR extends the Snap minimizer by (1) ensuring error preservation compares category, reason, and description, and (2) adding new minimization strategies that remove function parameters and remove elements/properties from array/object destructuring patterns.

One blocking issue: the minimizer’s AST traversals call t.traverseFast(...) in many places, but t is @babel/types; traverseFast should come from @babel/traverse. As-is, running the minimizer will throw before any strategy can execute.

Confidence Score: 2/5

  • Not safe to merge as-is due to a runtime failure in the minimizer traversal code.
  • The new minimization strategies rely on t.traverseFast, but t is @babel/types and does not expose that traversal helper; this should throw at runtime whenever the minimizer runs. Aside from that, the error matching update is straightforward.
  • compiler/packages/snap/src/minimize.ts

Important Files Changed

Filename Overview
compiler/packages/snap/src/minimize.ts Adds error matching on description and introduces new minimization generators to remove function params and destructuring pattern elements; however, this file uses t.traverseFast(...) which is not provided by @babel/types, causing runtime failure when minimization runs.

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

1 file reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

@greptile-apps

greptile-apps Bot commented Feb 4, 2026

Copy link
Copy Markdown
Additional Comments (1)

compiler/packages/snap/src/minimize.ts
Invalid AST traversal

This file calls t.traverseFast(...) in multiple places, but @babel/types doesn’t provide traverseFast (it’s from @babel/traverse). As written, minimize() will throw at runtime the first time it hits one of these calls. You likely want import traverse, {traverseFast} from '@babel/traverse' and then use traverseFast(ast, ...) (or replace these with traverse(ast, { enter(path) { ... } })).

Also appears at compiler/packages/snap/src/minimize.ts:195, 234, 322, 364, 443, etc.

Prompt To Fix With AI
This is a comment left during a code review.
Path: compiler/packages/snap/src/minimize.ts
Line: 149:151

Comment:
**Invalid AST traversal**

This file calls `t.traverseFast(...)` in multiple places, but `@babel/types` doesn’t provide `traverseFast` (it’s from `@babel/traverse`). As written, `minimize()` will throw at runtime the first time it hits one of these calls. You likely want `import traverse, {traverseFast} from '@babel/traverse'` and then use `traverseFast(ast, ...)` (or replace these with `traverse(ast, { enter(path) { ... } })`).

Also appears at `compiler/packages/snap/src/minimize.ts:195`, `234`, `322`, `364`, `443`, etc.

How can I resolve this? If you propose a fix, please make it concise.

@everettbu

Copy link
Copy Markdown
Author

Upstream PR was closed or merged. Code is synced via branch mirror.

@everettbu everettbu closed this Feb 4, 2026
@everettbu
everettbu deleted the more-snap-improvements-3 branch February 4, 2026 15:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed React Core Team Opened by a member of the React Core Team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants