in codemods/lib/renameImports.js [18:40]
function rewriteImport(from, to, members) {
imports.forEach(decl => {
j(decl)
.find(j.ImportSpecifier, {imported: {name: from}})
.forEach(spec => {
if (importsByName[to] && members.length) {
// if the destination import already exists and there are members
// in this identifier, then this one is a dupe
j(spec).remove()
} else {
// otherwise, we can safely rename this one to the new identifier
spec.node.imported.name = to
importsByName[to] = spec
}
})
})
// replace all of the rewritten identifiers with member expressions
ast
.find(j.Identifier, {name: from})
.filter(id => id.parent.node.type !== 'ImportSpecifier')
.replaceWith(memberExpression(to, ...members))
}