This plugin allows Babel to transform boolean literals into !0
for true
and !1
for false
.
In
true;
false;
Out
!0;
!1;
npm install babel-plugin-transform-minify-booleans --save-dev
.babelrc
{
"plugins": ["transform-minify-booleans"]
}
babel --plugins transform-minify-booleans script.js
require("@babel/core").transform("code", {
plugins: ["transform-minify-booleans"]
});