{"id":17274612,"url":"https://github.com/rip21/import-move-codemod","last_synced_at":"2025-10-09T02:47:04.527Z","repository":{"id":39563618,"uuid":"280229590","full_name":"RIP21/import-move-codemod","owner":"RIP21","description":"Codemod that helps with moving selectively imports from one package to another. Super useful in monorepos or just bulk refactorings of some 3rd party dependencies.","archived":false,"fork":false,"pushed_at":"2023-01-06T11:40:16.000Z","size":1521,"stargazers_count":8,"open_issues_count":16,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-04-14T12:55:28.288Z","etag":null,"topics":["babel","babel-codemod","codemod","codeshift","import","imports","move","refactoring","rename"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/RIP21.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-07-16T18:33:26.000Z","updated_at":"2024-03-29T03:58:16.000Z","dependencies_parsed_at":"2023-02-06T00:16:19.939Z","dependency_job_id":null,"html_url":"https://github.com/RIP21/import-move-codemod","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RIP21%2Fimport-move-codemod","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RIP21%2Fimport-move-codemod/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RIP21%2Fimport-move-codemod/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RIP21%2Fimport-move-codemod/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RIP21","download_url":"https://codeload.github.com/RIP21/import-move-codemod/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248852109,"owners_count":21171839,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["babel","babel-codemod","codemod","codeshift","import","imports","move","refactoring","rename"],"created_at":"2024-10-15T08:54:20.738Z","updated_at":"2025-10-09T02:46:59.500Z","avatar_url":"https://github.com/RIP21.png","language":"TypeScript","readme":"# import-move-codemod\n![npm](https://img.shields.io/npm/v/import-move-codemod)\n\nCodemod to move imports from one module to another. Super useful in huge monorepos or huge migrations of 3rd party packages.\n\n## Usage\n\nInside your project root run\nFor `npm`\n```\nnpm i import-move-codemod --save-dev\n```\nor for `yarn`\n```\nyarn add import-move-codemod --dev\n```\nor for `pnpm`\n```\npnpm add import-move-codemod --D\n```\n\nBefore the run you need to create a file with a config, let say `codemod.json`\n```json\n{\n  \"module\": {\n    \"from\": \"one\",\n    \"to\": \"two\"\n  },\n  \"specifiers\": [\"One\"]\n}\n```\n\nThen for example to run codemod against all the files in `/src` run \n```\nnpx @codemod/cli -p import-move-codemod -o import-move-codemod=@codemod.json --printer prettier /src \n```\n\n\n\n\n## What refactorings are available\n\n### Move of one or multiple named imports from one module to another\n\n```\n{\n  module: {\n    from: \"one\",\n    to: \"two\"\n  },\n  specifiers: [\"One\"]\n}\n```\n\n```ts\nimport { One } from 'one'\n\n//      ↓ ↓ ↓ ↓ ↓ ↓\n\nimport { One } from 'two';\n```\n\n```\n{\n  module: {\n    from: \"one\",\n    to: \"two\"\n  },\n  specifiers: [\"One\", \"Two\"]\n}\n```\n\n```ts\nimport { One, Two } from 'one'\n\n//      ↓ ↓ ↓ ↓ ↓ ↓\n\nimport { One, Two } from 'two';\n```\n\n```ts\nimport { One as OneA, Two as TwoA } from 'one'\n\n//      ↓ ↓ ↓ ↓ ↓ ↓\n\nimport { One as OneA, Two as TwoA } from 'two';\n\n```\n\n```\n{\n  module: {\n    from: \"one\",\n    to: \"two\"\n  },\n  specifiers: [\"Two\"]\n}\n```\n\n```ts\nimport { One, Two } from 'one'\n\n//      ↓ ↓ ↓ ↓ ↓ ↓\n\nimport { Two } from 'two';\nimport { One } from 'one';\n```\n\n### Move named imports and default in one go\n\n```\n{\n  module: {\n    from: \"one\",\n    to: \"two\"\n  },\n  specifiers: [\"default\", \"One\", \"Two\"]\n}\n```\n\n\n```ts\nimport ADefault, { One, Two, Three } from 'one'\n\n//     ↓ ↓ ↓ ↓ ↓ ↓\n\nimport ADefault, { One, Two } from 'two';\nimport { Three } from 'one';\n```\n\n```\n{\n  module: {\n    from: \"one\",\n    to: \"two\"\n  },\n  specifiers: [\"default\", \"Two\"]\n}\n```\n\n```ts\nimport One, { Two } from 'one'\n\n //     ↓ ↓ ↓ ↓ ↓ ↓\n\nimport One, { Two } from 'two';\n```\n\n### Move everything i.e. module rename\n\n```\n{\n  module: {\n    from: \"one\",\n    to: \"two\"\n  },\n  specifiers: [\"*\"]\n}\n```\n\n```ts\nimport ADefault, { One, Two, Three } from 'one'\n\n//      ↓ ↓ ↓ ↓ ↓ ↓\n\nimport ADefault, { One, Two, Three } from 'two';\n\n```\n\n### Move named imports and rename them\n\n```\n{\n  module: {\n    from: \"one\",\n    to: \"two\"\n  },\n  specifiers: {\n    One: \"OneR\",\n    Two: \"TwoR\"\n  }\n}\n```\n\n```ts\nimport ADefault, { One, Two } from 'one'\n\n//      ↓ ↓ ↓ ↓ ↓ ↓\n\nimport { OneR, TwoR } from 'two';\nimport ADefault from 'one';\n```\n\n```ts\nimport { One, Two } from 'one'\n\n//      ↓ ↓ ↓ ↓ ↓ ↓\n\nimport { OneR, TwoR } from 'two';\n```\n\n### Move default import to named\n```\n{\n  module: {\n    from: \"one\",\n    to: \"two\"\n  },\n  specifiers: { default: \"One\" }\n}\n```\n\n```ts\nimport One, { Two } from 'one'\n\n//      ↓ ↓ ↓ ↓ ↓ ↓\n\nimport { One } from 'two';\nimport { Two } from 'one';\n```\n\n```ts\nimport One from 'one'\n\n//      ↓ ↓ ↓ ↓ ↓ ↓\n\nimport { One } from 'two';\n```\n\n### Move only default import\n\n```\n{\n  module: {\n    from: \"one\",\n    to: \"two\"\n  },\n  specifiers: [\"default\"]\n}\n```\n\n```ts\nimport ADefault, { One, Two, Three } from 'one'\n\n//      ↓ ↓ ↓ ↓ ↓ ↓\n\nimport ADefault from 'two';\nimport { One, Two, Three } from 'one';\n```\n\n```ts\nimport One from 'one'\n\n//      ↓ ↓ ↓ ↓ ↓ ↓\n\nimport One from 'two';\n```\n\n### Make default import from named\n\n```\n{\n  module: {\n    from: \"one\",\n    to: \"two\"\n  },\n  specifiers: {\n    One: \"default\"\n  }\n}\n```\n\n```ts\nimport { One } from 'one'\n\n//      ↓ ↓ ↓ ↓ ↓ ↓\n\nimport One from 'two';\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frip21%2Fimport-move-codemod","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frip21%2Fimport-move-codemod","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frip21%2Fimport-move-codemod/lists"}