fix: eval?.() is indirect (#11850)

This commit is contained in:
Huáng Jùnliàng
2020-07-20 17:06:27 -04:00
committed by GitHub
parent 238cadda4c
commit e51a91e131
6 changed files with 86 additions and 1 deletions

View File

@@ -78,7 +78,11 @@ export default declare((api, options) => {
let ref;
let check;
if (loose && isCall && isSimpleMemberExpression(chain)) {
if (isCall && t.isIdentifier(chain, { name: "eval" })) {
check = ref = chain;
// `eval?.()` is an indirect eval call transformed to `(0,eval)()`
node[replaceKey] = t.sequenceExpression([t.numericLiteral(0), ref]);
} else if (loose && isCall && isSimpleMemberExpression(chain)) {
// If we are using a loose transform (avoiding a Function#call) and we are at the call,
// we can avoid a needless memoize. We only do this if the callee is a simple member
// expression, to avoid multiple calls to nested call expressions.