Ensure that default exports have a name before splitting them - fixes T6750

This commit is contained in:
Logan Smyth 2015-12-05 11:36:44 -08:00
parent 412c65deb3
commit a12a116b9f
3 changed files with 33 additions and 0 deletions

View File

@ -0,0 +1,6 @@
export default function() {
return class Select {
query(query) {
}
}
}

View File

@ -0,0 +1,19 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
function _default() {
return (function () {
function Select() {
babelHelpers.classCallCheck(this, Select);
}
babelHelpers.createClass(Select, [{
key: "query",
value: function query(_query) {}
}]);
return Select;
})();
}
exports.default = _default;

View File

@ -40,6 +40,14 @@ export default class Renamer {
// build specifiers that point back to this export declaration // build specifiers that point back to this export declaration
let isDefault = exportDeclar.isExportDefaultDeclaration(); let isDefault = exportDeclar.isExportDefaultDeclaration();
if (isDefault && (parentDeclar.isFunctionDeclaration() ||
parentDeclar.isClassDeclaration())&& !parentDeclar.node.id) {
// Ensure that default class and function exports have a name so they have a identifier to
// reference from the export specifier list.
parentDeclar.node.id = parentDeclar.scope.generateUidIdentifier("default");
}
let bindingIdentifiers = parentDeclar.getOuterBindingIdentifiers(); let bindingIdentifiers = parentDeclar.getOuterBindingIdentifiers();
let specifiers = []; let specifiers = [];