babel-plugin-minify-guarded-expressions
In
!x && foo();
alert(0 && new Foo());
Out
x || foo();
alert(0);
Installation
npm install babel-plugin-minify-guarded-expressions --save-dev
Usage
With a configuration file (Recommended)
{
"plugins": ["minify-guarded-expressions"]
}
Via CLI
babel --plugins minify-guarded-expressions script.js
Via Node API
require("@babel/core").transformSync("code", {
plugins: ["minify-guarded-expressions"]
});