Skip to content

Instantly share code, notes, and snippets.

@johnkpaul
Created September 1, 2014 20:42
Show Gist options
  • Save johnkpaul/e2a44524203a9c0e70eb to your computer and use it in GitHub Desktop.
Save johnkpaul/e2a44524203a9c0e70eb to your computer and use it in GitHub Desktop.
Traceur compile in the browser
var compiler = new traceur.Compiler;
compiler.script(content, {experimental: true})
.then(function(result){
var source = result.js;
eval(source);
});
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