babel-plugin-minify-constant-folding
Tries to evaluate expressions and inline the result.
Last updated 2 years ago by boopathi .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install babel-plugin-minify-constant-folding 
SYNC missed versions from official npm registry.

babel-plugin-minify-constant-folding

Tries to evaluate expressions and inline the result.

Example

In

"a" + "b"
2 * 3;
4 | 3;
"b" + a + "c" + "d" + g + z + "f" + "h" + "i"

[a, b, c].concat([d, e], f, g, [h]);
["a", "b", "c"].join();
["a", "b", "c"].join('@');
[1, 2, 3].length;
[1, 2, 3][1];
[1, 2, 3].shift();
[1, 2, 3].slice(0, 2);
[a, b, c].pop();
[a, b, c].reverse();
"a,b,c".split(",");
"abc"[0];
"abc".charAt();
"abc".charAt(1);
"abc".length;

Out

"ab";
6;
7;
"b" + a + "cd" + g + z + "fhi";

[a, b, c, d, e, f, g, h];
"a,b,c";
"a@b@c";
3;
2;
2;
[1, 2];
c;
[c, b, a];
["a", "b", "c"];
"a";
"a";
"a";
"b";
3;

Installation

npm install babel-plugin-minify-constant-folding --save-dev

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"]
});

Options

  • tdz - Account for TDZ (Temporal Dead Zone)

Current Tags

  • 0.5.0-alpha.9                                ...           canary (2 years ago)
  • 0.5.0                                ...           latest (2 years ago)

81 Versions

  • 0.5.0                                ...           2 years ago
  • 0.5.0-alpha.9                                ...           2 years ago
  • 0.5.0-alpha.3cc09dcf                                ...           2 years ago
  • 0.5.0-alpha.beb87b9a                                ...           2 years ago
  • 0.5.0-alpha.5a128fd5                                ...           2 years ago
  • 0.5.0-alpha.2ed85317                                ...           2 years ago
  • 0.5.0-alpha.a24dd066                                ...           2 years ago
  • 0.5.0-alpha.2e0de171                                ...           2 years ago
  • 0.5.0-alpha.89fc69da                                ...           2 years ago
  • 0.5.0-alpha.a28b6b00                                ...           2 years ago
  • 0.5.0-alpha.2ec8ff72                                ...           2 years ago
  • 0.5.0-alpha.01eac1c3                                ...           2 years ago
  • 0.5.0-alpha.5dbc73f7                                ...           2 years ago
  • 0.5.0-alpha.830ce3f1                                ...           2 years ago
  • 0.5.0-alpha.9e447f6d                                ...           2 years ago
  • 0.5.0-alpha.3b1a8f05                                ...           2 years ago
  • 0.5.0-alpha.367cc048                                ...           2 years ago
  • 0.5.0-alpha.36b27d42                                ...           2 years ago
  • 0.5.0-alpha.7ba5821f                                ...           2 years ago
  • 0.5.0-alpha.7195fa98                                ...           2 years ago
  • 0.5.0-alpha.1cb46b73                                ...           2 years ago
  • 0.5.0-alpha.85c9b6d8                                ...           2 years ago
  • 0.5.0-alpha.6889f45d                                ...           2 years ago
  • 0.5.0-alpha.91ed3622                                ...           2 years ago
  • 0.4.3                                ...           2 years ago
  • 0.5.0-alpha.b5637c57                                ...           2 years ago
  • 0.4.2                                ...           2 years ago
  • 0.5.0-alpha.540d75e7                                ...           2 years ago
  • 0.5.0-alpha.bce578e2                                ...           2 years ago
  • 0.5.0-alpha.18dcfe13                                ...           2 years ago
  • 0.5.0-alpha.9939bca9                                ...           2 years ago
  • 0.5.0-alpha.5f601890                                ...           2 years ago
  • 0.5.0-alpha.34c3efe9                                ...           2 years ago
  • 0.5.0-alpha.9e986477                                ...           2 years ago
  • 0.5.0-alpha.e86a44f1                                ...           2 years ago
  • 0.4.1                                ...           2 years ago
  • 0.5.0-alpha.e9f96ffe                                ...           2 years ago
  • 0.5.0-alpha.8b905991                                ...           2 years ago
  • 0.5.0-alpha.b4285271                                ...           2 years ago
  • 0.5.0-alpha.7b176463                                ...           2 years ago
  • 0.5.0-alpha.55276695                                ...           2 years ago
  • 0.5.0-alpha.b5bafaeb                                ...           2 years ago
  • 0.5.0-alpha.72092d20                                ...           2 years ago
  • 0.4.0                                ...           2 years ago
  • 0.4.0-alpha.caaefb4c                                ...           2 years ago
  • 0.4.0-alpha.f95869d4                                ...           2 years ago
  • 0.4.0-alpha.12994a48                                ...           2 years ago
  • 0.4.0-alpha.4b14df35                                ...           2 years ago
  • 0.4.0-alpha.6546ad11                                ...           2 years ago
  • 0.4.0-alpha.15ca1f11                                ...           2 years ago
  • 0.3.0                                ...           2 years ago
  • 0.3.0-alpha.4143a25b                                ...           2 years ago
  • 0.3.0-alpha.71b0b884                                ...           2 years ago
  • 0.3.0-alpha.6ceffb8d                                ...           2 years ago
  • 0.3.0-alpha.636ae276                                ...           2 years ago
  • 0.3.0-alpha.ab81368f                                ...           2 years ago
  • 0.3.0-alpha.ac576234                                ...           2 years ago
  • 0.3.0-alpha.879f25ec                                ...           3 years ago
  • 0.3.0-alpha.5ee3078e                                ...           3 years ago
  • 0.3.0-alpha.8857f145                                ...           3 years ago
  • 0.3.0-alpha.169f8743                                ...           3 years ago
  • 0.3.0-alpha.6ae655c0                                ...           3 years ago
  • 0.3.0-alpha.d9c99d3f                                ...           3 years ago
  • 0.3.0-alpha.a351eeed                                ...           3 years ago
  • 0.3.0-alpha.cf9a0da2                                ...           3 years ago
  • 0.3.0-alpha.e6a189cd                                ...           3 years ago
  • 0.3.0-alpha.670b24ec                                ...           3 years ago
  • 0.3.0-alpha.7f4dc3d4                                ...           3 years ago
  • 0.3.0-alpha.033d9ab6                                ...           3 years ago
  • 0.3.0-alpha.37064b40                                ...           3 years ago
  • 0.3.0-alpha.9a74dfd1                                ...           3 years ago
  • 0.3.0-alpha.a7421897                                ...           3 years ago
  • 0.3.0-alpha.da60c6b8                                ...           3 years ago
  • 0.2.0                                ...           3 years ago
  • 0.1.3                                ...           3 years ago
  • 0.1.2                                ...           3 years ago
  • 0.1.1                                ...           3 years ago
  • 0.1.0                                ...           3 years ago
  • 0.0.4                                ...           3 years ago
  • 0.0.3                                ...           4 years ago
  • 0.0.1                                ...           4 years ago

Copyright 2014 - 2017 © taobao.org |