From 4ecde425f9012f3ecad0144a317a03a8977bfa2a Mon Sep 17 00:00:00 2001 From: Anthony van der Hoorn Date: Thu, 3 Jul 2014 08:20:55 -0400 Subject: [PATCH] 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. --- main.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/main.js b/main.js index b6a0dbc593..4a3d47f016 100644 --- a/main.js +++ b/main.js @@ -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; } };