# react-jsx-anywhere

> Parse react jsx tags to javascript

Latest version **0.1.2** (published 2015-05-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-jsx-anywhere
pnpm add react-jsx-anywhere
yarn add react-jsx-anywhere
bun add react-jsx-anywhere
```

## 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.2 |
| Published | 2015-05-03 |
| First published | 2015-03-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | SSen |
| Maintainers | ssen |
| Keywords | react, jsx, gulp, grunt, webpack |

## Links

- npm: https://www.npmjs.com/package/react-jsx-anywhere
- Repository: https://github.com/iamssen/react-jsx-anywhere
- Issues: https://github.com/iamssen/react-jsx-anywhere/issues
- npm.io page: https://npm.io/package/react-jsx-anywhere

## Dependencies (5)

- [gulp](https://npm.io/package/gulp.md) ^3.8.11
- [through](https://npm.io/package/through.md) ^2.3.6
- [gulp-util](https://npm.io/package/gulp-util.md) ^3.0.4
- [react-tools](https://npm.io/package/react-tools.md) ^0.13.2
- [event-stream](https://npm.io/package/event-stream.md) ^3.2.2

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 0.1.2 (latest) — 2015-05-03
- 0.1.1 — 2015-03-05
- 0.1.0 — 2015-03-02

## README

# Write JSX Tags Anywhere

## Install

```js
npm install react-jsx-anywhere
```

## JSX Tags

### Coffeescript

```coffee
@element = jsx("""<Component str="string" num={100} obj={{a:1, b:2}}/>""")

// @element = (React.createElement(Component, {str: "string", num: 123, obj: {a:1, b:2}}))
```

### Typescript

```typescript
///<reference path="node_modules/react-jsx-anywhere/jsx.d.ts"/>

var element:React.ReactElement = jsx(`<Component str="string" num={100} obj={{a:1, b:2}}/>`)

// var element:React.ReactElement = (React.createElement(Component, {str: "string", num: 123, obj: {a:1, b:2}}))
```

_IntelliJ IDE Typescript template string support is version 14.1 and higher_

### Javascript (ECMAScript6)

```javascript
var element = jsx(`<Component str="string" num={100} obj={{a:1, b:2}}/>`)

// var element = (React.createElement(Component, {str: "string", num: 123, obj: {a:1, b:2}}))
```


## Build

### Gulp.js

#### [Coffeescript](samples/gulp-coffeescript/gulpfile.js)

```coffee
'use strict'

var path = require('path')
var gulp = require('gulp')
var coffeescript = require('gulp-coffee')
var jsx = require('react-jsx-anywhere/gulp')

gulp.task('build', function () {
  return gulp.src('src/script.coffee')
    .pipe(jsx())
    .pipe(coffeescript())
    .pipe(gulp.dest('dist/'))
})
```

#### [Typescript](samples/gulp-typescript/gulpfile.js)

```typescript
'use strict'

var gulp = require('gulp')
var typescript = require('gulp-typescript')
var jsx = require('react-jsx-anywhere/gulp')

gulp.task('build', function () {
  return gulp.src('src/script.ts')
    .pipe(jsx())
    .pipe(typescript({
      target: 'ES5',
      module: 'commonjs',
      declarationFiles: true,
      noExternalResolve: false
    }))
    .pipe(gulp.dest('dist/'))
})
```

#### [ECMAScript6](samples/gulp-es6/gulpfile.js)

```javascript
'use strict'

var gulp = require('gulp')
var babel = require('gulp-babel')
var jsx = require('react-jsx-anywhere/gulp')

gulp.task('build', function () {
  return gulp.src('src/script.js')
    .pipe(jsx())
    .pipe(babel())
    .pipe(gulp.dest('dist/'))
})
```


### Webpack

#### [Coffeescript](samples/webpack-coffeescript/webpack.config.js)

```js
'use strict'

module.exports = {
  entry: 'src/script.coffee',
  output: {
    path: 'dist',
    filename: 'script.js'
  },
  resolve: {
    root: __dirname,
    extensions: ['', '.js', '.coffee']
  },
  module: {
    loaders: [
      {test: /\.coffee$/, loaders: ['coffee-loader', 'react-jsx-anywhere/webpack']}
    ]
  }
}
```

#### [ECMAScript6](samples/webpack-es6/webpack.config.js)

```js
'use strict'

module.exports = {
  entry: 'src/script.js',
  output: {
    path: 'dist',
    filename: 'script.js'
  },
  resolve: {
    root: __dirname,
    extensions: ['', '.js']
  },
  module: {
    loaders: [
      {test: /\.js$/, loaders: ['babel-loader', 'react-jsx-anywhere/webpack']}
    ]
  }
}
```

#### [Typescript](samples/webpack-typescript/webpack.config.js)

```js
'use strict'

module.exports = {
  entry: 'src/script.ts',
  output: {
    path: 'dist',
    filename: 'script.js'
  },
  resolve: {
    root: __dirname,
    extensions: ['', '.js', '.ts']
  },
  module: {
    loaders: [
      {test: /\.ts$/, loaders: ['ts-loader', 'react-jsx-anywhere/webpack']}
    ]
  }
}
```


### Browserify

```sh
browserify -t react-jsx-anywhere/browserify src/script.coffee -o dist/script.js
```


### Jsx Parser Function

```js
var fs = require('fs')
var jsxParser = require('react-jsx-anywhere')

var origin = fs.readFileSync('src/script.ts', {encode:'utf8'}) // 'var element:React.ReactElement = jsx(`<Component str="string" num={100} obj={{a:1, b:2}}/>`)'
var parsed = jsxParser(origin)

fs.writeFileSync('dist/script.js', parsed)
```

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