Created
September 1, 2014 20:42
-
-
Save johnkpaul/e2a44524203a9c0e70eb to your computer and use it in GitHub Desktop.
Traceur compile in the browser
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var compiler = new traceur.Compiler; | |
compiler.script(content, {experimental: true}) | |
.then(function(result){ | |
var source = result.js; | |
eval(source); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var ProjectWriter = traceur.outputgeneration.ProjectWriter; | |
var ErrorReporter = traceur.util.ErrorReporter; | |
var url = location.href; | |
var project = new traceur.semantics.symbols.Project(url); | |
var name = 'repl'; | |
var sourceFile = new traceur.syntax.SourceFile(name, content); | |
project.addFile(sourceFile); | |
var reporter = new ErrorReporter(); | |
var res = traceur.codegeneration.Compiler.compile(reporter, project, false); | |
traceur.options.experimental = true; | |
var source = ProjectWriter.write(res, traceur.options); | |
eval(source); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment