mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Merge pull request #1322 from spicyj/transformer-harmony
Add optional harmony support to browser transform
This commit is contained in:
Vendored
+12
-5
@@ -22,7 +22,7 @@ var headEl;
|
||||
|
||||
var buffer = require('buffer');
|
||||
var transform = require('jstransform').transform;
|
||||
var visitors = require('./fbtransform/visitors').transformVisitors;
|
||||
var visitors = require('./fbtransform/visitors');
|
||||
var docblock = require('jstransform/src/docblock');
|
||||
|
||||
// The source-map library relies on Object.defineProperty, but IE8 doesn't
|
||||
@@ -31,16 +31,23 @@ var docblock = require('jstransform/src/docblock');
|
||||
// the source map in that case.
|
||||
var supportsAccessors = Object.prototype.hasOwnProperty('__defineGetter__');
|
||||
|
||||
function transformReact(source) {
|
||||
return transform(visitors.react, source, {
|
||||
function transformReact(source, options) {
|
||||
var visitorList;
|
||||
if (options && options.harmony) {
|
||||
visitorList = visitors.getAllVisitors();
|
||||
} else {
|
||||
visitorList = visitors.transformVisitors.react;
|
||||
}
|
||||
|
||||
return transform(visitorList, source, {
|
||||
sourceMap: supportsAccessors
|
||||
});
|
||||
}
|
||||
|
||||
exports.transform = transformReact;
|
||||
|
||||
exports.exec = function(code) {
|
||||
return eval(transformReact(code).code);
|
||||
exports.exec = function(code, options) {
|
||||
return eval(transformReact(code, options).code);
|
||||
};
|
||||
|
||||
var inlineScriptCount = 0;
|
||||
|
||||
Reference in New Issue
Block a user