diff --git a/benchmark/fixtures/all.js b/benchmark/fixtures/all.js index 2082915c93..484e8b4682 100644 --- a/benchmark/fixtures/all.js +++ b/benchmark/fixtures/all.js @@ -23,13 +23,13 @@ class Bar extends Foo { } - get foo() { - return this._foo; - } - - set foo(val) { - this._foo = val + " foo!"; - } + // not supported by jstransform + //get foo() { + // return this._foo; + //} + //set foo(val) { + // this._foo = val + " foo!"; + //} } // arrow functions diff --git a/benchmark/index.js b/benchmark/index.js index 52298ea8a7..18f6e124bf 100644 --- a/benchmark/index.js +++ b/benchmark/index.js @@ -1,5 +1,6 @@ Error.stackTraceLimit = Infinity; +var jsTrans = require("jstransform"); var traceur = require("traceur"); var es6tr = require("es6-transpiler"); var es6now = require("es6now"); @@ -17,10 +18,22 @@ var readResolve = function (filename) { return fs.readFileSync(require.resolve(filename), "utf8"); }; +var jsTransVisitors = []; + +_.each([ + "arrow-function-visitors", "class-visitors", "destructuring-visitors", + "object-concise-method-visitors", "object-short-notation-visitors", + "rest-param-visitors", "template-visitors" +], function (name) { + var mod = require("jstransform/visitors/es6-" + name); + jsTransVisitors = jsTransVisitors.concat(mod.visitorList); +}); + + var compilers = { "6to5": { compile: function (code, filename) { - return to5.transform(code, { filename: filename }); + return to5.transform(code, { filename: filename }).code; } }, @@ -54,6 +67,12 @@ var compilers = { if (result.errors.length) throw new Error(result.join("; ")); return result.src; } + }, + + jstransform: { + compile: function (code, filename) { + return jsTrans.transform(jsTransVisitors, code).code; + } } };