-
-
Notifications
You must be signed in to change notification settings - Fork 484
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
feat(transform): support es2015 new target #1967
Conversation
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.
@Dunqing I think we need to add an AST nodes stack soon :-)
CodSpeed Performance ReportMerging #1967 will degrade performances by 5.78%Comparing Summary
Benchmarks breakdown
|
There's a https://github.com/oxc-project/oxc/blob/main/tasks/transform_conformance/README.md#--exec |
Done. |
Waiting for @Dunqing to merge. |
I will take a look this tonight 😩 |
Here implementing the es2015 new target transform, see detail at https://babel.dev/docs/babel-plugin-transform-template-new-target. Here has three kinds need to be distinguished. - `NewTargetKind::Method`, it from `AstKind::ObjectMethod` or `AstKind::MethodDefinitionKind::Get/Set/Method`. It will be transformed to `void 0`. - `NewTargetKind::Constructor`, is from ` AstKind::MethodDefinitionKind::Constructor`. It will be transformed to `this.constructor`. - `NewTargetKind::Function`, is from ` AstKind::Function`, here the function is not the above function. It will be transformed to `this instanceof _target ? this.constructor : void 0`, here `_target` comes from the function name or is created by scope uid ident.
Here implementing the es2015 new target transform, see detail at https://babel.dev/docs/babel-plugin-transform-template-new-target.
Here has three kinds need to be distinguished.
NewTargetKind::Method
, it fromAstKind::ObjectMethod
orAstKind::MethodDefinitionKind::Get/Set/Method
. It will be transformed tovoid 0
.NewTargetKind::Constructor
, is fromAstKind::MethodDefinitionKind::Constructor
. It will be transformed tothis.constructor
.NewTargetKind::Function
, is fromAstKind::Function
, here the function is not the above function. It will be transformed tothis instanceof _target ? this.constructor : void 0
, here_target
comes from the function name or is created by scope uid ident.