function transform(file, { j }) { const root = j(file.source); root.find(j.ImportDeclaration, { source: { value: v => v.startsWith('lodash') } }).replaceWith(path => { const { node } = path; const newSourceValue = node.source.value.replace('lodash', 'es-toolkit'); return j.importDeclaration(node.specifiers, j.literal(newSourceValue)); }); return root.toSource(); } export default transform;
Input
import { debounce, chunk } from 'lodash'; import { countBy } from 'lodash/array';
Output
loading
Read-only