Compare commits

..

64 Commits

Author SHA1 Message Date
Sebastian McKenzie
e3dc2355e8 v2.3.1 2015-01-02 00:46:14 +11:00
Sebastian McKenzie
9733cb58c9 remove unused variable 2015-01-02 00:45:26 +11:00
Sebastian McKenzie
edd5a3878a fix redefined variables 2015-01-02 00:45:01 +11:00
Sebastian McKenzie
78d2c4fa8d 2.3.1 changelog 2015-01-02 00:43:54 +11:00
Sebastian McKenzie
e268dc6138 return Object.defineProperties without a closure in property methods assignment unless it's really necessary 2015-01-02 00:42:28 +11:00
Sebastian McKenzie
5b6c0fcacd add whitespace after array and object expressions 2015-01-02 00:41:58 +11:00
Sebastian McKenzie
777f2be14e add undefinedToVoid optional transformer 2015-01-02 00:41:33 +11:00
Sebastian McKenzie
41d60a85e9 simplify define property by using a helper in playground object getter memoization 2015-01-02 00:40:47 +11:00
Sebastian McKenzie
800c350db6 use Object.defineProperty on computed properties - fixes #357 2015-01-02 00:40:37 +11:00
Sebastian McKenzie
7b5b8ab6ed add undefinedToVoid optional transformer 2015-01-02 00:25:17 +11:00
Sebastian McKenzie
52e23473ed allow export default non-functions mapping to module.exports in common module formatter - fixes #356 2015-01-01 22:58:46 +11:00
Sebastian McKenzie
af412cae28 v2.3.0 2015-01-01 22:40:44 +11:00
Sebastian McKenzie
4c2c96366f add 2.3.0 changelog 2015-01-01 22:40:02 +11:00
Sebastian McKenzie
de427936a6 remove invalid lval super classes in generation tests 2015-01-01 22:38:01 +11:00
Sebastian McKenzie
9d6850d576 fix linting errors 2015-01-01 22:35:08 +11:00
Sebastian McKenzie
20a0280a52 add support for optional transformers 2015-01-01 22:35:02 +11:00
Sebastian McKenzie
64b7d6fa93 more verbose unknown node error message in code generator 2015-01-01 22:34:51 +11:00
Sebastian McKenzie
d7ca7ebbb9 remove Transformer exposure 2015-01-01 22:34:29 +11:00
Sebastian McKenzie
9680730e24 remove forced closure on super classes 2015-01-01 22:34:22 +11:00
Sebastian McKenzie
07667d80ff clean up traverse 2015-01-01 22:34:05 +11:00
Sebastian McKenzie
9a633ebd9c update scope to use new traversal api 2015-01-01 22:33:40 +11:00
Sebastian McKenzie
fac4a61245 use Makefile command shortcuts 2015-01-01 22:33:30 +11:00
Sebastian McKenzie
0ebc073762 update traversal api, removing return false; in favor of this.stop(); 2015-01-01 22:33:17 +11:00
Sebastian McKenzie
860432cdfd hoist export default to very top 2015-01-01 22:31:59 +11:00
Sebastian McKenzie
c408432445 add support for circular references and hoist all variable declarations 2015-01-01 22:30:28 +11:00
Sebastian McKenzie
27e9f9d616 remove invalid lval super class test 2015-01-01 22:29:57 +11:00
Sebastian McKenzie
94a11cd602 add optional core aliasing transformer 2015-01-01 20:02:20 +11:00
Sebastian McKenzie
ab6e424cac make experimental transformers declare that they're experimental 2015-01-01 20:01:24 +11:00
Sebastian McKenzie
9ee7b07cbf add corejs aliasing transformer and support for optional transformers 2015-01-01 20:01:09 +11:00
Sebastian McKenzie
31fff092b6 upgrade acorn-6to5 - fixes #358 and #353 2014-12-31 11:56:04 +11:00
Sebastian McKenzie
e847ac11af add object-getter-memoization template 2014-12-31 11:54:51 +11:00
Sebastian McKenzie
aee1ca45b0 add isFalsyExpression check to superName and make classes a closure if they're inheriting 2014-12-31 11:54:39 +11:00
Sebastian McKenzie
46632e1a97 better object getter memoization - closes #353 2014-12-31 11:54:13 +11:00
Sebastian McKenzie
961e0b9b6b reenable system modules tests 2014-12-31 11:51:52 +11:00
Sebastian McKenzie
afdde8b3a7 v2.2.0 2014-12-29 12:48:45 +11:00
Sebastian McKenzie
918ddb4124 disable system tests temporairly 2014-12-29 11:16:47 +11:00
Sebastian McKenzie
18739ad78b remove unused variable 2014-12-29 11:15:24 +11:00
Sebastian McKenzie
74a84e2473 fix duplicate comments being output, breaking code 2014-12-29 11:13:50 +11:00
Sebastian McKenzie
52ffc65a06 make system module formatter modules anonymous by default - fixes #347 2014-12-29 01:55:30 +11:00
Sebastian McKenzie
d4fbfbbe47 Merge pull request #348 from guybedford/system
System test adjustments
2014-12-29 01:51:16 +11:00
Sebastian McKenzie
781467d423 v2.1.0 2014-12-29 01:41:05 +11:00
Sebastian McKenzie
44f5b7d013 fix case statement newline in code generator test 2014-12-29 01:39:04 +11:00
Sebastian McKenzie
dcf7f0b70b fix newline in case statement test 2014-12-29 01:37:19 +11:00
Sebastian McKenzie
03efd69998 check if node exists before inheriting comments to it 2014-12-29 01:37:12 +11:00
Sebastian McKenzie
213003a007 fix new templates path in dotfiles 2014-12-29 01:34:49 +11:00
Sebastian McKenzie
b0503f2efe add 2.1.0 changelog 2014-12-29 01:33:58 +11:00
Sebastian McKenzie
c8cf7ff286 better blacklist tests and expose register cache - closes #344 2014-12-29 01:31:26 +11:00
Sebastian McKenzie
ceb32816d7 fix destructuring in switch/case statements - closes #346 2014-12-29 01:26:51 +11:00
Sebastian McKenzie
32b94899a6 update runtime script to runtime generator 2014-12-29 01:26:21 +11:00
Sebastian McKenzie
d951082b09 move replacement node comment inheritance to traverse replacement 2014-12-29 01:26:11 +11:00
Sebastian McKenzie
b49f6e33d6 fix newline on case statement 2014-12-29 01:25:56 +11:00
Sebastian McKenzie
c5fa6425a5 explicit canRun for hidden transformers 2014-12-29 01:25:15 +11:00
Sebastian McKenzie
70d896d609 rename runtime script to runtime-generator 2014-12-29 01:24:57 +11:00
Sebastian McKenzie
e00fa8c9b1 update core-js 2014-12-29 01:24:41 +11:00
Sebastian McKenzie
13933bc9b8 move templates folder into transformation folder 2014-12-29 01:24:35 +11:00
guybedford
295bab544b re-exporting in setters 2014-12-28 14:43:56 +02:00
guybedford
cfe05ca10d exported variable declarations hoist along with functions 2014-12-28 14:41:32 +02:00
guybedford
da72182219 make modules anonymous 2014-12-28 14:38:52 +02:00
Sebastian McKenzie
005f5b2174 v2.0.4 2014-12-28 11:06:04 +11:00
Sebastian McKenzie
8551c94fa0 fix linting errors 2014-12-28 11:05:27 +11:00
Sebastian McKenzie
c509d06bc2 vaoid being greedy when destructuring array iterables 2014-12-28 11:04:00 +11:00
Sebastian McKenzie
f21743012b v2.0.3 2014-12-28 09:37:32 +11:00
Sebastian McKenzie
22dc33f93c remove unused variable 2014-12-28 09:36:29 +11:00
Sebastian McKenzie
6df6652629 better circular references in amd/umd/system module formatter 2014-12-28 09:35:47 +11:00
157 changed files with 1159 additions and 523 deletions

