Skip to content

Instantly share code, notes, and snippets.

@arv
Last active December 17, 2015 04:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arv/5554809 to your computer and use it in GitHub Desktop.
Save arv/5554809 to your computer and use it in GitHub Desktop.
Shows how you can build a smaller js binary to only parse (and print) some ES6 code.
traceur --out out.js parser.js
# Traceur does not strip dead code. Use Uglify2.
uglifyjs src/runtime/runtime.js out.js -cm -o out.min.js
traceur parser.js
import {Parser} from './src/syntax/Parser.js';
import {SourceFile} from './src/syntax/SourceFile.js';
import {ErrorReporter} from './src/util/ErrorReporter.js';
import {TreeWriter} from './src/outputgeneration/TreeWriter.js';
var file = new SourceFile('name', '`abc`');
var reporter = new ErrorReporter();
var parser = new Parser(reporter, file);
var tree = parser.parseProgram();
console.log(TreeWriter.write(tree));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment