Skip to content

Commit

Permalink
Merge pull request facebook#1322 from spicyj/transformer-harmony
Browse files Browse the repository at this point in the history
Add optional harmony support to browser transform
  • Loading branch information
vjeux committed Mar 29, 2014
2 parents 999b4cf + e6c93f9 commit 98ef7ab
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions vendor/browser-transforms.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand Down

0 comments on commit 98ef7ab

Please sign in to comment.