-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
fix: Object spread operator is unnecessarily transformed when used with React #7054
Changes from all commits
4b5ebbf
2847afb
233d4d6
228942d
738122e
4edc9fa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,9 +19,7 @@ use swc_config::merge::Merge; | |
use swc_ecma_ast::*; | ||
use swc_ecma_parser::{parse_file_as_expr, Syntax}; | ||
use swc_ecma_transforms_base::helper; | ||
use swc_ecma_utils::{ | ||
drop_span, member_expr, prepend_stmt, private_ident, quote_ident, undefined, ExprFactory, | ||
}; | ||
use swc_ecma_utils::{drop_span, prepend_stmt, private_ident, quote_ident, undefined, ExprFactory}; | ||
use swc_ecma_visit::{as_folder, noop_visit_mut_type, Fold, VisitMut, VisitMutWith}; | ||
|
||
use self::static_check::should_use_create_element; | ||
|
@@ -832,7 +830,7 @@ where | |
return Box::new(Expr::Lit(Lit::Null(Null { span: DUMMY_SP }))); | ||
} | ||
|
||
if self.use_spread { | ||
if self.use_spread || self.use_builtins { | ||
return self.fold_attrs_for_next_classic(attrs); | ||
} | ||
|
||
|
@@ -872,13 +870,7 @@ where | |
// calls `_extends` or `Object.assign` | ||
Box::new(Expr::Call(CallExpr { | ||
span: DUMMY_SP, | ||
callee: { | ||
if self.use_builtins { | ||
member_expr!(DUMMY_SP, Object.assign).as_callee() | ||
} else { | ||
helper!(extends, "extends") | ||
} | ||
}, | ||
callee: helper!(extends, "extends"), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this should be reverted There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't quite understand the difference between configuring use_buildin and use_spread. It looks like the public is the same, only one is {... } One is Object.assign There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe we can support issue without fixing it, just configure use_spread |
||
args, | ||
type_args: None, | ||
})) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like a regression.