import replacePath from "../helpers/replacePath";

export default function (t, path, state, {toMatch, toRemove, toReplace}) {
	const pathIsImportDeclaration = path.isImportDeclaration();
	const pathToMatch = path.get("source"),
		pathToRemove = pathIsImportDeclaration && !path.node.specifiers.length && path,
		pathToReplace = pathIsImportDeclaration && path.node.specifiers.length && path;
	
	if(pathToMatch.node) {
		replacePath(t, {
			pathToMatch,
			pathToRemove,
			// TODO replacement functionality
			pathToReplace,
			toMatch, toRemove, toReplace
		}, state);
	}
}
@@ -44,16 +44,1183 @@
 Path%22;%0A%0A
+const replaceImport = (t, replacementObj, pathToReplace) =%3E %7B%0A%09const props = %5B%5D;%0A%09let firstDeclaration, firstIdentifier;%0A%09%0A%09for(let specifier of pathToReplace.node.specifiers) %7B%0A%09%09if(t.isImportNamespaceSpecifier(specifier)) %7B%0A%09%09%09firstDeclaration = t.variableDeclarator(firstIdentifier = specifier.local, replacementObj);%0A%09%09%7D else %7B%0A%09%09%09const isDefaultSpecifier = t.isImportDefaultSpecifier(specifier);%0A%09%09%09%0A%09%09%09const imported = isDefaultSpecifier ? t.Identifier(%22default%22) : specifier.imported;%0A%09%09%09const local = specifier.local;%0A%09%09%09%0A%09%09%09const shorthand = !isDefaultSpecifier && imported.start === local.start && imported.end === local.end;%0A%09%09%09const objectProp = t.objectProperty(%0A%09%09%09%09imported,%0A%09%09%09%09specifier.local, false, shorthand%0A%09%09%09);%0A%09%09%09props.push(objectProp);%0A%09%09%7D%0A%09%7D%0A%09%0A%09const declarations =%0A%09%09firstDeclaration ?%0A%09%09%09props.length ?%0A%09%09%09%09%5BfirstDeclaration, t.variableDeclarator(t.objectPattern(props, null), firstIdentifier)%5D : %5BfirstDeclaration%5D :%0A%09%09props.length ?%0A%09%09%09%5Bt.variableDeclarator(t.objectPattern(props), replacementObj)%5D : %5B%5D;%0A%09%0A%09const variableDeclaration = t.variableDeclaration(%22const%22, declarations);%0A%09%0A%09pathToReplace.replaceWith(variableDeclaration);%0A%7D;%0A%0A
 export d
@@ -1634,45 +1634,8 @@
 ve,%0A
-%09%09%09// TODO replacement functionality%0A
 %09%09%09p
@@ -1679,16 +1679,45 @@
 oReplace
+,%0A%09%09%09replaceFn: replaceImport
 %0A%09%09%7D, st

Allow to replace named imports with objects per property