mirror of
https://github.com/swc-project/swc.git
synced 2024-10-05 04:39:06 +03:00
feat(es/minifier): Handle boolean in Evaluator
(#6756)
**Related issue:** - Closes https://github.com/swc-project/swc/issues/5953.
This commit is contained in:
parent
48902b60d3
commit
8a6a1cbcf1
@ -88,10 +88,13 @@ impl Evaluator {
|
||||
match e {
|
||||
Expr::Seq(s) => return self.eval(s.exprs.last()?),
|
||||
|
||||
Expr::Lit(l @ Lit::Null(..))
|
||||
| Expr::Lit(l @ Lit::Num(..) | l @ Lit::Str(..) | l @ Lit::BigInt(..)) => {
|
||||
return Some(EvalResult::Lit(l.clone()))
|
||||
}
|
||||
Expr::Lit(
|
||||
l @ Lit::Num(..)
|
||||
| l @ Lit::Str(..)
|
||||
| l @ Lit::BigInt(..)
|
||||
| l @ Lit::Bool(..)
|
||||
| l @ Lit::Null(..),
|
||||
) => return Some(EvalResult::Lit(l.clone())),
|
||||
|
||||
Expr::Tpl(t) => {
|
||||
return self.eval_tpl(t);
|
||||
|
@ -66,6 +66,12 @@ fn simple() {
|
||||
assert_eq!(eval("const foo = 4", "foo").unwrap(), "4");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn eval_lit() {
|
||||
assert_eq!(eval("", "true").unwrap(), "true");
|
||||
assert_eq!(eval("", "false").unwrap(), "false");
|
||||
}
|
||||
|
||||
struct PartialInliner {
|
||||
marks: Marks,
|
||||
eval: Option<Evaluator>,
|
||||
|
Loading…
Reference in New Issue
Block a user