View File

@@ -1,3 +1,3 @@
node_modules
test
lib/6to5/templates
lib/6to5/transformation/templates

View File

@@ -1,7 +1,7 @@
node_modules
*.log
*.cache
lib/6to5/templates
lib/6to5/transformation/templates
test
benchmark
Makefile

View File

@@ -2,6 +2,38 @@
Gaps between patch versions are faulty/broken releases.
## 2.3.1
* Add `undefinedToVoid` optional transformer.
* Use `Object.defineProperty` for computed properties.
## 2.3.0
* Upgrade `acorn-6to5`.
* Support circular references and hoist variable declarations in `system` module formatter.
* Add optional transformers, including a new `coreAliasing` transformer that aliases native ES6 static properties to their `core-js` equivalent.
## 2.2.0
* Make `system` module formatter modules anonymous by default.
* Fix duplicate comments being output, breaking code.
## 2.1.0
* Add `cache` option to register hook.
* Update `core-js`.
* Fix starting newline not being added on case statements.
* Fix destructuring `VariableDeclaration`s not inside `BlockStatement`s and `Program`.
## 2.0.4
* Avoid being greedy when destructuring array iterables.
## 2.0.3
* Hoist function declarations in system module formatter for circular references.
* Hoist default function declarations in umd and amd module formatters for circular references.
## 2.0.2
* Inherit comments in `for-of` transformer.

View File

@@ -21,8 +21,7 @@ lint:
test-clean:
rm -rf test/tmp
test:
make lint
test: lint
$(MOCHA_CMD)
make test-clean
@@ -33,8 +32,7 @@ test-cov:
test-spec:
node $(ISTANBUL_CMD) $(MOCHA_CMD) -- --reporter spec
test-travis:
make test-spec
test-travis: test-spec
if test -n "$$CODECLIMATE_REPO_TOKEN"; then codeclimate < coverage/lcov.info; fi
test-browser:

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env node
var runtime = require("../lib/6to5/runtime");
var runtime = require("../lib/6to5/runtime-generator");
console.log(runtime(process.argv[2]));

View File

