# register-jsx

> babel-less require hook for jsx transpilation

Latest version **2.0.3** (published 2023-12-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install register-jsx
pnpm add register-jsx
yarn add register-jsx
bun add register-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 | 2.0.3 |
| Published | 2023-12-07 |
| First published | 2016-09-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 5.5 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 4 |
| Author | @gellerthegyi |
| Maintainers | gerhardberger, brenca |
| Keywords | jsx, require, extension, transpile |

## Links

- npm: https://www.npmjs.com/package/register-jsx
- Repository: https://github.com/gerhardberger/register-jsx
- Homepage: https://github.com/gerhardberger/register-jsx#readme
- Issues: https://github.com/gerhardberger/register-jsx/issues
- npm.io page: https://npm.io/package/register-jsx

## Dependencies (4)

- [find-root](https://npm.io/package/find-root.md) ^1.1.0
- [minimatch](https://npm.io/package/minimatch.md) ^3.0.4
- [mime-types](https://npm.io/package/mime-types.md) ^2.1.11
- [jsx-transform-modern](https://npm.io/package/jsx-transform-modern.md) ^2.0.3

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

- 2.0.3 (latest) — 2023-12-07
- 2.0.2 — 2023-12-06
- 2.0.1 — 2022-04-28
- 2.0.0 — 2022-04-25
- 1.0.2 — 2017-11-21
- 1.0.1 — 2016-11-09
- 1.0.0 — 2016-09-07

## README

# register-jsx

a simple require hook for jsx transpilation without babel or react

``` jsx
// a.jsx

const tr = (name, options, children) => {
  return { name, options, children }
}

module.exports = <foo>
  <bar a={123} />
</foo>
```

``` js
require('register-jsx')({ factory: 'tr' })

console.log(require('a.jsx'))
/*
  {
    name: 'foo',
    options: undefined,
    children: [{
      name: 'bar',
      options: { a: 123 },
      children: undefined
    }]
  }
*/
```

## install

```
$ npm i register-jsx
```

## usage

#### `require('register-jsx')(options)`

it uses [**jsx-transform**](https://github.com/alexmingoia/jsx-transform) for transpiling and `options` are just passed onto [`jsxTransform.fromFile`](https://github.com/alexmingoia/jsx-transform#module_jsx-transform..fromFile).

it returns the `jsxTransform` object.

Starting from version `1.0.2`, the module ignores everything inside `node_modules` folders, and can also ignore other files if a `.jsxignore` file is present in the project's root directory. The `.jsxignore` file must have one pattern per line, and the lines are first trimmed, and then matched using `minimatch`.

## test

```
$ npm test
```

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