diff --git a/lib/babel/transformation/transformers/es6/classes.js b/lib/babel/transformation/transformers/es6/classes.js index 8ca8786924..c82d8566a0 100644 --- a/lib/babel/transformation/transformers/es6/classes.js +++ b/lib/babel/transformation/transformers/es6/classes.js @@ -65,6 +65,7 @@ function ClassTransformer(node, file, scope, isStatement) { ClassTransformer.prototype.run = function () { var superName = this.superName; var className = this.className; + var classBody = this.node.body.body; var file = this.file; // @@ -86,7 +87,10 @@ ClassTransformer.prototype.run = function () { var constructorName = null; // when class has no parent and there is only constructor or nothing then // constructor is not wrapped in closure and has to be named - if (!this.hasSuper && this.node.body.body.length <= 1) { + var containsOnlyConstructor = classBody.length === 1 && + classBody[0].key.name === "constructor"; + if (!this.hasSuper && (classBody.length === 0 || + containsOnlyConstructor)) { constructorName = className; }