# babel-plugin-transform-private-class-members

> Mangle JavaScript private class members

Latest version **0.1.0** (published 2021-10-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install babel-plugin-transform-private-class-members
pnpm add babel-plugin-transform-private-class-members
yarn add babel-plugin-transform-private-class-members
bun add babel-plugin-transform-private-class-members
```

## 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.1.0 |
| Published | 2021-10-17 |
| First published | 2021-10-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Richard Dobroň |
| Maintainers | dobron |
| Keywords | babel-plugin |

## Links

- npm: https://www.npmjs.com/package/babel-plugin-transform-private-class-members
- Repository: https://github.com/richardDobron/babel-plugin-transform-private-class-members
- Homepage: https://github.com/richardDobron/babel-plugin-transform-private-class-members#readme
- Issues: https://github.com/richardDobron/babel-plugin-transform-private-class-members/issues
- npm.io page: https://npm.io/package/babel-plugin-transform-private-class-members

## 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.1.0 (latest) — 2021-10-17

## README

# babel-plugin-transform-private-class-members ![](https://github.com/richardDobron/babel-plugin-transform-private-class-members/workflows/tests/badge.svg) [![npm](https://img.shields.io/npm/v/babel-plugin-transform-private-class-members.svg)](https://www.npmjs.com/package/babel-plugin-transform-private-class-members)

Mangle JavaScript private class members.

## Installation

```
$ npm install babel-plugin-transform-private-class-members
```

## Usage

### Via `.babelrc` (Recommended)

**.babelrc**

```json
{
  "plugins": ["babel-plugin-transform-private-class-members"]
}
```

### Via CLI

```sh
$ babel --plugins babel-plugin-transform-private-class-members script.js
```

### Via Node API

```javascript
require("babel-core").transform("code", {
  plugins: ["babel-plugin-transform-private-class-members"]
});
```

## Example

Input file:

```js
class Rectangle {
    result = null;

    constructor(height, width) {
        this._height = height;
        this._width = width;
    }

    area() {
        if (this.result === null) {
            this.result = this._calcArea();
        }

        return this.result;
    }

    _calcArea() {
        return this._height * this._width;
    }
}
```

Output:

```js
class Rectangle {
    result = null;

    constructor(height, width) {
        this.$1 = height;
        this.$2 = width;
    }

    area() {
        if (this.result === null) {
            this.result = this.$3();
        }

        return this.result;
    }

    $3() {
        return this.$1 * this.$2;
    }
}
```

## Options

| Option      | Description                                               | Default                                     |
| ----------- | --------------------------------------------------------- | ------------------------------------------- |
| blacklist   | A RegEx defining which members to ignore                  | *[ /^_super.*/, /^__.*/, /^_$/, /^[^_].*/ ] |
| memoize     | Keep mangle position and keys for another transform       | *false*                                     |
| onlyClass   | Replace only private class members and properties         | *true*                                      |

## License

This plugin is licensed under the MIT license. See [LICENSE](./LICENSE).

---
_Source: https://npm.io/package/babel-plugin-transform-private-class-members · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
