mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
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:
@@ -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;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user