Make .insert{Before,After} work by default when the parent is an eport declaration (#7040)

This commit is contained in:
Nicolò Ribaudo
2017-12-19 00:05:29 +01:00
committed by GitHub
parent 17b37b5013
commit 68476b6ddd
6 changed files with 88 additions and 38 deletions

View File

@@ -228,15 +228,9 @@ export default function(api, options) {
if (path.isClassExpression()) {
path.scope.push({ id: ref });
path.replaceWith(t.assignmentExpression("=", ref, path.node));
} else {
// path.isClassDeclaration()
if (!path.node.id) {
path.node.id = ref;
}
if (path.parentPath.isExportDeclaration()) {
path = path.parentPath;
}
} else if (!path.node.id) {
// Anonymous class declaration
path.node.id = ref;
}
path.insertAfter(nodes);