Static eval for arrow functions

This commit is contained in:
Andrew Morris
2023-07-24 14:49:38 +10:00
parent d3383ff11e
commit 72a7ab5c37
2 changed files with 12 additions and 1 deletions

View File

@@ -1046,8 +1046,14 @@ impl ModuleCompiler {
Value::String("(error)".to_string())
}
},
swc_ecma_ast::Expr::Arrow(arrow) => {
let p = self.allocate_defn_numbered("_anon");
let mut fn_defns = self.compile_fn(p.clone(), None, Functionish::Arrow(arrow.clone()));
self.module.definitions.append(&mut fn_defns);
Value::Pointer(p)
}
swc_ecma_ast::Expr::TaggedTpl(_)
| swc_ecma_ast::Expr::Arrow(_)
| swc_ecma_ast::Expr::Class(_)
| swc_ecma_ast::Expr::Yield(_)
| swc_ecma_ast::Expr::MetaProp(_)