# jsx-compiler

> Parser for Rax JSX Statements.

Latest version **0.4.37** (published 2022-09-16) · BSD-3-Clause license · 0 weekly downloads

## Install

```sh
npm install jsx-compiler
pnpm add jsx-compiler
yarn add jsx-compiler
bun add jsx-compiler
```

## 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.4.37 |
| Published | 2022-09-16 |
| First published | 2019-04-12 |
| Weekly downloads | 0 |
| License | BSD-3-Clause |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 11 |
| Unpacked size | 277.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Rax Team |
| Maintainers | zeroling, likai757, solojiang, chriscindy, rax-publisher |

## Links

- npm: https://www.npmjs.com/package/jsx-compiler
- Homepage: https://github.com/raxjs/miniapp#readme
- npm.io page: https://npm.io/package/jsx-compiler

## Dependencies (11)

- [css](https://npm.io/package/css.md) ^2.2.4
- [md5](https://npm.io/package/md5.md) ^2.2.1
- [chalk](https://npm.io/package/chalk.md) ^2.4.2
- [resolve](https://npm.io/package/resolve.md) ^1.12.0
- [fs-extra](https://npm.io/package/fs-extra.md) ^7.0.1
- [kebab-case](https://npm.io/package/kebab-case.md) ^1.0.0
- [@babel/types](https://npm.io/package/@babel/types.md) ^7.3.4
- [@babel/parser](https://npm.io/package/@babel/parser.md) ^7.3.4
- [@babel/traverse](https://npm.io/package/@babel/traverse.md) ^7.3.4
- [@babel/generator](https://npm.io/package/@babel/generator.md) ^7.3.4
- [@babel/code-frame](https://npm.io/package/@babel/code-frame.md) ^7.0.0

## Recent versions

- 0.4.37 (latest) — 2022-09-16
- 0.4.38-3 (beta) — 2024-10-25
- 0.4.38-2 — 2022-12-05
- 0.4.38-1 — 2022-09-23
- 0.4.38-0 — 2022-09-19
- 0.4.37-0 — 2022-09-05
- 0.4.36-5 — 2022-03-22
- 0.4.36-4 — 2022-03-21
- 0.4.36 — 2021-11-29
- 0.4.36-3 — 2021-11-26
- 0.4.36-2 — 2021-11-26
- 0.4.36-1 — 2021-11-10
- 0.4.36-0 — 2021-11-04
- 0.4.35 — 2021-08-31
- 0.4.35-0 — 2021-08-27
- … 137 more at https://npm.io/package/jsx-compiler/versions

## README

# jsx-compiler

Transform JSX styled Rax Components into miniapp parts.

## example

input:

```jsx
import { Component } from 'rax';

export default class extends Component {

  render() {
    return (<view>hello world</view>);
  }
}
```

Run jsx compiler.

- type: Required, enum of `app`, `page`, `component`.
- outputPath: Required, string of dist path.
- sourcePath: Required, string of source path.
- resourcePath: Required, string of original file path.

```js
const compile = require('jsx-compiler');
const { baseOptions } = compile;

const output = compile(code, { ...baseOptions, type: 'component' });
```

output:

- ast
  - Babel 7 format AST of JS code
- imported
  - Imported modules and local identifiers
- exported
  - Exported identifiers
- template
  - axml template for miniapp
- code
  - Transformed JS code.
- map
  - Source map of JS code
- config
  - JS Object, miniapp config
- style
  - String, acss of style.
- usingComponents

eg.

```js
{
  ast: ASTNodeTree,
  imported: {
    rax: [
      {
        local: "Component",
        default: false,
        importFrom: "Component",
        name: "rax",
        external: true
      }
    ]
  },
  exported: ["default"],
  code:
    'import { createComponent as __create_component__, Component as __component__ } from "jsx2mp-runtime";\n\nconst __def__ = class extends __component__ {\n  render() {\n    return {};\n  }\n\n};\n\nComponent(__create_component__(__def__, {\n  events: []\n}));',
  map: null,
  config: {
    component: true
  },
  style: "",
  usingComponents: {},
  template: "<view>hello world</view>"
}
```

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