Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f1a2401681 | ||
|
|
2d61672cdb | ||
|
|
1b00ba21a1 | ||
|
|
f8ea386f3c | ||
|
|
2527fffbad | ||
|
|
86498ad990 | ||
|
|
27c8804214 | ||
|
|
2b6f0ee780 | ||
|
|
c7c9660c79 | ||
|
|
ff025e63ec | ||
|
|
9fb6681ad3 |
@@ -1,3 +1,12 @@
|
||||
# 1.14.2
|
||||
|
||||
* Fix `commonInterop` default export handling.
|
||||
* Fix keyworded property key identifiers being turned into computed property key literals.
|
||||
|
||||
# 1.14.1
|
||||
|
||||
* Inherit comments from `ClassDeclaration`.
|
||||
|
||||
# 1.14.0
|
||||
|
||||
* Add [playground](https://6to5.github.io/playground.html).
|
||||
|
||||
@@ -44,10 +44,10 @@ equivalent to:
|
||||
|
||||
```javascript
|
||||
var obj = {};
|
||||
if (Object.prototype.hasOwnProperty.call(obj, "x")) obj.x = 2;
|
||||
if (!Object.prototype.hasOwnProperty.call(obj, "x")) obj.x = 2;
|
||||
```
|
||||
|
||||
### Method binding expression.
|
||||
### Method binding expression
|
||||
|
||||
```javascript
|
||||
var fn = obj:method;
|
||||
|
||||
@@ -3,10 +3,16 @@ module.exports = CommonJSInteropFormatter;
|
||||
var CommonJSFormatter = require("./common");
|
||||
var util = require("../../util");
|
||||
var t = require("../../types");
|
||||
var _ = require("lodash");
|
||||
|
||||
function CommonJSInteropFormatter() {
|
||||
this.has = false;
|
||||
function CommonJSInteropFormatter(file) {
|
||||
CommonJSFormatter.apply(this, arguments);
|
||||
|
||||
var has = false;
|
||||
_.each(file.ast.program.body, function (node) {
|
||||
if (t.isExportDeclaration(node) && !node.default) has = true;
|
||||
});
|
||||
this.has = has;
|
||||
}
|
||||
|
||||
util.inherits(CommonJSInteropFormatter, CommonJSFormatter);
|
||||
@@ -40,14 +46,11 @@ CommonJSInteropFormatter.prototype.export = function (node, nodes) {
|
||||
// hoist to the top if this default is a function
|
||||
nodes.push(this._hoistExport(declar, assign));
|
||||
return;
|
||||
} else {
|
||||
this.has = true;
|
||||
}
|
||||
|
||||
CommonJSFormatter.prototype.export.apply(this, arguments);
|
||||
};
|
||||
|
||||
CommonJSInteropFormatter.prototype.exportSpecifier = function () {
|
||||
this.has = true;
|
||||
CommonJSFormatter.prototype.exportSpecifier.apply(this, arguments);
|
||||
};
|
||||
|
||||
@@ -68,7 +68,6 @@ _.each({
|
||||
|
||||
_propertyLiterals: require("./transformers/_property-literals"),
|
||||
_memberExpressioLiterals: require("./transformers/_member-expression-literals"),
|
||||
_memberExpressionKeywords: require("./transformers/_member-expression-keywords"),
|
||||
_moduleFormatter: require("./transformers/_module-formatter")
|
||||
}, function (transformer, key) {
|
||||
transform.transformers[key] = new Transformer(key, transformer);
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
var esutils = require("esutils");
|
||||
var t = require("../../types");
|
||||
|
||||
exports.MemberExpression = function (node) {
|
||||
var prop = node.property;
|
||||
if (t.isIdentifier(prop) && esutils.keyword.isKeywordES6(prop.name, true)) {
|
||||
node.property = t.literal(prop.name);
|
||||
node.computed = true;
|
||||
}
|
||||
};
|
||||
@@ -1,4 +1,5 @@
|
||||
var t = require("../../types");
|
||||
var esutils = require("esutils");
|
||||
var t = require("../../types");
|
||||
|
||||
exports.MemberExpression = function (node) {
|
||||
var prop = node.property;
|
||||
@@ -6,5 +7,8 @@ exports.MemberExpression = function (node) {
|
||||
// computed literal that is a valid identifier
|
||||
node.property = t.identifier(prop.value);
|
||||
node.computed = false;
|
||||
} else if (!node.computed && t.isIdentifier(prop) && esutils.keyword.isKeywordES6(prop.name, true)) {
|
||||
node.property = t.literal(prop.name);
|
||||
node.computed = true;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -7,9 +7,8 @@ exports.Property = function (node) {
|
||||
// property key is a literal but a valid identifier
|
||||
node.key = t.identifier(key.value);
|
||||
node.computed = false;
|
||||
} else if (t.isIdentifier(key) && esutils.keyword.isKeywordES6(key.name, true)) {
|
||||
} else if (!node.computed && t.isIdentifier(key) && esutils.keyword.isKeywordES6(key.name, true)) {
|
||||
// property key is a keyword
|
||||
node.key = t.literal(key.name);
|
||||
node.computed = true;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -4,9 +4,13 @@ var t = require("../../types");
|
||||
var _ = require("lodash");
|
||||
|
||||
exports.ClassDeclaration = function (node, parent, file, scope) {
|
||||
return t.variableDeclaration("let", [
|
||||
t.variableDeclarator(node.id, new Class(node, file, scope).run())
|
||||
var built = new Class(node, file, scope).run();
|
||||
|
||||
var declar = t.variableDeclaration("let", [
|
||||
t.variableDeclarator(node.id, built)
|
||||
]);
|
||||
t.inheritsComments(declar, node);
|
||||
return declar;
|
||||
};
|
||||
|
||||
exports.ClassExpression = function (node, parent, file, scope) {
|
||||
|
||||
@@ -114,7 +114,9 @@ t.shallowEqual = function (actual, expected) {
|
||||
//
|
||||
|
||||
t.isDynamic = function (node) {
|
||||
if (t.isIdentifier(node) || t.isLiteral(node) || t.isThisExpression(node)) {
|
||||
if (t.isParenthesizedExpression(node)) {
|
||||
return t.isDynamic(node.expression);
|
||||
} else if (t.isIdentifier(node) || t.isLiteral(node) || t.isThisExpression(node)) {
|
||||
return false;
|
||||
} else if (t.isMemberExpression(node)) {
|
||||
return t.isDynamic(node.object) || t.isDynamic(node.property);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "6to5",
|
||||
"description": "Turn ES6 code into readable vanilla ES5 with source maps",
|
||||
"version": "1.14.0",
|
||||
"version": "1.14.2",
|
||||
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
||||
"homepage": "https://github.com/6to5/6to5",
|
||||
"repository": {
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
test.catch;
|
||||
test.catch["foo"];
|
||||
test["catch"];
|
||||
test["catch"]["foo"];
|
||||
@@ -1,6 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
test["catch"];
|
||||
test["catch"].foo;
|
||||
test["catch"];
|
||||
test["catch"].foo;
|
||||
@@ -1 +1,6 @@
|
||||
obj["x"] = 2;
|
||||
|
||||
test.catch;
|
||||
test.catch["foo"];
|
||||
test["catch"];
|
||||
test["catch"]["foo"];
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
"use strict";
|
||||
|
||||
obj.x = 2;
|
||||
|
||||
test["catch"];
|
||||
test["catch"].foo;
|
||||
test["catch"];
|
||||
test["catch"].foo;
|
||||
|
||||
Reference in New Issue
Block a user