fix(es/minifier): Abort sequential inliner on optional chaining (#6637)

**Related issue:**

 - Closes https://github.com/swc-project/swc/issues/6636.
This commit is contained in:
Donny/강동윤 2022-12-14 13:45:47 +09:00 committed by GitHub
parent 4986694d4c
commit e4e4d6cf6b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 22 additions and 1 deletions

View File

@ -1546,7 +1546,9 @@ where
}
match b {
Expr::Update(..) | Expr::Arrow(..) | Expr::Fn(..) => return Ok(false),
Expr::Update(..) | Expr::Arrow(..) | Expr::Fn(..) | Expr::OptChain(..) => {
return Ok(false)
}
Expr::Cond(b) => {
trace_op!("seq: Try test of cond");

View File

@ -0,0 +1,7 @@
{
"passes": 2,
"toplevel": true,
"defaults": true,
"sequences": true,
"collapse_vars": true
}

View File

@ -0,0 +1,8 @@
export function memo(fn, opts) {
let result;
return () => {
result = fn(...newDeps);
opts?.onChange?.(result);
return result;
};
}

View File

@ -0,0 +1,4 @@
export function memo(fn, opts) {
let result;
return ()=>(result = fn(...newDeps), opts?.onChange?.(result), result);
}