Skip to content

Commit

Permalink
also check match_require to rewrite requires
Browse files Browse the repository at this point in the history
  • Loading branch information
wardpeet committed Nov 26, 2021
1 parent ca49498 commit b12d567
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions packages/transformers/js/core/src/utils.rs
Expand Up @@ -109,6 +109,12 @@ pub fn match_require(
if let Expr::Lit(Lit::Str(str_)) = &*arg.expr {
return Some(str_.value.clone());
}

if let ast::Expr::Tpl(_tpl) = &*arg.expr {
if _tpl.quasis.len() == 1 && _tpl.exprs.is_empty() {
return Some(_tpl.quasis[0].raw.clone().value);
}
}
}
}

Expand All @@ -120,6 +126,12 @@ pub fn match_require(
if let Expr::Lit(Lit::Str(str_)) = &*arg.expr {
return Some(str_.value.clone());
}

if let ast::Expr::Tpl(_tpl) = &*arg.expr {
if _tpl.quasis.len() == 1 && _tpl.exprs.is_empty() {
return Some(_tpl.quasis[0].raw.clone().value);
}
}
}
}

Expand Down

0 comments on commit b12d567

Please sign in to comment.