diff --git a/lib/babel/transformation/transformers/es6/classes.js b/lib/babel/transformation/transformers/es6/classes.js index 6d1705bffa..20df75660c 100644 --- a/lib/babel/transformation/transformers/es6/classes.js +++ b/lib/babel/transformation/transformers/es6/classes.js @@ -83,7 +83,14 @@ ClassTransformer.prototype.run = function () { constructor = t.functionDeclaration(className, [], constructorBody); body.push(constructor); } else { - constructor = t.functionExpression(null, [], constructorBody); + var constructorName = null; + // when there is only constructor or nothing, constructor is not + // wrapped in closure and has to be named + if (this.node.body.body.length <= 1) { + constructorName = className; + } + + constructor = t.functionExpression(constructorName, [], constructorBody); body.push(t.variableDeclaration("var", [ t.variableDeclarator(className, constructor) ]));