You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
reactify transform also can compile a limited set of es6 syntax constructs
into es5. Supported features are arrow functions, rest params, templates, object
short notation and classes. You can activate this via --es6 or --harmony
boolean option:
% browserify -t [ reactify --es6 ] main.js
es6 class getter and setter methods can be activated via --target es5 option:
Code in 3rd-party packages isn't being transformed by reactify
By default Browserify applies transforms only for modules in the current package. That means that if there are modules with JSX in packages in node_modules/ directory then browserify will throw SyntaxError left and right even if you are using reactify.
The best way to fix that is ask package author to publish to npm with code compiled down to plain ES5 which is runnable in browsers and Node.js as-is.
Another approach is to ask to add
"browserify": {
"transform": ["reactify"]
}
to the package's package.json. That will make Browserify apply reactify transform for that package too.
Another way is to activate reactify with -g option which will instruct Browserify to apply reactify to every module it encounters:
% browserify -g reactify main.js
Note that this will lead to slower builds as every module will be parsed and transformed by reactify even if it doesn't have JSX code in it.
About
[DEPRECATED] Browserify transform for JSX (superset of JavaScript used in React library by Facebook)