first commit

This commit is contained in:
armansansd
2023-07-12 16:31:19 +01:00
commit 3424b1927b
23306 changed files with 2217776 additions and 0 deletions
+22
View File
@@ -0,0 +1,22 @@
var recast = require('recast');
var transform = require('./transform-tree.js');
module.exports = function(input, options) {
options || (options = {});
var sourceFileName = options.sourceFileName || '';
var sourceMapName = options.sourceMapName || '';
var createSourceMap = sourceFileName && sourceMapName;
var tree = recast.parse(input, {
'sourceFileName': sourceFileName
});
tree = transform(tree);
if (createSourceMap) {
// If a source map was requested, return an object with `code` and `map`
// properties.
return recast.print(tree, {
'sourceMapName': sourceMapName
});
}
// If no source map was requested, return the transpiled code directly.
return recast.print(tree).code;
};