$ npm install babel-plugin-minify-simplify
Simplifies code for minification by reducing statements into expressions and making expressions uniform where possible.
In
function foo() {
if (x) a();
}
function foo2() {
if (x) a();
else b();
}
Out
function foo() {
x && a();
}
function foo2() {
x ? a() : b();
}
In
undefined
foo['bar']
Number(foo)
Out
void 0
foo.bar
+foo
npm install babel-plugin-minify-simplify
.babelrc
(Recommended).babelrc
{
"plugins": ["minify-simplify"]
}
babel --plugins minify-simplify script.js
require("@babel/core").transform("code", {
plugins: ["minify-simplify"]
});
© 2010 - cnpmjs.org x YWFE | Home | YWFE