-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
fix(es/minifier): Fix cycle detection #10950
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
🦋 Changeset detectedLatest commit: 8b585d9 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Claude finished @kdy1's task —— View job Claude finished @kdy1's task —— View job PR Review: Fix cycle detectionSummaryThis PR fixes a bug in the ES minifier's cycle detection logic for class inheritance. The issue was that super class references were incorrectly being tracked as dependencies within the AST path context, leading to false cycles in the dependency graph. Code Quality ✅Positive aspects:
Analysis of the fix: // BEFORE: Super class visited inside AST path context
fn visit_class_decl(&mut self, n: &ClassDecl) {
self.with_ast_path(vec![n.ident.to_id()], |v| {
n.visit_children_with(v); // Includes super_class
})
}
// AFTER: Super class visited outside AST path context
fn visit_class_decl(&mut self, n: &ClassDecl) {
if let Some(super_class) = &n.class.super_class {
super_class.visit_with(self); // Outside AST path
}
self.with_ast_path(vec![n.ident.to_id()], |v| {
// Visit specific parts, excluding super_class
n.ident.visit_with(v);
n.class.decorators.visit_with(v);
n.class.body.visit_with(v);
})
} The fix ensures that dependencies on super classes are not incorrectly attributed to the class being defined, preventing false cycles. Test Coverage ✅Excellent test coverage:
The test structure follows SWC conventions correctly (input.js only, expecting empty output). Performance Considerations ✅Performance impact analysis:
The fix should improve rather than degrade performance by enabling more accurate dead code elimination. Security Concerns ✅No security issues identified:
Potential Issues ❓Minor considerations:
Overall Assessment ⭐⭐⭐⭐⭐Excellent PR - This is a high-quality bug fix that:
Recommendation: Approve and merge after considering the changeset requirement. |
CodSpeed Performance ReportMerging #10950 will not alter performanceComparing Summary
|
To pull in a minifier bugfix: swc-project/swc#10950 Fixes error locations again: swc-project/swc#10930 https://vercel.slack.com/archives/C02HY34AKME/p1753429211338319 Blocked on swc-project/plugins#514
Description:
The super class expression of a class declaration should be analyzed from the outside context of the class declarartions.