Skip to content

Latest commit

 

History

History

babel-plugin-minify-constant-folding

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

babel-plugin-minify-constant-folding

Tries to evaluate expressions and inline the result. For now only deals with numbers and strings.

Example

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";

Installation

$ npm install babel-plugin-minify-constant-folding

Usage

Via .babelrc (Recommended)

.babelrc

{
  "plugins": ["minify-constant-folding"]
}

Via CLI

$ babel --plugins minify-constant-folding script.js

Via Node API

require("babel-core").transform("code", {
  plugins: ["minify-constant-folding"]
});