Tries to evaluate expressions and inline the result. For now only deals with numbers and strings.
In
"a" + "b"
2 * 3;
4 | 3;
"b" + a + "c" + "d" + g + z + "f" + "h" + "z"
Out
"ab";
6;
7;
"b" + a + "cd" + g + z + "fhz";
npm install babel-plugin-minify-constant-folding
.babelrc
{
"plugins": ["minify-constant-folding"]
}
babel --plugins minify-constant-folding script.js
require("babel-core").transform("code", {
plugins: ["minify-constant-folding"]
});