Update React-tools to support transform as object

This change adds an additional function to the exported object to support getting access to the transformed result as an object rather than just a string result - the separate function designed to maintain backwards compatibility. 

This facilitates tools that want the code separate from the sourcemap or anything else as time goes by.
This commit is contained in:
Anthony van der Hoorn
2014-07-03 08:20:55 -04:00
parent 12479d3d20
commit 4ecde425f9
+12
View File
@@ -19,6 +19,18 @@ module.exports = {
output += '\n' + map;
}
return output;
},
transformAsObject: function(input, options) {
options = options || {};
var visitorList = getVisitors(options.harmony);
var resultRaw = transform(visitorList, input, options);
var result = {
code: resultRaw.code
};
if (options.sourceMap) {
result.sourceMap = resultRaw.sourceMap;
}
return result;
}
};