Turbopack: fix import_usage for functions behind member expressions#145
Conversation
There was a problem hiding this comment.
Code Review
This pull request modifies the ECMAScript analyzer's handling of member expressions to prevent identifier objects from being incorrectly added to the full star imports list. While the change correctly skips the general expression visitor for the object, it currently fails to visit the property of the member expression. Feedback suggests explicitly visiting the property to ensure identifiers or private names in that position are correctly analyzed.
| // Skip traversing if obj is a Expr::Ident, so that it doesn't get added to | ||
| // Intentionally skipping over visit_expr(node.obj) here so that it doesn't get added to | ||
| // full_star_imports below in visit_expr. | ||
| ident.visit_with(self); |
There was a problem hiding this comment.
The visit_member_expr implementation skips node.prop when the condition is met. This means that identifiers or private names in the property position are not visited, which can lead to incorrect analysis (e.g., failing to mark them as used). You should explicitly visit node.prop.
| ident.visit_with(self); | |
| ident.visit_with(self); | |
| node.prop.visit_with(self); |
align with: vercel#93504
just fix a runtime error from our business: