-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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(es/transforms/compat): apply regenerator transform for default expr #2681
fix(es/transforms/compat): apply regenerator transform for default expr #2681
Conversation
83964c5
to
c7764b3
Compare
Thinking this more, I'm curious if there's specific reason it has to be FnExpr for the default exported fn: it looks like babel treats it as declaration regardless of async or not for the default export: https://astexplorer.net/#/gist/4e88e71b8c3f7e7094dc5a2bc5085a36/666b57be5110383e94f552dbd2e0f976b003251e |
Identifier of default function declaration is optional, while identifier of |
Got it. thoughts on current approach? |
c7764b3
to
286e00d
Compare
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.
Thanks!
I found some small performance issues.
// if fn is ExportDefaultDecl, fn is not FnDecl but FnExpr | ||
ModuleItem::ModuleDecl(ModuleDecl::ExportDefaultDecl(export_default)) => { | ||
if let DefaultDecl::Fn(fn_expr) = export_default.decl { | ||
let expr = fn_expr.fold_children_with(self); |
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.
Isn't this double-fold?
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.
Thanks for the catch, updated.
286e00d
to
7e1f7ab
Compare
7e1f7ab
to
95f0f06
Compare
95f0f06
to
85a4373
Compare
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.
Thank you!
LGTM.
PR updates transform to check defaultexportdecl and fold if there's fn expression to transpile default exported async fn.
One thing bit unsure is unlike other fn's
FnDecl
, if it'sExportDefaultDecl
fn is set toFnExpr
instead. PR doesn't touches those node but only touches transform instead for now.