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.
Anthony van der Hoorn committed
Jul 3, 2014 at 08:20 UTC
4ecde425f9012f3ecad0144a317a03a8977bfa2a
1 file changed
+12
main.js
+12
@@ -19,6 +19,18 @@ module.exports = {
19
output += '\n' + map;
20
}
21
return output;
22
+ },
23
+ transformAsObject: function(input, options) {
24
+ options = options || {};
25
+ var visitorList = getVisitors(options.harmony);
26
+ var resultRaw = transform(visitorList, input, options);
27
+ var result = {
28
+ code: resultRaw.code
29
+ };
30
+ if (options.sourceMap) {
31
+ result.sourceMap = resultRaw.sourceMap;
32
+ }
33
+ return result;
34
}
35
};
36