Compare commits
19 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
40a2d14c7c | ||
|
|
573283f260 | ||
|
|
0497860462 | ||
|
|
a173775fec | ||
|
|
c5214ffe70 | ||
|
|
3d62af004d | ||
|
|
d7af8c6261 | ||
|
|
680c6b166a | ||
|
|
5bad458b09 | ||
|
|
055f894a88 | ||
|
|
da8edecc09 | ||
|
|
cd6dea6480 | ||
|
|
69d7ac0e0c | ||
|
|
dae46bfbfa | ||
|
|
b5b175c45a | ||
|
|
569c681c4f | ||
|
|
ed1e4a7820 | ||
|
|
b55f941dae | ||
|
|
a0219ef278 |
13
CHANGELOG.md
13
CHANGELOG.md
@@ -1,3 +1,16 @@
|
||||
# 1.14.13
|
||||
|
||||
* Fix let scoping of `while` loops.
|
||||
* Make class methods enumerable.
|
||||
|
||||
# 1.14.12
|
||||
|
||||
* Fix duplicate dynamic expressions in call spread.
|
||||
|
||||
# 1.14.10
|
||||
|
||||
* Fix let scoping unneccesary override.
|
||||
|
||||
# 1.14.6
|
||||
|
||||
* Avoid ensuring a block on non-array node replacements.
|
||||
|
||||
2
Makefile
2
Makefile
@@ -16,7 +16,7 @@ bench:
|
||||
node node_modules/matcha/bin/_matcha
|
||||
|
||||
lint:
|
||||
$(JSHINT_CMD) lib bin benchmark/index.js
|
||||
$(JSHINT_CMD) --reporter node_modules/jshint-stylish/stylish.js lib bin benchmark/index.js
|
||||
|
||||
test-clean:
|
||||
rm -rf test/tmp
|
||||
|
||||
@@ -15,15 +15,18 @@ process.argv.slice(2).forEach(function(arg){
|
||||
case "-d":
|
||||
args.unshift("--debug");
|
||||
break;
|
||||
|
||||
case "debug":
|
||||
case "--debug":
|
||||
case "--debug-brk":
|
||||
args.unshift(arg);
|
||||
break;
|
||||
|
||||
case "-gc":
|
||||
case "--expose-gc":
|
||||
args.unshift("--expose-gc");
|
||||
break;
|
||||
|
||||
case "--gc-global":
|
||||
case "--harmony":
|
||||
case "--harmony-proxies":
|
||||
@@ -35,16 +38,20 @@ process.argv.slice(2).forEach(function(arg){
|
||||
case "--trace-deprecation":
|
||||
args.unshift(arg);
|
||||
break;
|
||||
|
||||
default:
|
||||
if (0 == arg.indexOf("--trace")) args.unshift(arg);
|
||||
else args.push(arg);
|
||||
if (arg.indexOf("--trace") === 0) {
|
||||
args.unshift(arg);
|
||||
} else {
|
||||
args.push(arg);
|
||||
}
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
var proc = spawn(process.argv[0], args, { stdio: "inherit" });
|
||||
proc.on("exit", function (code, signal) {
|
||||
process.on("exit", function (){
|
||||
process.on("exit", function () {
|
||||
if (signal) {
|
||||
process.kill(process.pid, signal);
|
||||
} else {
|
||||
|
||||
@@ -28,7 +28,13 @@ exports.before = {
|
||||
};
|
||||
|
||||
exports.after = {
|
||||
nodes: {},
|
||||
nodes: {
|
||||
AssignmentExpression: function (node) {
|
||||
if (t.isFunction(node.right)) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
list: {
|
||||
VariableDeclaration: function (node) {
|
||||
|
||||
@@ -162,17 +162,22 @@ Class.prototype.buildBody = function () {
|
||||
Class.prototype.pushMethod = function (node) {
|
||||
var methodName = node.key;
|
||||
|
||||
var mutatorMap = this.instanceMutatorMap;
|
||||
if (node.static) mutatorMap = this.staticMutatorMap;
|
||||
|
||||
var kind = node.kind;
|
||||
|
||||
if (kind === "") {
|
||||
kind = "value";
|
||||
util.pushMutatorMap(mutatorMap, methodName, "writable", t.identifier("true"));
|
||||
}
|
||||
// method
|
||||
|
||||
util.pushMutatorMap(mutatorMap, methodName, kind, node);
|
||||
var className = this.className;
|
||||
if (!node.static) className = t.memberExpression(className, t.identifier("prototype"));
|
||||
methodName = t.memberExpression(className, methodName, node.computed);
|
||||
|
||||
this.body.push(t.expressionStatement(t.assignmentExpression("=", methodName, node.value)));
|
||||
} else {
|
||||
// mutator
|
||||
var mutatorMap = this.instanceMutatorMap;
|
||||
if (node.static) mutatorMap = this.staticMutatorMap;
|
||||
util.pushMutatorMap(mutatorMap, methodName, kind, node);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -260,16 +260,14 @@ LetScoping.prototype.checkFor = function () {
|
||||
hasBreak: false,
|
||||
};
|
||||
|
||||
var forParent = this.forParent;
|
||||
|
||||
traverse(this.block, function (node) {
|
||||
var replace;
|
||||
|
||||
if (t.isFunction(node) || t.isFor(node)) {
|
||||
if (t.isFunction(node) || t.isLoop(node) || t.isSwitchStatement(node)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (forParent && node && !node.label) {
|
||||
if (node && !node.label) {
|
||||
if (t.isBreakStatement(node)) {
|
||||
has.hasBreak = true;
|
||||
replace = t.returnStatement(t.literal("break"));
|
||||
|
||||
@@ -56,7 +56,7 @@ exports.ArrayExpression = function (node, parent, file) {
|
||||
return t.callExpression(t.memberExpression(first, t.identifier("concat")), nodes);
|
||||
};
|
||||
|
||||
exports.CallExpression = function (node, parent, file) {
|
||||
exports.CallExpression = function (node, parent, file, scope) {
|
||||
var args = node.arguments;
|
||||
if (!hasSpread(args)) return;
|
||||
|
||||
@@ -79,10 +79,16 @@ exports.CallExpression = function (node, parent, file) {
|
||||
}
|
||||
|
||||
var callee = node.callee;
|
||||
var temp;
|
||||
|
||||
if (t.isMemberExpression(callee)) {
|
||||
contextLiteral = callee.object;
|
||||
|
||||
if (t.isDynamic(contextLiteral)) {
|
||||
temp = contextLiteral = scope.generateTemp(file);
|
||||
callee.object = t.assignmentExpression("=", temp, callee.object);
|
||||
}
|
||||
|
||||
if (callee.computed) {
|
||||
callee.object = t.memberExpression(callee.object, callee.property, true);
|
||||
callee.property = t.identifier("apply");
|
||||
|
||||
@@ -30,12 +30,7 @@ exports.AssignmentExpression = function (node, parent, file, scope) {
|
||||
if (!t.isExpressionStatement(parent)) {
|
||||
// `node.right` isn't a simple identifier so we need to reference it
|
||||
if (t.isDynamic(value)) {
|
||||
var tempName = file.generateUid("temp");
|
||||
temp = value = t.identifier(tempName);
|
||||
scope.push({
|
||||
key: tempName,
|
||||
id: temp
|
||||
});
|
||||
temp = value = scope.generateTemp(file);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,12 +70,7 @@ exports.CallExpression = function (node, parent, file, scope) {
|
||||
var temp;
|
||||
if (t.isDynamic(callee.object)) {
|
||||
// we need to save `callee.object` so we can call it again
|
||||
var tempName = file.generateUid("temp");
|
||||
temp = t.identifier(tempName);
|
||||
scope.push({
|
||||
key: tempName,
|
||||
id: temp
|
||||
});
|
||||
temp = scope.generateTemp(file);
|
||||
}
|
||||
|
||||
var call = util.template("abstract-expression-call", {
|
||||
|
||||
@@ -7,12 +7,7 @@ exports.BindMemberExpression = function (node, parent, file, scope) {
|
||||
|
||||
var temp;
|
||||
if (t.isDynamic(object)) {
|
||||
var tempName = file.generateUid("temp", scope);
|
||||
temp = object = t.identifier(tempName);
|
||||
scope.push({
|
||||
key: tempName,
|
||||
id: temp
|
||||
});
|
||||
temp = object = scope.generateTemp(file);
|
||||
}
|
||||
|
||||
var call = t.callExpression(
|
||||
@@ -39,17 +34,12 @@ exports.BindFunctionExpression = function (node, parent, file, scope) {
|
||||
};
|
||||
|
||||
if (_.find(node.arguments, t.isDynamic)) {
|
||||
var argsIdName = file.generateUid("args", scope);
|
||||
var argsId = t.identifier(argsIdName);
|
||||
scope.push({
|
||||
key: argsIdName,
|
||||
id: argsId
|
||||
});
|
||||
var temp = scope.generateTemp(file, "args");
|
||||
|
||||
return t.sequenceExpression([
|
||||
t.assignmentExpression("=", argsId, t.arrayExpression(node.arguments)),
|
||||
t.assignmentExpression("=", temp, t.arrayExpression(node.arguments)),
|
||||
buildCall(node.arguments.map(function (node, i) {
|
||||
return t.memberExpression(argsId, t.literal(i), true);
|
||||
return t.memberExpression(temp, t.literal(i), true);
|
||||
}))
|
||||
]);
|
||||
} else {
|
||||
|
||||
@@ -23,7 +23,16 @@ function Scope(block, parent) {
|
||||
|
||||
Scope.add = function (node, references) {
|
||||
if (!node) return;
|
||||
_.merge(references, t.getIds(node, true));
|
||||
_.defaults(references, t.getIds(node, true));
|
||||
};
|
||||
|
||||
Scope.prototype.generateTemp = function (file, name) {
|
||||
var id = file.generateUidIdentifier(name || "temp", this);
|
||||
this.push({
|
||||
key: id.name,
|
||||
id: id
|
||||
});
|
||||
return id;
|
||||
};
|
||||
|
||||
Scope.prototype.getReferences = function () {
|
||||
|
||||
@@ -3,14 +3,14 @@
|
||||
"BreakStatement": ["Statement"],
|
||||
"ContinueStatement": ["Statement"],
|
||||
"DebuggerStatement": ["Statement"],
|
||||
"DoWhileStatement": ["Statement"],
|
||||
"DoWhileStatement": ["Statement", "Loop", "With"],
|
||||
"IfStatement": ["Statement"],
|
||||
"ReturnStatement": ["Statement"],
|
||||
"SwitchStatement": ["Statement"],
|
||||
"ThrowStatement": ["Statement"],
|
||||
"TryStatement": ["Statement"],
|
||||
"WhileStatement": ["Statement"],
|
||||
"WithStatement": ["Statement"],
|
||||
"WithStatement": ["Statement", "Loop", "With"],
|
||||
"EmptyStatement": ["Statement"],
|
||||
"LabeledStatement": ["Statement"],
|
||||
"VariableDeclaration": ["Statement", "Declaration"],
|
||||
@@ -35,9 +35,9 @@
|
||||
"ClassDeclaration": ["Statement", "Declaration", "Class"],
|
||||
"ClassExpression": ["Class"],
|
||||
|
||||
"ForOfStatement": ["Statement", "For", "Scope"],
|
||||
"ForInStatement": ["Statement", "For", "Scope"],
|
||||
"ForStatement": ["Statement", "For", "Scope"],
|
||||
"ForOfStatement": ["Statement", "For", "Scope", "Loop"],
|
||||
"ForInStatement": ["Statement", "For", "Scope", "Loop"],
|
||||
"ForStatement": ["Statement", "For", "Scope", "Loop"],
|
||||
|
||||
"ObjectPattern": ["Pattern"],
|
||||
"ArrayPattern": ["Pattern"],
|
||||
|
||||
@@ -162,7 +162,7 @@ t.toIdentifier = function (name) {
|
||||
return c ? c.toUpperCase() : "";
|
||||
});
|
||||
|
||||
return name;
|
||||
return name || '_';
|
||||
};
|
||||
|
||||
t.isValidIdentifier = function (name) {
|
||||
|
||||
11
package.json
11
package.json
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "6to5",
|
||||
"description": "Turn ES6 code into readable vanilla ES5 with source maps",
|
||||
"version": "1.14.10",
|
||||
"version": "1.14.13",
|
||||
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
||||
"homepage": "https://github.com/6to5/6to5",
|
||||
"repository": {
|
||||
@@ -52,13 +52,14 @@
|
||||
"source-map-support": "0.2.8"
|
||||
},
|
||||
"devDependencies": {
|
||||
"browserify": "6.3.2",
|
||||
"chai": "^1.9.2",
|
||||
"istanbul": "0.3.2",
|
||||
"jshint": "2.5.10",
|
||||
"jshint-stylish": "^1.0.0",
|
||||
"matcha": "0.6.0",
|
||||
"mocha": "1.21.4",
|
||||
"uglify-js": "2.4.15",
|
||||
"browserify": "6.3.2",
|
||||
"rimraf": "2.2.8",
|
||||
"jshint": "2.5.10",
|
||||
"chai": "^1.9.2"
|
||||
"uglify-js": "2.4.15"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
SyntaxError: test.js: Unexpected character '@'
|
||||
SyntaxError: test.js: Unexpected character '#'
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
arr.map(x => {
|
||||
$@!
|
||||
$#!
|
||||
});
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
arr.map(function () {
|
||||
return $@!@#;
|
||||
return $#!;
|
||||
});
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "Unexpected character '@'"
|
||||
"throws": "Unexpected character '#'"
|
||||
}
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
"use strict";
|
||||
|
||||
var _slice = Array.prototype.slice;
|
||||
var _classProps = function (child, staticProps, instanceProps) {
|
||||
if (staticProps) Object.defineProperties(child, staticProps);
|
||||
if (instanceProps) Object.defineProperties(child.prototype, instanceProps);
|
||||
};
|
||||
|
||||
var _extends = function (child, parent) {
|
||||
child.prototype = Object.create(parent.prototype, {
|
||||
constructor: {
|
||||
@@ -34,25 +29,17 @@ var Test = (function (Foo) {
|
||||
|
||||
_extends(Test, Foo);
|
||||
|
||||
_classProps(Test, {
|
||||
foo: {
|
||||
writable: true,
|
||||
value: function () {
|
||||
Foo.foo.call(this);
|
||||
Foo.foo.call.apply(Foo.foo, [this].concat(_slice.call(arguments)));
|
||||
Foo.foo.call.apply(Foo.foo, [this, "test"].concat(_slice.call(arguments)));
|
||||
}
|
||||
}
|
||||
}, {
|
||||
test: {
|
||||
writable: true,
|
||||
value: function () {
|
||||
Foo.prototype.test.call(this);
|
||||
Foo.prototype.test.call.apply(Foo.prototype.test, [this].concat(_slice.call(arguments)));
|
||||
Foo.prototype.test.call.apply(Foo.prototype.test, [this, "test"].concat(_slice.call(arguments)));
|
||||
}
|
||||
}
|
||||
});
|
||||
Test.prototype.test = function () {
|
||||
Foo.prototype.test.call(this);
|
||||
Foo.prototype.test.call.apply(Foo.prototype.test, [this].concat(_slice.call(arguments)));
|
||||
Foo.prototype.test.call.apply(Foo.prototype.test, [this, "test"].concat(_slice.call(arguments)));
|
||||
};
|
||||
|
||||
Test.foo = function () {
|
||||
Foo.foo.call(this);
|
||||
Foo.foo.call.apply(Foo.foo, [this].concat(_slice.call(arguments)));
|
||||
Foo.foo.call.apply(Foo.foo, [this, "test"].concat(_slice.call(arguments)));
|
||||
};
|
||||
|
||||
return Test;
|
||||
})(Foo);
|
||||
|
||||
@@ -1,10 +1,5 @@
|
||||
"use strict";
|
||||
|
||||
var _classProps = function (child, staticProps, instanceProps) {
|
||||
if (staticProps) Object.defineProperties(child, staticProps);
|
||||
if (instanceProps) Object.defineProperties(child.prototype, instanceProps);
|
||||
};
|
||||
|
||||
var _extends = function (child, parent) {
|
||||
child.prototype = Object.create(parent.prototype, {
|
||||
constructor: {
|
||||
@@ -25,14 +20,9 @@ var Test = (function (Foo) {
|
||||
|
||||
_extends(Test, Foo);
|
||||
|
||||
_classProps(Test, {
|
||||
test: {
|
||||
writable: true,
|
||||
value: function () {
|
||||
return Foo.wow.call(this);
|
||||
}
|
||||
}
|
||||
});
|
||||
Test.test = function () {
|
||||
return Foo.wow.call(this);
|
||||
};
|
||||
|
||||
return Test;
|
||||
})(Foo);
|
||||
|
||||
@@ -1,21 +1,11 @@
|
||||
"use strict";
|
||||
|
||||
var _classProps = function (child, staticProps, instanceProps) {
|
||||
if (staticProps) Object.defineProperties(child, staticProps);
|
||||
if (instanceProps) Object.defineProperties(child.prototype, instanceProps);
|
||||
};
|
||||
|
||||
var Test = (function () {
|
||||
var Test = function Test() {};
|
||||
|
||||
_classProps(Test, null, {
|
||||
test: {
|
||||
writable: true,
|
||||
value: function () {
|
||||
return 5 + 5;
|
||||
}
|
||||
}
|
||||
});
|
||||
Test.prototype.test = function () {
|
||||
return 5 + 5;
|
||||
};
|
||||
|
||||
return Test;
|
||||
})();
|
||||
|
||||
@@ -1,10 +1,5 @@
|
||||
"use strict";
|
||||
|
||||
var _classProps = function (child, staticProps, instanceProps) {
|
||||
if (staticProps) Object.defineProperties(child, staticProps);
|
||||
if (instanceProps) Object.defineProperties(child.prototype, instanceProps);
|
||||
};
|
||||
|
||||
var BaseView = function BaseView() {
|
||||
this.autoRender = true;
|
||||
};
|
||||
@@ -16,14 +11,9 @@ var BaseView = function () {
|
||||
var BaseView = (function () {
|
||||
var _class2 = function () {};
|
||||
|
||||
_classProps(_class2, null, {
|
||||
foo: {
|
||||
writable: true,
|
||||
value: function () {
|
||||
this.autoRender = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
_class2.prototype.foo = function () {
|
||||
this.autoRender = true;
|
||||
};
|
||||
|
||||
return _class2;
|
||||
})();
|
||||
|
||||
@@ -8,11 +8,9 @@ var _classProps = function (child, staticProps, instanceProps) {
|
||||
var A = (function () {
|
||||
var A = function A() {};
|
||||
|
||||
A.a = function () {};
|
||||
|
||||
_classProps(A, {
|
||||
a: {
|
||||
writable: true,
|
||||
value: function () {}
|
||||
},
|
||||
b: {
|
||||
get: function () {},
|
||||
set: function (b) {}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
var obj = {
|
||||
[foobar]() {
|
||||
return "foobar";
|
||||
return "foobar";
|
||||
}
|
||||
};
|
||||
|
||||
@@ -4,5 +4,6 @@ var obj = (function (_obj) {
|
||||
_obj[foobar] = function () {
|
||||
return "foobar";
|
||||
};
|
||||
|
||||
return _obj;
|
||||
})({});
|
||||
|
||||
@@ -6,7 +6,9 @@ define(["exports"], function (exports) {
|
||||
exports["default"] = [];
|
||||
exports["default"] = foo;
|
||||
exports["default"] = function () {};
|
||||
|
||||
exports["default"] = function () {};
|
||||
|
||||
function foo() {}
|
||||
exports["default"] = foo;
|
||||
var Foo = function Foo() {};
|
||||
|
||||
@@ -6,7 +6,9 @@ module.exports = {};
|
||||
module.exports = [];
|
||||
module.exports = foo;
|
||||
module.exports = function () {};
|
||||
|
||||
module.exports = function () {};
|
||||
|
||||
function foo() {}
|
||||
var Foo = function Foo() {};
|
||||
|
||||
|
||||
@@ -5,7 +5,9 @@ exports["default"] = {};
|
||||
exports["default"] = [];
|
||||
exports["default"] = foo;
|
||||
exports["default"] = function () {};
|
||||
|
||||
exports["default"] = function () {};
|
||||
|
||||
function foo() {}
|
||||
exports["default"] = foo;
|
||||
var Foo = function Foo() {};
|
||||
|
||||
@@ -12,7 +12,9 @@
|
||||
exports["default"] = [];
|
||||
exports["default"] = foo;
|
||||
exports["default"] = function () {};
|
||||
|
||||
exports["default"] = function () {};
|
||||
|
||||
function foo() {}
|
||||
exports["default"] = foo;
|
||||
var Foo = function Foo() {};
|
||||
|
||||
Reference in New Issue
Block a user