npm install jsxtransformify -save
browserify -t jsxtransformify widget.js -o output.js
Only files with the /** @jsx DOM */ docblock will be parsed.
/** @jsx react.createElement */
var profile = <div>
<img src="avatar.png" class="profile" />
<h3>{[user.firstName, user.lastName].join(' ')}</h3>
</div>;
Transformed into JS:
var profile = react.createElement('div', null, [
react.createElement('img', { src: "avatar.png", class: "profile" }),
react.createElement('h3', null, [[user.firstName, user.lastName].join(' ')])
]);
/** @jsx h */
var h = require('virtual-dom/h');
var profile = <div>
<img src="avatar.png" class="profile" />
<h3>{[user.firstName, user.lastName].join(' ')}</h3>
</div>;
var h = require('virtual-dom/h');
var profile = h('div', null, [
h('img', { src: "avatar.png", class: "profile" }),
h('h3', null, [[user.firstName, user.lastName].join(' ')])
]);