babel plugin for simple jsx to string transformation
npm install babel-plugin-transform-simple-jsx bash
npm install\
babel-plugin-transform-simple-jsx\
babel-preset-env\
--save-dev
`
In your .babelrc:
` json
{
"presets": ["@babel/preset-env"],
"plugins": ["babel-plugin-transform-simple-jsx"]
}
`
The plugin transpiles the following E4X code:
` js
const fooId = 'foo-id';
const barText = 'bar text';
const html = (
{barText}
);
`
To the following JavaScript:
` js
var JSX = require("simple-jsx");
var fooId = 'foo-id';
var barText = 'bar text';
var html = JSX("" + (barText) + "");
`
See tests for more examples and details.
Examples
$3
* Client side web rendering example using jsx
* Server side web rendering example using jsx
Requirements
- Babel 7 compatible
Developing
$3
* simple-jsx
$3
* root: Contains the README.md, the main configuration to execute the project such as package.json or any other configuration files.
* lib: Contains the source code for plugin.
* test: Contains library tests and examples.
* examples: Contains library examples.
* node_modules: Contains third party JS libraries used in this project
$3
Download the code
`shell
git clone git@github.com:pikamachu/pika-babel-plugin-transform-simple-jsx.git
cd pika-babel-plugin-transform-simple-jsx
`
Install dependencies
`shell
bash pika install
`
Run application tests.
`shell
bash pika test
``