# babel-plugin-minify-constant-folding

> Tries to evaluate expressions and inline the result.

Latest version **0.5.0** (published 2018-09-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install babel-plugin-minify-constant-folding
pnpm add babel-plugin-minify-constant-folding
yarn add babel-plugin-minify-constant-folding
bun add babel-plugin-minify-constant-folding
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.5.0 |
| Published | 2018-09-24 |
| First published | 2016-08-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 12.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4372 |
| Author | amasad |
| Maintainers | babeljs, boopathi, hzoo, loganfsmyth, vignesh.shanmugam |
| Keywords | babel-plugin |

## Links

- npm: https://www.npmjs.com/package/babel-plugin-minify-constant-folding
- Repository: https://github.com/babel/minify/tree/master/packages/babel-plugin-minify-constant-folding
- Homepage: https://github.com/babel/minify#readme
- Issues: https://github.com/babel/minify/issues
- npm.io page: https://npm.io/package/babel-plugin-minify-constant-folding

## Dependencies (1)

- [babel-helper-evaluate-path](https://npm.io/package/babel-helper-evaluate-path.md) ^0.5.0

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 0.5.0 (latest) — 2018-09-24
- 0.5.0-alpha.9 (canary) — 2018-09-23
- 0.5.0-alpha.3cc09dcf — 2018-07-27
- 0.5.0-alpha.beb87b9a — 2018-07-26
- 0.5.0-alpha.5a128fd5 — 2018-07-17
- 0.5.0-alpha.2ed85317 — 2018-07-17
- 0.5.0-alpha.a24dd066 — 2018-06-11
- 0.5.0-alpha.2e0de171 — 2018-06-01
- 0.5.0-alpha.89fc69da — 2018-06-01
- 0.5.0-alpha.a28b6b00 — 2018-05-22
- 0.5.0-alpha.2ec8ff72 — 2018-05-22
- 0.5.0-alpha.01eac1c3 — 2018-05-17
- 0.5.0-alpha.5dbc73f7 — 2018-05-17
- 0.5.0-alpha.830ce3f1 — 2018-05-17
- 0.5.0-alpha.9e447f6d — 2018-05-17
- … 66 more at https://npm.io/package/babel-plugin-minify-constant-folding/versions

## README

# babel-plugin-minify-constant-folding

Tries to evaluate expressions and inline the result.

## Example

**In**

```javascript
"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**

```javascript
"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

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

## Usage

### Via `.babelrc` (Recommended)

**.babelrc**

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

### Via CLI

```sh
babel --plugins minify-constant-folding script.js
```

### Via Node API

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

## Options

+ `tdz` - Account for TDZ (Temporal Dead Zone)

---
_Source: https://npm.io/package/babel-plugin-minify-constant-folding · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
