# babel-plugin-transform-redom-jsx

> Babel plugin for RE:DOM jsx

Latest version **3.0.6** (published 2024-08-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install babel-plugin-transform-redom-jsx
pnpm add babel-plugin-transform-redom-jsx
yarn add babel-plugin-transform-redom-jsx
bun add babel-plugin-transform-redom-jsx
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.0.6 |
| Published | 2024-08-12 |
| First published | 2016-11-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 8.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 20 |
| Author | Tomer Igal |
| Maintainers | tomerigal |
| Keywords | babel, redom, jsx |

## Links

- npm: https://www.npmjs.com/package/babel-plugin-transform-redom-jsx
- Repository: https://github.com/tomerigal/babel-plugin-transform-redom-jsx
- Homepage: https://github.com/tomerigal/babel-plugin-transform-redom-jsx#readme
- Issues: https://github.com/tomerigal/babel-plugin-transform-redom-jsx/issues
- npm.io page: https://npm.io/package/babel-plugin-transform-redom-jsx

## Dependencies (1)

- [@babel/plugin-syntax-jsx](https://npm.io/package/@babel/plugin-syntax-jsx.md) ^7.24.7

## 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

- 3.0.6 (latest) — 2024-08-12
- 3.0.5 — 2022-05-28
- 3.0.4 — 2022-01-25
- 3.0.3 — 2021-09-15
- 3.0.2 — 2021-05-11
- 3.0.1 — 2020-06-02
- 3.0.0 — 2020-03-24
- 2.0.1 — 2019-08-13
- 2.0.0 — 2018-11-12
- 1.0.5 — 2017-06-03
- 1.0.4 — 2017-02-03
- 1.0.3 — 2016-11-22
- 1.0.2 — 2016-11-19
- 1.0.1 — 2016-11-19
- 1.0.0 — 2016-11-19

## README

# babel-plugin-transform-redom-jsx

[![Build Status](https://github.com/tomerigal/babel-plugin-transform-redom-jsx/workflows/tests/badge.svg)](https://github.com/tomerigal/babel-plugin-transform-redom-jsx/actions)
[![npm version](https://badge.fury.io/js/babel-plugin-transform-redom-jsx.svg)](https://badge.fury.io/js/babel-plugin-transform-redom-jsx)

## Installation

```bash
npm install babel-plugin-transform-redom-jsx --save-dev
```

## Usage

### Babel config:

```json
{
  "plugins": [
    "babel-plugin-transform-redom-jsx",
    [
      "transform-react-jsx",
      {
        "pragma": "el"
      }
    ]
  ]
}
```

### Component

The plugin transpiles the following JSX:

```jsx
import { el, text, mount } from "redom";
class A {
  constructor(attr, text) {
    <div this="el">
      <h3>{attr.title}</h3>
      <span this="span">Hello</span> {text}
    </div>;
  }
  update() {
    this.span.textContent = "Hi";
  }
}

class B {
  constructor() {
    <div this="el">
      <A this="a" title="Hello World example">
        <span this="span">World</span>
      </A>
    </div>;
  }
  update() {
    this.span.textContent = "You";
    this.a.update();
  }
}

const b = <B />;

mount(document.body, b);

b.update();
```

To the following JavaScript:

```js
import { el, text, mount } from "redom";
class A {
  constructor(attr, text) {
    this["el"] = el(
      "div",
      null,
      el("h3", null, attr.title),
      (this["span"] = el("span", null, "Hello")),
      " ",
      text
    );
  }
  update() {
    this.span.textContent = "Hi";
  }
}

class B {
  constructor() {
    this["el"] = el(
      "div",
      null,
      (this["a"] = new A(
        { title: "Hello World example" },
        (this["span"] = el("span", null, "World"))
      ))
    );
  }
  update() {
    this.span.textContent = "You";
    this.a.update();
  }
}

const b = new B({});

mount(document.body, b);

b.update();
```

### Assign to this

The plugin transpiles the following JSX:

```jsx
import { el, mount } from "redom";

// define Login component
class Login {
  constructor() {
    <form
      this="el"
      id="login"
      onsubmit={(e) => {
        e.preventDefault();
        const email = this.email.value;
        const pass = this.pass.value;
        console.log(email, pass);
      }}
    >
      <input type="email" class="email" this="email" />
      <input type="password" class="pass" this="pass" />
      <button type="submit">Sign in</button>
    </form>;
  }
}

// mount to DOM
mount(document.body, <Login />);
```

To the following JavaScript:

```js
import { el, mount } from "redom";

// define Login component
class Login {
  constructor() {
    this["el"] = el(
      "form",
      {
        id: "login",
        onsubmit: (e) => {
          e.preventDefault();
          const email = this.email.value;
          const pass = this.pass.value;
          console.log(email, pass);
        },
      },
      (this["email"] = el("input", { type: "email", class: "email" })),
      (this["pass"] = el("input", { type: "password", class: "pass" })),
      el("button", { type: "submit" }, "Sign in")
    );
  }
}

// mount to DOM
mount(document.body, new Login());
```

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