It\'s pretty easy to do this with coffee-script.
var coffee = require(\'coffee-script\'); coffee.compile(\"a = 1\"); //=> \'(function() {\\n var a;\\n\\n a
It seems that nowadays there is a simpler solution, you can do:
let ts = require('typescript'); let source = ts.transpileModule('class Test {}', {}).outputText;
This results in:
"use strict"; var Test = (function () { function Test() { } return Test; }());