babel-plugin-minify-guarded-expressions

In

  1. !x && foo();
  2. alert(0 && new Foo());

Out

  1. x || foo();
  2. alert(0);

Installation

  1. npm install babel-plugin-minify-guarded-expressions --save-dev

Usage

.babelrc

  1. {
  2. "plugins": ["minify-guarded-expressions"]
  3. }

Via CLI

  1. babel --plugins minify-guarded-expressions script.js

Via Node API

  1. require("@babel/core").transform("code", {
  2. plugins: ["minify-guarded-expressions"]
  3. });