Skip to content

Commit

Permalink
fix default exported classes without a name (#4518)
Browse files Browse the repository at this point in the history
* fix default exported classes without a name

This correctly requeues class without name so the es3 transform can
transform the default keyword.

* Replace phabricator issue number with github
  • Loading branch information
danez authored and hzoo committed Sep 18, 2016
1 parent 590ad4d commit cbbc1c7
Show file tree
Hide file tree
Showing 13 changed files with 65 additions and 1 deletion.
Expand Up @@ -267,13 +267,18 @@ export default function () {
]);
} else {
path.replaceWith(buildExportsAssignment(defNode, t.toExpression(declaration.node)));

// Manualy re-queue `export default class {}` expressions so that the ES3 transform
// has an opportunity to convert them. Ideally this would happen automatically from the
// replaceWith above. See #4140 for more info.
path.parentPath.requeue(path.get("expression.left"));
}
} else {
path.replaceWith(buildExportsAssignment(t.identifier("default"), declaration.node));

// Manualy re-queue `export default foo;` expressions so that the ES3 transform
// has an opportunity to convert them. Ideally this would happen automatically from the
// replaceWith above. See T7166 for more info.
// replaceWith above. See #4140 for more info.
path.parentPath.requeue(path.get("expression.left"));
}
exportDefaultFound = true;
Expand Down
@@ -0,0 +1 @@
export default class {}
@@ -0,0 +1,6 @@
"use strict";

Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = class {};
@@ -0,0 +1,7 @@
{
"plugins": [
"transform-es2015-modules-commonjs",
"transform-es3-member-expression-literals",
"transform-es3-property-literals"
]
}
@@ -0,0 +1 @@
export default function () {}
@@ -0,0 +1,7 @@
"use strict";

Object.defineProperty(exports, "__esModule", {
value: true
});

exports["default"] = function () {};
@@ -0,0 +1,7 @@
{
"plugins": [
"transform-es2015-modules-commonjs",
"transform-es3-member-expression-literals",
"transform-es3-property-literals"
]
}
@@ -0,0 +1 @@
export default class Foo {}
@@ -0,0 +1,7 @@
"use strict";

Object.defineProperty(exports, "__esModule", {
value: true
});
class Foo {}
exports["default"] = Foo;
@@ -0,0 +1,7 @@
{
"plugins": [
"transform-es2015-modules-commonjs",
"transform-es3-member-expression-literals",
"transform-es3-property-literals"
]
}
@@ -0,0 +1 @@
export default function bat () {}
@@ -0,0 +1,7 @@
"use strict";

Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = bat;
function bat() {}
@@ -0,0 +1,7 @@
{
"plugins": [
"transform-es2015-modules-commonjs",
"transform-es3-member-expression-literals",
"transform-es3-property-literals"
]
}

0 comments on commit cbbc1c7

Please sign in to comment.