packages/babel-plugin-minify-simplify/src/if-statement.js
function toGuardedExpression(path) {
    const { node } = path;
    if (
      node.consequent &&
      !node.alternate &&
      node.consequent.type === "ExpressionStatement"
    ) {
      let op = "&&";
      if (t.isUnaryExpression(node.test, { operator: "!" })) {
        node.test = node.test.argument;
        op = "||";
      }

      path.replaceWith(
        t.expressionStatement(
          t.logicalExpression(op, node.test, node.consequent.expression)
        )
      );
      return REPLACED;
    }
  }
function toGuardedExpression(path) {
    const { node } = path;
    if (
      node.consequent &&
      !node.alternate &&
      node.consequent.type === "ExpressionStatement"
    ) {
      let op = "&&";
      if (t.isUnaryExpression(node.test, { operator: "!" })) {
        node.test = node.test.argument;
        op = "||";
      }

      path.replaceWith(
        t.expressionStatement(
          t.logicalExpression(op, node.test, node.consequent.expression)
        )
      );
      return REPLACED;
    }
  }
function toGuardedExpression ( path ) { const { node } = path ; if ( node . consequent && ! node . alternate && node . consequent . type === "ExpressionStatement" ) { let op = "&&" ; if ( t . isUnaryExpression ( node . test , { operator : "!" } ) ) { node . test = node . test . argument ; op = "||" ; } path . replaceWith ( t . expressionStatement ( t . logicalExpression ( op , node . test , node . consequent . expression ) ) ) ; return REPLACED ; } }
No alternate, make into a guarded expression
No alternate make into a guarded expression