@@ -17,18 +17,28 @@ commander.option("-p, --playground", "Enable playground support");
commander.option("-m, --modules [modules]", "Module formatter type to use [common]", "common");
commander.option("-w, --whitelist [whitelist]", "Whitelist of transformers to ONLY use", util.list);
commander.option("-b, --blacklist [blacklist]", "Blacklist of transformers to NOT use", util.list);
commander.option("-i, --optional [list]", "List of optional transformers to enable", util.list);
commander.option("-o, --out-file [out]", "Compile all input files into a single file");
commander.option("-d, --out-dir [out]", "Compile an input directory of modules into an output directory");
commander.option("-c, --remove-comments", "Remove comments from the compiled code", false);
commander.option("-a, --amd-module-ids", "Insert module id in AMD modules", false);
commander.option("-a, --amd-module-ids", "Insert module id in AMD modules", false); // todo: remove in 3.0.0
commander.option("-m, --module-ids", "Insert module id in modules", false);
commander.on("--help", function(){
var outKeys = function (title, obj) {
console.log(" " + title + ":");
console.log();
var hasOptional = true;
_.each(_.keys(obj).sort(), function (key) {
if (key[0] === "_") return;
if (obj[key].optional) {
hasOptional = true;
key = "[" + key + "]";
}
console.log(" - " + key);
});
@@ -89,12 +99,13 @@ if (errors.length) {
exports.opts = {
sourceMapName: commander.outFile,
amdModuleIds: commander.amdModuleIds,
experimental: commander.experimental,
playground: commander.playground,
moduleIds: commander.amdModuleIds || commander.moduleIds,
blacklist: commander.blacklist,
whitelist: commander.whitelist,
sourceMap: commander.sourceMaps || commander.sourceMapsInline,
optional: commander.optional,
comments: !commander.removeComments,
runtime: commander.runtime,
modules: commander.modules

View File

@@ -152,10 +152,10 @@ result.ast;
// Default: `sourceRoot` option.
moduleRoot: "my-app",
// If truthy, insert an explicit id for each defined AMD module.
// By default, AMD modules are anonymous.
// If truthy, insert an explicit id for each defined AMD/System module.
// By default, AMD/System modules are anonymous.
// Default: false
amdModuleIds: true,
moduleIds: true,
// Optionally replace all 6to5 helper declarations with a referenece to this
// variable. If set to `true` then the default namespace is used "to5Runtime".
@@ -250,6 +250,10 @@ require("6to5/register")({
// This will remove the currently hooked extensions of .es6 and .js so you'll
// have to add them back if you want them to be used again.
extensions: [".js", ".es6"]
extensions: [".js", ".es6"],
// Enables `roadrunner` cache that will save to a `.roadrunner.json` file in your cwd
// Do not check this into git as it's user-specific
cache: true
});
```

View File

@@ -10,9 +10,10 @@ var t = require("./types");
var _ = require("lodash");
function File(opts) {
this.opts = File.normaliseOptions(opts);
this.uids = {};
this.ast = {};
this.opts = File.normaliseOptions(opts);
this.transformers = this.getTransformers();
this.uids = {};
this.ast = {};
}
File.declarations = [
@@ -22,9 +23,11 @@ File.declarations = [
"tagged-template-literal",
"interop-require",
"to-array",
"sliced-to-array",
"object-without-properties",
"has-own",
"slice"
"slice",
"define-property"
];
File.normaliseOptions = function (opts) {
@@ -34,9 +37,11 @@ File.normaliseOptions = function (opts) {
experimental: false,
playground: false,
whitespace: true,
moduleIds: opts.amdModuleIds || false,
blacklist: [],
whitelist: [],
sourceMap: false,
optional: [],
comments: true,
filename: "unknown",
modules: "common",
@@ -78,17 +83,37 @@ File.normaliseOptions = function (opts) {
transform._ensureTransformerNames("blacklist", opts.blacklist);
transform._ensureTransformerNames("whitelist", opts.whitelist);
transform._ensureTransformerNames("optional", opts.optional);
return opts;
};
File.prototype.toArray = function (node) {
File.prototype.getTransformers = function () {
var file = this;
var transformers = [];
_.each(transform.transformers, function (transformer) {
if (transformer.canRun(file)) {
transformers.push(transformer);
}
});
return transformers;
};
File.prototype.toArray = function (node, i) {
if (t.isArrayExpression(node)) {
return node;
} else if (t.isIdentifier(node) && node.name === "arguments") {
return t.callExpression(t.memberExpression(this.addDeclaration("slice"), t.identifier("call")), [node]);
} else {
return t.callExpression(this.addDeclaration("to-array"), [node]);
var declarationName = "to-array";
var args = [node];
if (i) {
args.push(t.literal(i));
declarationName = "sliced-to-array";
}
return t.callExpression(this.addDeclaration(declarationName), args);
}
};
@@ -174,15 +199,25 @@ File.prototype.parse = function (code) {
};
File.prototype.transform = function (ast) {
var self = this;
this.ast = ast;
this.scope = new Scope(ast.program);
this.moduleFormatter = this.getModuleFormatter(this.opts.modules);
var self = this;
var astRun = function (key) {
_.each(self.transformers, function (transformer) {
transformer.astRun(self, key);
});
};
_.each(transform.transformers, function (transformer) {
astRun("enter");
_.each(this.transformers, function (transformer) {
transformer.transform(self);
});
astRun("exit");
};
File.prototype.generate = function () {

View File

@@ -115,6 +115,7 @@ CodeGenerator.prototype.print = function (node, parent, opts) {
if (!node) return "";
var self = this;
opts = opts || {};
var newline = function (leading) {
@@ -170,7 +171,7 @@ CodeGenerator.prototype.print = function (node, parent, opts) {
this.printTrailingComments(node, parent);
} else {
throw new ReferenceError("unknown node " + node.type);
throw new ReferenceError("unknown node of type " + JSON.stringify(node.type) + " with constructor " + JSON.stringify(node && node.constructor.name));
}
};

View File

@@ -146,7 +146,7 @@ exports.SwitchCase = function (node, print) {
this.push("default:");
}
this.space();
this.newline();
print.sequence(node.consequent, { indent: true });
};

View File

@@ -55,6 +55,8 @@ _.each({
Function: 1,
Class: 1,
For: 1,
ArrayExpression: { after: 1 },
ObjectExpression: { after: 1 },
SwitchStatement: 1,
IfStatement: { before: 1 },
CallExpression: { after: 1 },

View File

@@ -3,11 +3,9 @@ var util = require("./util");
var fs = require("fs");
var _ = require("lodash");
exports.Transformer = require("./transformation/transformer");
exports.types = require("./types");
exports.runtime = require("./runtime");
exports.runtime = require("./runtime-generator");
exports.register = function (opts) {
var register = require("./register");

View File

@@ -1,6 +1,7 @@
require("./polyfill");
var sourceMapSupport = require("source-map-support");
var roadrunner = require("roadrunner");
var util = require("./util");
var to5 = require("./index");
var fs = require("fs");
@@ -38,15 +39,22 @@ var blacklistTest = function (transformer, code) {
};
blacklistTest("arrayComprehension", "var foo = [for (foo of bar) foo * foo];");
//blacklistTest("generatorComprehension", "");
blacklistTest("generatorComprehension", "var foo = (for (foo of bar) foo * foo)");
blacklistTest("arrowFunctions", "var foo = x => x * x;");
blacklistTest("classes", "class Foo {}");
blacklistTest("computedPropertyNames", "var foo = { [foo]: bar };");
//blacklistTest("constants", "const foo = 0;");
blacklistTest("constants", function () {
try {
new Function("const foo = 'foo';\nfoo = 'wow';");
} catch (err) {
return; // constants are supported
}
throw new SyntaxError;
});
blacklistTest("defaultParamaters", "var foo = function (bar = 0) {};");
blacklistTest("destructuring", "var { x, y } = { x: 0, y: 0 };");
blacklistTest("forOf", "for (var foo of bar) {}");
blacklistTest("generators", "function* foo() {}");
blacklistTest("generators", "function* foo() {}\nasync function bar() {}"); // generators/async functions delegated to same transformer
blacklistTest("letScoping", "let foo = 0;");
blacklistTest("modules", 'import foo from "from";');
blacklistTest("propertyMethodAssignment", "{ get foo() {} }");
@@ -130,6 +138,11 @@ module.exports = function (opts) {
if (opts.cache) cache = opts.cache;
if (opts.cache === false) cache = null;
if (opts.cache === true) {
roadrunner.load();
roadrunner.setup();
cache = roadrunner.get("6to5");
}
_.extend(transformOpts, opts);
};

View File

@@ -1,3 +0,0 @@
(function (KEY) {
return KEY;
})(OBJECT)

View File

@@ -1,4 +0,0 @@
(function (KEY) {
CONTENT;
return KEY;
})(OBJECT);

View File

@@ -124,9 +124,9 @@ DefaultFormatter.prototype._pushStatement = function (ref, nodes) {
return ref;
};
DefaultFormatter.prototype._hoistExport = function (declar, assign) {
DefaultFormatter.prototype._hoistExport = function (declar, assign, priority) {
if (t.isFunctionDeclaration(declar)) {
assign._blockHoist = true;
assign._blockHoist = priority || 2;
}
return assign;
@@ -139,17 +139,18 @@ DefaultFormatter.prototype._exportSpecifier = function (getRef, specifier, node,
if (node.source) {
if (t.isExportBatchSpecifier(specifier)) {
// export * from "foo";
nodes.push(this._exportsWildcard(getRef()));
nodes.push(this._exportsWildcard(getRef(), node));
} else {
// export { foo } from "test";
nodes.push(this._exportsAssign(
t.getSpecifierName(specifier),
t.memberExpression(getRef(), specifier.id)
t.memberExpression(getRef(), specifier.id),
node
));
}
} else {
// export { foo };
nodes.push(this._exportsAssign(t.getSpecifierName(specifier), specifier.id));
nodes.push(this._exportsAssign(t.getSpecifierName(specifier), specifier.id, node));
}
};
@@ -169,30 +170,36 @@ DefaultFormatter.prototype._exportsAssign = function (id, init) {
DefaultFormatter.prototype.exportDeclaration = function (node, nodes) {
var declar = node.declaration;
var id = declar.id;
if (node.default) {
nodes.push(
this._exportsAssign(t.identifier("default"), this._pushStatement(declar, nodes))
);
} else {
var assign;
id = t.identifier("default");
}
if (t.isVariableDeclaration(declar)) {
for (var i in declar.declarations) {
var decl = declar.declarations[i];
var assign;
decl.init = this._exportsAssign(decl.id, decl.init).expression;
if (t.isVariableDeclaration(declar)) {
for (var i in declar.declarations) {
var decl = declar.declarations[i];
var newDeclar = t.variableDeclaration(declar.kind, [decl]);
if (i === "0") t.inherits(newDeclar, declar);
nodes.push(newDeclar);
}
} else {
assign = this._exportsAssign(declar.id, declar.id);
decl.init = this._exportsAssign(decl.id, decl.init, node).expression;
nodes.push(t.toStatement(declar));
nodes.push(assign);
this._hoistExport(declar, assign);
var newDeclar = t.variableDeclaration(declar.kind, [decl]);
if (i === "0") t.inherits(newDeclar, declar);
nodes.push(newDeclar);
}
} else {
var ref = declar;
if (t.isFunctionDeclaration(declar) || t.isClassDeclaration(declar)) {
ref = declar.id;
nodes.push(declar);
}
assign = this._exportsAssign(id, ref, node);
nodes.push(assign);
this._hoistExport(declar, assign);
}
};

View File

@@ -55,7 +55,7 @@ AMDFormatter.prototype.transform = function (ast) {
*/
AMDFormatter.prototype.getModuleName = function () {
if (this.file.opts.amdModuleIds) {
if (this.file.opts.moduleIds) {
return DefaultFormatter.prototype.getModuleName.apply(this, arguments);
} else {
return null;

View File

@@ -57,6 +57,7 @@ CommonJSFormatter.prototype.importDeclaration = function (node, nodes) {
CommonJSFormatter.prototype.exportDeclaration = function (node, nodes) {
if (node.default) {
var declar = node.declaration;
var assign;
// module.exports = VALUE;
var templateName = "exports-default-module";
@@ -64,15 +65,29 @@ CommonJSFormatter.prototype.exportDeclaration = function (node, nodes) {
// exports = module.exports = VALUE;
if (this.hasNonDefaultExports) templateName = "exports-default-module-override";
var assign = util.template(templateName, {
VALUE: this._pushStatement(declar, nodes)
}, true);
if (t.isFunction(declar) || !this.hasNonDefaultExports) {
assign = util.template(templateName, {
VALUE: this._pushStatement(declar, nodes)
}, true);
// hoist to the top if this default is a function
nodes.push(this._hoistExport(declar, assign));
} else {
DefaultFormatter.prototype.exportDeclaration.apply(this, arguments);
// hoist to the top if this default is a function
nodes.push(this._hoistExport(declar, assign, 3));
return;
} else {
// this export isn't a function so we can't hoist it to the top so we need to set it
// at the very end of the file with something like:
//
// module.exports = Object.assign(exports["default"], exports)
//
assign = util.template("common-export-default-assign", true);
assign._blockHoist = 0;
nodes.push(assign);
}
}
DefaultFormatter.prototype.exportDeclaration.apply(this, arguments);
};
CommonJSFormatter.prototype.exportSpecifier = function (specifier, node, nodes) {

View File

@@ -1,26 +1,27 @@
module.exports = SystemFormatter;
var DefaultFormatter = require("./_default");
var AMDFormatter = require("./amd");
var util = require("../../util");
var t = require("../../types");
var _ = require("lodash");
var AMDFormatter = require("./amd");
var traverse = require("../../traverse");
var util = require("../../util");
var t = require("../../types");
var _ = require("lodash");
function SystemFormatter(file) {
this.exportIdentifier = file.generateUidIdentifier("export");
this.noInteropRequire = true;
AMDFormatter.apply(this, arguments);
this.moduleNameLiteral = t.literal(this.getModuleName());
}
util.inherits(SystemFormatter, AMDFormatter);
SystemFormatter.prototype.getModuleName = DefaultFormatter.prototype.getModuleName;
SystemFormatter.prototype._addImportSource = function (node, exportNode) {
node._importSource = exportNode.source && exportNode.source.value;
return node;
};
SystemFormatter.prototype._exportsWildcard = function (objectIdentifier) {
var leftIdentifier = t.identifier("i");
SystemFormatter.prototype._exportsWildcard = function (objectIdentifier, node) {
var leftIdentifier = this.file.generateUidIdentifier("key");
var valIdentifier = t.memberExpression(objectIdentifier, leftIdentifier, true);
var left = t.variableDeclaration("var", [
@@ -33,11 +34,12 @@ SystemFormatter.prototype._exportsWildcard = function (objectIdentifier) {
this.buildExportCall(leftIdentifier, valIdentifier)
]);
return t.forInStatement(left, right, block);
return this._addImportSource(t.forInStatement(left, right, block), node);
};
SystemFormatter.prototype._exportsAssign = function (id, init) {
return this.buildExportCall(t.literal(id.name), init, true);
SystemFormatter.prototype._exportsAssign = function (id, init, node) {
var call = this.buildExportCall(t.literal(id.name), init, true);
return this._addImportSource(call, node);
};
SystemFormatter.prototype.remapExportAssignment = function (node) {
@@ -53,33 +55,120 @@ SystemFormatter.prototype.buildExportCall = function (id, init, isStatement) {
}
};
SystemFormatter.prototype.buildRunnerSetters = function () {
return t.arrayExpression(_.map(this.ids, function (uid) {
var moduleIdentifier = t.identifier("m");
SystemFormatter.prototype.importSpecifier = function (specifier, node, nodes) {
AMDFormatter.prototype.importSpecifier.apply(this, arguments);
this._addImportSource(_.last(nodes), node);
};
return t.functionExpression(null, [moduleIdentifier], t.blockStatement([
t.assignmentExpression("=", uid, moduleIdentifier)
]));
SystemFormatter.prototype.buildRunnerSetters = function (block, hoistDeclarators) {
return t.arrayExpression(_.map(this.ids, function (uid, source) {
var nodes = [];
traverse(block, {
enter: function (node) {
if (node._importSource === source) {
if (t.isVariableDeclaration(node)) {
_.each(node.declarations, function (declar) {
hoistDeclarators.push(t.variableDeclarator(declar.id));
nodes.push(t.expressionStatement(
t.assignmentExpression("=", declar.id, declar.init)
));
});
} else {
nodes.push(node);
}
this.remove();
}
}
});
return t.functionExpression(null, [uid], t.blockStatement(nodes));
}));
};
SystemFormatter.prototype.transform = function (ast) {
var program = ast.program;
var hoistDeclarators = [];
var moduleName = this.getModuleName();
var moduleNameLiteral = t.literal(moduleName);
var block = t.blockStatement(program.body);
var runner = util.template("system", {
MODULE_NAME: this.moduleNameLiteral,
MODULE_NAME: moduleNameLiteral,
MODULE_DEPENDENCIES: t.arrayExpression(this.buildDependencyLiterals()),
EXPORT_IDENTIFIER: this.exportIdentifier,
SETTERS: this.buildRunnerSetters(),
EXECUTE: t.functionExpression(null, [], t.blockStatement(program.body))
SETTERS: this.buildRunnerSetters(block, hoistDeclarators),
EXECUTE: t.functionExpression(null, [], block)
}, true);
if (!_.isEmpty(this.ids)) {
var handlerBody = runner.expression.arguments[2].body.body;
handlerBody.unshift(t.variableDeclaration("var", _.map(this.ids, function (uid) {
return t.variableDeclarator(uid);
})));
var handlerBody = runner.expression.arguments[2].body.body;
if (!moduleName) runner.expression.arguments.shift();
var returnStatement = handlerBody.pop();
// hoist up all variable declarations
traverse(block, {
enter: function (node, parent, scope) {
if (t.isFunction(node)) {
// nothing inside is accessible
return this.stop();
}
if (t.isVariableDeclaration(node)) {
if (node.kind !== "var" && !t.isProgram(parent)) { // let, const
// can't be accessed
return;
}
var nodes = [];
_.each(node.declarations, function (declar) {
hoistDeclarators.push(t.variableDeclarator(declar.id));
if (declar.init) {
// no initializer so we can just hoist it as-is
var assign = t.expressionStatement(t.assignmentExpression("=", declar.id, declar.init));
nodes.push(assign);
}
});
// for (var i in test)
// for (var i = 0;;)
if (t.isFor(parent)) {
if (parent.left === node) {
return node.declarations[0].id;
}
if (parent.init === node) {
return t.toSequenceExpression(nodes, scope);
}
}
return nodes;
}
}
});
if (hoistDeclarators.length) {
var hoistDeclar = t.variableDeclaration("var", hoistDeclarators);
hoistDeclar._blockHoist = true;
handlerBody.unshift(hoistDeclar);
}
// hoist up function declarations for circular references
traverse(block, {
enter: function (node) {
if (t.isFunction(node)) this.stop();
if (t.isFunctionDeclaration(node) || node._blockHoist) {
handlerBody.push(node);
this.remove();
}
}
});
handlerBody.push(returnStatement);
program.body = [runner];
};

View File

@@ -0,0 +1 @@
module.exports = Object.assign(exports["default"], exports);

View File

@@ -0,0 +1 @@
CORE_ID.$for.getIterator(VALUE);

View File

@@ -0,0 +1,8 @@
(function (obj, key, value) {
return Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
});

View File

@@ -0,0 +1,12 @@
(function (arr, i) {
if (Array.isArray(arr)) {
return arr;
} else {
var _arr = [];
for (var _iterator = arr[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) {
_arr.push(_step.value);
if (i && _arr.length === i) break;
}
return _arr;
}
});

View File

@@ -80,6 +80,9 @@ _.each({
_declarations: require("./transformers/_declarations"),
coreAliasing: require("./transformers/optional-core-aliasing"),
undefinedToVoid: require("./transformers/optional-undefined-to-void"),
// wrap up
_aliasFunctions: require("./transformers/_alias-functions"),
useStrict: require("./transformers/use-strict"),

View File

@@ -5,9 +5,11 @@ var t = require("../types");
var _ = require("lodash");
function Transformer(key, transformer, opts) {
this.transformer = Transformer.normalise(transformer);
this.opts = opts || {};
this.key = key;
this.experimental = !!transformer.experimental;
this.transformer = Transformer.normalise(transformer);
this.optional = !!transformer.optional;
this.opts = opts || {};
this.key = key;
}
Transformer.normalise = function (transformer) {
@@ -16,8 +18,13 @@ Transformer.normalise = function (transformer) {
}
_.each(transformer, function (fns, type) {
// hidden property
if (type[0] === "_") return;
if (_.isFunction(fns)) fns = { enter: fns };
if (!_.isObject(fns)) return;
transformer[type] = fns;
var aliases = t.FLIPPED_ALIAS_KEYS[type];
@@ -41,13 +48,9 @@ Transformer.prototype.astRun = function (file, key) {
};
Transformer.prototype.transform = function (file) {
if (!this.canRun(file)) return;
var transformer = this.transformer;
var ast = file.ast;
this.astRun(file, "enter");
var build = function (exit) {
return function (node, parent, scope) {
var fns = transformer[node.type];
@@ -61,25 +64,30 @@ Transformer.prototype.transform = function (file) {
};
};
this.astRun(file, "before");
traverse(ast, {
enter: build(),
exit: build(true)
});
this.astRun(file, "exit");
this.astRun(file, "after");
};
Transformer.prototype.canRun = function (file) {
var opts = file.opts;
var key = this.key;
if (key[0] === "_") return true;
var blacklist = opts.blacklist;
if (blacklist.length && _.contains(blacklist, key)) return false;
if (key[0] !== "_") {
var whitelist = opts.whitelist;
if (whitelist.length && !_.contains(whitelist, key)) return false;
}
var whitelist = opts.whitelist;
if (whitelist.length && !_.contains(whitelist, key)) return false;
if (this.optional && !_.contains(opts.optional, key)) return false;
if (this.experimental && !opts.experimental) return false;
return true;
};

View File

@@ -20,7 +20,7 @@ var go = function (getBody, node, file, scope) {
if (!node._aliasFunction) {
if (t.isFunction(node)) {
// stop traversal of this node as it'll be hit again by this transformer
return false;
return this.stop();
} else {
return;
}
@@ -30,10 +30,10 @@ var go = function (getBody, node, file, scope) {
traverse(node, {
enter: function (node, parent) {
if (t.isFunction(node) && !node._aliasFunction) {
return false;
return this.stop();
}
if (node._ignoreAliasFunctions) return false;
if (node._ignoreAliasFunctions) return this.stop();
var getId;
@@ -49,7 +49,7 @@ var go = function (getBody, node, file, scope) {
}
});
return false;
return this.stop();
}
});

View File

@@ -1,17 +1,29 @@
var _ = require("lodash");
// Priority:
//
// - 0 We want this to be at the **very** bottom
// - 1 Default node position
// - 2 Priority over normal nodes
// - 3 We want this to be at the **very** top
exports.BlockStatement =
exports.Program = {
exit: function (node) {
var unshift = [];
var hasChange = false;
for (var i in node.body) {
var bodyNode = node.body[i];
if (bodyNode && bodyNode._blockHoist != null) hasChange = true;
}
if (!hasChange) return;
node.body = node.body.filter(function (bodyNode) {
if (bodyNode._blockHoist) {
unshift.push(bodyNode);
return false;
} else {
return true;
}
var nodePriorities = _.groupBy(node.body, function (bodyNode) {
var priority = bodyNode._blockHoist;
if (priority == null) priority = 1;
if (priority === true) priority = 2;
return priority;
});
node.body = unshift.concat(node.body);
node.body = _.flatten(_.values(nodePriorities).reverse());
}
};

View File

@@ -20,14 +20,21 @@ exports.ObjectExpression = function (node, parent, file) {
if (!hasAny) return;
var objId = util.getUid(parent, file);
if (node.properties.length) {
var objId = util.getUid(parent, file);
return util.template("object-define-properties-closure", {
KEY: objId,
OBJECT: node,
CONTENT: util.template("object-define-properties", {
OBJECT: objId,
return util.template("object-define-properties-closure", {
KEY: objId,
OBJECT: node,
CONTENT: util.template("object-define-properties", {
OBJECT: objId,
PROPS: util.buildDefineProperties(mutatorMap)
})
});
} else {
return util.template("object-define-properties", {
OBJECT: node,
PROPS: util.buildDefineProperties(mutatorMap)
})
});
});
}
};

View File

@@ -153,7 +153,7 @@ Class.prototype.buildBody = function () {
}
}
if (!this.hasConstructor && superName) {
if (!this.hasConstructor && superName && !t.isFalsyExpression(superName)) {
constructor.body.body.push(util.template("class-super-constructor-call", {
SUPER_NAME: superName
}, true));

View File

@@ -3,45 +3,95 @@ var t = require("../../types");
exports.ObjectExpression = function (node, parent, file) {
var hasComputed = false;
var prop;
var key;
var i;
var computed = [];
node.properties = node.properties.filter(function (prop) {
if (prop.computed) {
hasComputed = true;
computed.unshift(prop);
return false;
} else {
return true;
}
});
for (i in node.properties) {
hasComputed = t.isProperty(node.properties[i], { computed: true });
if (hasComputed) break;
}
if (!hasComputed) return;
var objId = util.getUid(parent, file);
var container = util.template("function-return-obj", {
KEY: objId,
OBJECT: node
});
var body = [];
var container = t.functionExpression(null, [], t.blockStatement(body));
container._aliasFunction = true;
var containerCallee = container.callee;
var containerBody = containerCallee.body.body;
var props = node.properties;
containerCallee._aliasFunction = true;
// normalise key
for (var i in computed) {
var prop = computed[i];
containerBody.unshift(
t.expressionStatement(
t.assignmentExpression(
"=",
t.memberExpression(objId, prop.key, true),
prop.value
)
)
);
for (i in props) {
prop = props[i];
key = prop.key;
if (!prop.computed && t.isIdentifier(key)) {
prop.key = t.literal(key.name);
}
}
return container;
// add all non-computed properties and `__proto__` properties to the initializer
var initProps = [];
var broken = false;
for (i in props) {
prop = props[i];
if (prop.computed) {
broken = true;
}
if (!broken || t.isLiteral(prop.key, { value: "__proto__" })) {
initProps.push(prop);
props[i] = null;
}
}
// add a simple assignment for all Symbol member expressions due to symbol polyfill limitations
// otherwise use Object.defineProperty
for (i in props) {
prop = props[i];
if (!prop) continue;
key = prop.key;
var bodyNode;
if (prop.computed && t.isMemberExpression(key) && t.isIdentifier(key.object, { name: "Symbol" })) {
bodyNode = t.assignmentExpression(
"=",
t.memberExpression(objId, key, true),
prop.value
);
} else {
bodyNode = t.callExpression(file.addDeclaration("define-property"), [objId, key, prop.value]);
}
body.push(t.expressionStatement(bodyNode));
}
// only one node and it's a Object.defineProperty that returns the object
if (body.length === 1) {
var first = body[0].expression;
if (t.isCallExpression(first)) {
first.arguments[0] = t.objectExpression([]);
return first;
}
}
//
body.unshift(t.variableDeclaration("var", [
t.variableDeclarator(objId, t.objectExpression(initProps))
]));
body.push(t.returnStatement(objId));
return t.callExpression(container, []);
};

View File

@@ -61,13 +61,27 @@ var pushObjectPattern = function (opts, nodes, pattern, parentId) {
};
var pushArrayPattern = function (opts, nodes, pattern, parentId) {
if (!pattern.elements) return;
var i;
var hasSpreadElement = false;
for (i in pattern.elements) {
if (t.isSpreadElement(pattern.elements[i])) {
hasSpreadElement = true;
break;
}
}
var toArray = opts.file.toArray(parentId, !hasSpreadElement && pattern.elements.length);
var _parentId = opts.file.generateUidIdentifier("ref", opts.scope);
nodes.push(t.variableDeclaration("var", [
t.variableDeclarator(_parentId, opts.file.toArray(parentId))
t.variableDeclarator(_parentId, toArray)
]));
parentId = _parentId;
for (var i in pattern.elements) {
for (i in pattern.elements) {
var elem = pattern.elements[i];
if (!elem) continue;
@@ -254,6 +268,7 @@ exports.VariableDeclaration = function (node, parent, file, scope) {
}
if (!t.isProgram(parent) && !t.isBlockStatement(parent)) {
declar = null;
for (i in nodes) {
node = nodes[i];

View File

@@ -1 +1,3 @@
module.exports = require("regenerator").transform;
exports.ast = {
before: require("regenerator").transform
};

View File

@@ -280,7 +280,7 @@ LetScoping.prototype.checkLoop = function () {
var replace;
if (t.isFunction(node) || t.isLoop(node)) {
return false;
return this.stop();
}
if (node && !node.label) {
@@ -329,7 +329,7 @@ LetScoping.prototype.hoistVarDeclarations = function () {
} else if (isVar(node, parent)) {
return self.pushDeclar(node).map(t.expressionStatement);
} else if (t.isFunction(node)) {
return false;
return this.stop();
}
}
});
@@ -388,9 +388,9 @@ LetScoping.prototype.getLetReferences = function () {
}
});
return false;
return this.stop();
} else if (t.isLoop(node)) {
return false;
return this.stop();
}
}
});

View File

@@ -1,26 +1,16 @@
var t = require("../../types");
var inheritsComments = function (node, nodes) {
if (nodes.length) {
t.inheritsComments(nodes[0], node);
}
};
exports.ImportDeclaration = function (node, parent, file) {
var nodes = [];
if (node.specifiers.length) {
if (!file.moduleFormatter.importSpecifier) return;
for (var i in node.specifiers) {
file.moduleFormatter.importSpecifier(node.specifiers[i], node, nodes, parent);
}
} else {
if (!file.moduleFormatter.importDeclaration) return;
file.moduleFormatter.importDeclaration(node, nodes, parent);
}
inheritsComments(node, nodes);
return nodes;
};
@@ -35,16 +25,12 @@ exports.ExportDeclaration = function (node, parent, file) {
declar.init = declar.init || t.identifier("undefined");
}
if (!file.moduleFormatter.exportDeclaration) return;
file.moduleFormatter.exportDeclaration(node, nodes, parent);
} else {
if (!file.moduleFormatter.exportSpecifier) return;
for (var i in node.specifiers) {
file.moduleFormatter.exportSpecifier(node.specifiers[i], node, nodes, parent);
}
}
inheritsComments(node, nodes);
return nodes;
};

View File

@@ -3,6 +3,8 @@
var util = require("../../util");
var t = require("../../types");
exports.experimental = true;
var container = function (parent, call, ret) {
if (t.isExpressionStatement(parent)) {
// we don't need to worry about return values

View File

@@ -1,6 +1,8 @@
var util = require("../../util");
var t = require("../../types");
exports.experimental = true;
var single = function (node, file) {
var block = node.blocks[0];

View File

@@ -1,5 +1,7 @@
// https://github.com/rwaldron/exponentiation-operator
exports.experimental = true;
var t = require("../../types");
var pow = t.memberExpression(t.identifier("Math"), t.identifier("pow"));

View File

@@ -1,6 +1,8 @@
var arrayComprehension = require("./es7-array-comprehension");
var t = require("../../types");
exports.experimental = true;
exports.ComprehensionExpression = function (node) {
if (!node.generator) return;

View File

@@ -2,6 +2,8 @@
var t = require("../../types");
exports.experimental = true;
exports.ObjectExpression = function (node) {
var hasSpread = false;
var i;

View File

@@ -0,0 +1,55 @@
var traverse = require("../../traverse");
var util = require("../../util");
var core = require("core-js/library");
var t = require("../../types");
var _ = require("lodash");
exports.optional = true;
exports.ast = {
enter: function (ast, file) {
file._coreId = file.generateUidIdentifier("core");
var specifiers = [t.importSpecifier(t.identifier("default"), file._coreId)];
var declar = t.importDeclaration(specifiers, t.literal("core-js/library"));
ast.program.body.unshift(declar);
},
exit: function (ast, file) {
traverse(ast, {
enter: function (node, parent) {
var prop;
if (t.isMemberExpression(node) && t.isReferenced(node, parent)) {
// Array.from -> _core.Array.from
var obj = node.object;
prop = node.property;
if (!t.isReferenced(obj, node)) return;
var coreHasObject = obj.name !== "_" && _.has(core, obj.name);
if (coreHasObject && _.has(core[obj.name], prop.name)) {
this.stop();
return t.memberExpression(file._coreId, node);
}
} else if (t.isCallExpression(node)) {
// arr[Symbol.iterator]() -> _core.$for.getIterator(arr)
if (node.arguments.length) return;
var callee = node.callee;
if (!t.isMemberExpression(callee)) return;
if (!callee.computed) return;
prop = callee.property;
if (!t.isIdentifier(prop.object, { name: "Symbol" })) return;
if (!t.isIdentifier(prop.property, { name: "iterator" })) return;
return util.template("corejs-iterator", {
CORE_ID: file._coreId,
VALUE: callee.object
});
}
}
});
}
};

View File

@@ -0,0 +1,9 @@
var t = require("../../types");
exports.optional = true;
exports.Identifier = function (node, parent) {
if (node.name === "undefined" && t.isReferenced(node, parent)) {
return t.unaryExpression("void", t.literal(0), true);
}
};

View File

@@ -2,38 +2,30 @@ var traverse = require("../../traverse");
var t = require("../../types");
exports.Property =
exports.MethodDefinition = function (node, parent, file, scope) {
exports.MethodDefinition = function (node, parent, file) {
if (node.kind !== "memo") return;
node.kind = "get";
var value = node.value;
t.ensureBlock(value);
var body = value.body.body;
var key = node.key;
var key = node.key;
if (t.isIdentifier(key) && !node.computed) {
key = "_" + key.name;
} else {
key = file.generateUid("memo", scope);
key = t.literal(key.name);
}
var memoId = t.memberExpression(t.thisExpression(), t.identifier(key));
var doneId = t.memberExpression(t.thisExpression(), t.identifier(key + "Done"));
traverse(value, {
enter: function (node) {
if (t.isFunction(node)) return;
if (t.isReturnStatement(node) && node.argument) {
node.argument = t.assignmentExpression("=", memoId, node.argument);
node.argument = t.memberExpression(t.callExpression(file.addDeclaration("define-property"), [
t.thisExpression(),
key,
node.argument
]), key, true);
}
}
});
// this._barDone = true;
body.unshift(t.expressionStatement(t.assignmentExpression("=", doneId, t.literal(true))));
// if (this._barDone) return this._bar;
body.unshift(t.ifStatement(doneId, t.returnStatement(memoId)));
};

View File

@@ -1,12 +1,14 @@
var t = require("../../types");
module.exports = function (ast) {
var body = ast.program.body;
var first = body[0];
exports.ast = {
exit: function (ast) {
var body = ast.program.body;
var first = body[0];
var noStrict = !first || !t.isExpressionStatement(first) || !t.isLiteral(first.expression) || first.expression.value !== "use strict";
var noStrict = !first || !t.isExpressionStatement(first) || !t.isLiteral(first.expression) || first.expression.value !== "use strict";
if (noStrict) {
body.unshift(t.expressionStatement(t.literal("use strict")));
if (noStrict) {
body.unshift(t.expressionStatement(t.literal("use strict")));
}
}
};

View File

@@ -39,22 +39,37 @@ function traverse(parent, opts, scope) {
// replace node
var maybeReplace = function (result) {
if (result === false) return;
if (result == null) return;
if (result != null) {
updated = true;
node = obj[key] = result;
var isArray = _.isArray(result);
if (_.isArray(result) && _.contains(t.STATEMENT_OR_BLOCK_KEYS, key) && !t.isBlockStatement(obj)) {
t.ensureBlock(obj, key);
}
// inherit comments from original node to the first replacement node
var inheritTo = result;
if (isArray) inheritTo = result[0];
if (inheritTo) t.inheritsComments(inheritTo, node);
// replace the node
node = obj[key] = result;
updated = true;
// we're replacing a statement or block node with an array of statements so we better
// ensure that it's a block
if (isArray && _.contains(t.STATEMENT_OR_BLOCK_KEYS, key) && !t.isBlockStatement(obj)) {
t.ensureBlock(obj, key);
}
};
var stop = false;
var stopped = false;
var removed = false;
var context = {
stop: function () {
stop = true;
stopped = true;
},
remove: function () {
this.stop();
removed = true;
}
};
@@ -67,8 +82,13 @@ function traverse(parent, opts, scope) {
var result = opts.enter.call(context, node, parent, ourScope);
maybeReplace(result);
if (removed) {
obj[key] = null;
updated = true;
}
// stop iteration
if (stop || result === false) return;
if (stopped) return;
}
// traverse node
@@ -85,7 +105,9 @@ function traverse(parent, opts, scope) {
handle(nodes, i);
}
if (updated) parent[key] = _.flatten(parent[key]);
if (updated) {
parent[key] = _.flatten(parent[key]);
}
} else {
handle(parent, key);
}
@@ -134,7 +156,7 @@ traverse.hasType = function (tree, type, blacklistTypes) {
enter: function (node) {
if (node.type === type) {
has = true;
return false;
this.stop();
}
}
});

View File

@@ -93,7 +93,7 @@ Scope.prototype.getInfo = function () {
// this block is a function so we'll stop since none of the variables
// declared within are accessible
if (t.isFunction(node)) return false;
if (t.isFunction(node)) return this.stop();
// function identifier doesn't belong to this scope
if (block.id && node === block.id) return;

View File

@@ -11,6 +11,8 @@
"FunctionExpression": ["id", "params", "body", "generator"],
"Identifier": ["name"],
"IfStatement": ["test", "consequent", "alternate"],
"ImportDeclaration": ["specifiers", "source"],
"ImportSpecifier": ["id", "name"],
"Literal": ["value"],
"LogicalExpression": ["operator", "left", "right"],
"MemberExpression": ["object", "property", "computed"],

View File

@@ -74,6 +74,17 @@ addAssert("Expression", t.isExpression);
//
t.isFalsyExpression = function (node) {
if (t.isLiteral(node)) {
return !node.value;
} else if (t.isIdentifier(node)) {
return node.name === "undefined";
}
return false;
};
//
t.toSequenceExpression = function (nodes, scope) {
var exprs = [];
@@ -293,8 +304,9 @@ t.removeComments = function (child) {
};
t.inheritsComments = function (child, parent) {
child.leadingComments = _.compact([].concat(child.leadingComments, parent.leadingComments));
child.trailingComments = _.compact([].concat(child.trailingComments, parent.trailingComments));
_.each(["leadingComments", "trailingComments"], function (key) {
child[key] = _.uniq(_.compact([].concat(child[key], parent[key])));
});
return child;
};

View File

@@ -268,7 +268,7 @@ exports.parseTemplate = function (loc, code) {
var loadTemplates = function () {
var templates = {};
var templatesLoc = __dirname + "/templates";
var templatesLoc = __dirname + "/transformation/templates";
if (!fs.existsSync(templatesLoc)) {
throw new Error("no templates directory - this is most likely the " +
"result of a broken `npm publish`. Please report to " +

View File

@@ -1,7 +1,7 @@
{
"name": "6to5",
"description": "Turn ES6 code into readable vanilla ES5 with source maps",
"version": "2.0.2",
"version": "2.3.1",
"author": "Sebastian McKenzie <sebmck@gmail.com>",
"homepage": "https://github.com/6to5/6to5",
"repository": {
@@ -35,11 +35,11 @@
"test": "make test"
},
"dependencies": {
"acorn-6to5": "0.9.1-16",
"acorn-6to5": "0.11.1-1",
"ast-types": "~0.6.1",
"chokidar": "0.11.1",
"commander": "2.5.0",
"core-js": "^0.3.2",
"core-js": "^0.3.3",
"estraverse": "1.8.0",
"esutils": "1.1.6",
"fs-readdir-recursive": "0.1.0",

View File

@@ -2,8 +2,6 @@ class Test {
}
class Derived extends Super {
}
class Derived2 extends Super() {
}
class StaticMethods {
static n1() {
}

View File

@@ -1,6 +1,5 @@
class Test {}
class Derived extends Super {}
class Derived2 extends Super() {}
class StaticMethods {
static n1() {}

View File

@@ -1,6 +1,5 @@
(class Test { });
(class Derived extends Super { });
(class Derived2 extends Super() { });
(class StaticMethods {
static n1() {
}
@@ -54,4 +53,3 @@
}
});
(class { });
(class extends Super() { });

View File

@@ -1,6 +1,5 @@
(class Test {});
(class Derived extends Super {});
(class Derived2 extends Super() {});
(class StaticMethods {
static n1() {}
@@ -38,4 +37,3 @@
*[gen1]() {}
});
(class {});
(class extends Super() {});

View File

@@ -33,7 +33,10 @@ switch (foo) {
}
switch (foo) {
case "foo": foo();
case "bar": bar();
default: yay();
case "foo":
foo();
case "bar":
bar();
default:
yay();
}

View File

@@ -1,17 +1,13 @@
"use strict";
var obj = (function (_obj) {
Object.defineProperties(_obj, {
foo: {
get: function () {
return 5 + 5;
},
set: function (value) {
this._foo = value;
},
enumerable: true
}
});
return _obj;
})({});
var obj = Object.defineProperties({}, {
foo: {
get: function () {
return 5 + 5;
},
set: function (value) {
this._foo = value;
},
enumerable: true
}
});

View File

@@ -1,14 +1,10 @@
"use strict";
var obj = (function (_obj) {
Object.defineProperties(_obj, {
foo: {
get: function () {
return 5 + 5;
},
enumerable: true
}
});
return _obj;
})({});
var obj = Object.defineProperties({}, {
foo: {
get: function () {
return 5 + 5;
},
enumerable: true
}
});

View File

@@ -1,14 +1,10 @@
"use strict";
var obj = (function (_obj) {
Object.defineProperties(_obj, {
foo: {
set: function (value) {
this._foo = value;
},
enumerable: true
}
});
return _obj;
})({});
var obj = Object.defineProperties({}, {
foo: {
set: function (value) {
this._foo = value;
},
enumerable: true
}
});

View File

@@ -1,3 +0,0 @@
class Q extends function () {} {
}

View File

@@ -1,23 +0,0 @@
"use strict";
var _inherits = function (child, parent) {
child.prototype = Object.create(parent && parent.prototype, {
constructor: {
value: child,
enumerable: false,
writable: true,
configurable: true
}
});
if (parent) child.__proto__ = parent;
};
var _QSuper = function () {};
var Q = function Q() {
if (_QSuper) {
_QSuper.apply(this, arguments);
}
};
_inherits(Q, _QSuper);

View File

@@ -1,6 +1,12 @@
"use strict";
foo((function (_ref) {
_ref[bar] = "foobar";
return _ref;
})({}));
var _defineProperty = function (obj, key, value) {
return Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
};
foo(_defineProperty({}, bar, "foobar"));

View File

@@ -1,6 +1,12 @@
"use strict";
foo = (function (_foo) {
_foo[bar] = "foobar";
return _foo;
})({});
var _defineProperty = function (obj, key, value) {
return Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
};
foo = _defineProperty({}, bar, "foobar");

View File

@@ -0,0 +1,3 @@
var foo = {
[Symbol.iterator]: "foobar"
};

View File

@@ -0,0 +1,8 @@
"use strict";
var foo = (function () {
var _foo = {};
_foo[Symbol.iterator] = "foobar";
return _foo;
})();

Some files were not shown because too many files have changed in this diff Show More