{"id":13532278,"url":"https://github.com/suchipi/transform-imports","last_synced_at":"2025-09-08T18:31:02.790Z","repository":{"id":51766844,"uuid":"122303711","full_name":"suchipi/transform-imports","owner":"suchipi","description":"Tools that make it easy to codemod imports/requires in your JS","archived":false,"fork":false,"pushed_at":"2024-05-07T14:25:47.000Z","size":1347,"stargazers_count":55,"open_issues_count":9,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-08-22T12:58:13.451Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/suchipi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-02-21T07:12:53.000Z","updated_at":"2024-07-07T21:41:42.000Z","dependencies_parsed_at":"2024-06-18T18:35:57.035Z","dependency_job_id":null,"html_url":"https://github.com/suchipi/transform-imports","commit_stats":{"total_commits":91,"total_committers":4,"mean_commits":22.75,"dds":"0.10989010989010994","last_synced_commit":"b6abcf352f19cbf75d451f77240140ad61b75073"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/suchipi/transform-imports","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/suchipi%2Ftransform-imports","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/suchipi%2Ftransform-imports/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/suchipi%2Ftransform-imports/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/suchipi%2Ftransform-imports/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/suchipi","download_url":"https://codeload.github.com/suchipi/transform-imports/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/suchipi%2Ftransform-imports/sbom","scorecard":{"id":857121,"data":{"date":"2025-08-11","repo":{"name":"github.com/suchipi/transform-imports","commit":"b6abcf352f19cbf75d451f77240140ad61b75073"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":1.6,"checks":[{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Code-Review","score":0,"reason":"Found 1/13 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":0,"reason":"license file not detected","details":["Warn: project does not have a license file"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 18 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":2,"reason":"8 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-968p-4wvh-cqc8","Warn: Project is vulnerable to: GHSA-h5c3-5r3r-rr8q","Warn: Project is vulnerable to: GHSA-rmvr-2pp2-xj38","Warn: Project is vulnerable to: GHSA-xx4v-prfh-6cgc","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-24T00:08:05.413Z","repository_id":51766844,"created_at":"2025-08-24T00:08:05.413Z","updated_at":"2025-08-24T00:08:05.413Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274229367,"owners_count":25245187,"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","status":"online","status_checked_at":"2025-09-08T02:00:09.813Z","response_time":121,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2024-08-01T07:01:09.686Z","updated_at":"2025-09-08T18:31:02.433Z","avatar_url":"https://github.com/suchipi.png","language":"JavaScript","funding_links":[],"categories":["JavaScript","others"],"sub_categories":[],"readme":"# transform-imports\n\nAn API that makes it easy to transform imports and require calls.\n\n## Usage\n\n```js\nimport transformImports from \"transform-imports\";\n\nconst code = `\n  import Foo from \"foo\";\n  import Bar from \"bar\";\n`;\n\nconst newCode = transformImports(code, (importDefs) =\u003e {\n  importDefs.forEach((importDef) =\u003e {\n    if (importDef.source === \"bar\") {\n      importDef.source = \"something-new\";\n    }\n  });\n});\n\nconsole.log(newCode);\n// Logs:\n// import Foo from \"foo\";\n// import Foo from \"something-new\";\n```\n\n`transformImports` calls its callback with an Array of `ImportDefinition` objects, which have this shape:\n\n```ts\nclass ImportDefinition {\n  variableName: ?string;\n  source: ?string;\n  importedExport: {\n    name: string,\n    isImportedAsCJS: boolean,\n  };\n  kind: \"value\" | \"type\" | \"typeof\",\n  isDynamicImport: boolean,\n  path: NodePath;\n\n  remove(): void;\n  fork(?{ insert: \"before\" | \"after\" }): void;\n}\n```\n\nYou can change the values of the properties on the `ImportDefinition` or call the methods on it to change the underlying import/require statement.\n\nEach `ImportDefinition` is associated with a single import; that is, `import { red, blue } from \"colors\"` contains two `ImportDefinitions` (one for `red` and one for `blue`).\n\nHere's an example of what some different imports/requires parse into:\n\n```js\nimport * as React from \"react\";\n// Becomes...\nImportDefinition {\n  variableName: \"React\",\n  source: \"react\",\n  importedExport: {\n    name: \"*\",\n    isImportedAsCJS: false,\n  },\n  kind: \"value\",\n  isDynamicImport: false,\n};\n\nimport traverse from \"babel-traverse\";\n// Becomes...\nImportDefinition {\n  variableName: \"traverse\",\n  source: \"babel-traverse\",\n  importedExport: {\n    name: \"default\",\n    isImportedAsCJS: false,\n  },\n  kind: \"value\",\n  isDynamicImport: false,\n};\n\nimport MyClass, { SOME_CONSTANT } from \"my-library\";\n// Becomes...\nImportDefinition {\n  variableName: \"MyClass\",\n  source: \"my-library\",\n  importedExport: {\n    name: \"default\",\n    isImportedAsCJS: false,\n  },\n  kind: \"value\",\n  isDynamicImport: false,\n};\n// and\nImportDefinition {\n  variableName: \"SOME_CONSTANT\",\n  source: \"my-library\",\n  importedExport: {\n    name: \"SOME_CONSTANT\",\n    isImportedAsCJS: false,\n  },\n  kind: \"value\",\n  isDynamicImport: false,\n};\n\nconst PropTypes = require(\"prop-types\");\n// Becomes...\nImportDefinition {\n  variableName: \"PropTypes\",\n  source: \"prop-types\",\n  importedExport: {\n    name: \"*\",\n    isImportedAsCJS: true,\n  },\n  kind: \"value\",\n  isDynamicImport: false,\n};\n\nconst { darken, lighten } = require(\"polished\");\n// Becomes...\nImportDefinition {\n  variableName: \"darken\",\n  source: \"polished\",\n  importedExport: {\n    name: \"darken\",\n    isImportedAsCJS: true,\n  },\n  kind: \"value\",\n  isDynamicImport: false,\n};\n// and\nImportDefinition {\n  variableName: \"lighten\",\n  source: \"polished\",\n  importedExport: {\n    name: \"lighten\",\n    isImportedAsCJS: true,\n  },\n  kind: \"value\",\n  isDynamicImport: false,\n};\n\nimport type {Node} from \"./node\";\n// Becomes...\nImportDefinition {\n  variableName: \"Node\",\n  source: \"./node\",\n  importedExport: {\n    name: \"Node\",\n    isImportedAsCJS: false,\n  },\n  kind: \"type\",\n  isDynamicImport: false,\n};\n\nimport \"something\";\n// Becomes...\nImportDefinition {\n  variableName: null,\n  source: \"something\",\n  importedExport: {\n    name: \"*\",\n    isImportedAsCJS: false,\n  },\n  kind: \"value\",\n  isDynamicImport: false,\n};\n\nimport(\"something\").then((somethingModule) =\u003e somethingModule.default());\n// Becomes...\nImportDefinition {\n  variableName: null,\n  source: \"something\",\n  importedExport: {\n    name: \"*\",\n    isImportedAsCJS: false,\n  },\n  kind: \"value\",\n  isDynamicImport: true,\n};\n```\n\nHere's some more in-depth documentation explaining what each property means/does. In each example, `importDef` refers to an `ImportDefinition` object as passed to the `transformImports` callback.\n\n### `variableName`\n\nThis refers to the name of the variable that was created by the import. For example, in `import MyThing from \"./overThere\";`, it would be `MyThing`.\n\nIf you change this string, then the variable name in the code will change. So doing this:\n\n```js\nimportDef.variableName = \"MyOtherThing\";\n```\n\nwould change the code into:\n\n```js\nimport MyOtherThing from \"./overThere\";\n```\n\nWhen dealing with named imports, this only refers to the name of the local variable created. To also change the name of the variable that is being imported, change `importedExport.name`:\n\n```js\n// Given this code:\nimport { red } from \"./colors\";\n\n// Doing this:\nimportDef.variableName = \"blue\";\n\n// Would only change the code to this:\nimport { red as blue } from \"./colors\";\n\n// But doing this:\nimportDef.variableName = \"blue\";\nimportDef.importedExport.name = \"blue\";\n\n// Would change the code to this:\nimport { blue } from \"blue\";\n```\n\nChanging `variableName` does not rename references to the variable:\n\n```js\n// Given this code:\nimport MyThing from \"./overThere\";\n\nMyThing.isCool();\n\n// Doing this:\nimportDef.variableName = \"MyOtherThing\";\n\n// Would change the code to this:\nimport MyOtherThing from \"./overThere\";\n\nMyThing.isCool();\n```\n\nIf you want to also change references to the variable, you can use the babel Scope object found at `importDef.path.scope`.\n\n\u003e NOTE: An `ImportDefinition` referring to a dynamic import (`import(\"foo\")`) or bare import (`import \"foo\";`) has no `variableName`, and attempting to set the `variableName` will throw an Error.\n\n### `source`\n\nThis refers to the string indicating which file or package this import was obtained from. So for `const Theme = require(\"../theme\")`, it would be `\"../theme\"`.\n\nIf you change this string, then the import's source will change.\n\n```js\n// Given this code:\nimport Something from \"../somewhere\";\n\n// Doing this:\nimportDef.source = \"../somewhereElse\";\n\n// Would change the code to this:\nimport Something from \"../somewhereElse\";\n```\n\nNote that the source string always reflects the source string found in the source code. If you would like to find the absolute path to a given imported file, you will need to use another package, like `eslint-import-resolver-node` or `eslint-import-resolver-webpack`:\n\n```js\nconst fileLocation = \"/Users/suchipi/Code/my-project/something.js\"; // Get this from babel, jscodeshift, etc\n\nconst { resolve } = require(\"eslint-import-resolver-webpack\");\nconst { found, path } = resolve(importDef.source, fileLocation, {\n  /* import resolver config goes here */\n});\n```\n\nFor more info, see [the eslint-plugin-import Resolver spec](https://github.com/benmosher/eslint-plugin-import/blob/master/resolvers/README.md).\n\n### `importedExport.name`\n\nThis refers to the name of the export that is being imported into the file where the code associated with this `ImportDefinition` is.\n\nFor example, given two files `one.js` and `two.js`:\n\n```js\n// one.js\n\nconst Chunky = \"chunky\";\nconst Bacon = \"bacon\";\n\nexport { Chunky, Bacon };\n```\n\n```js\n// two.js\n\nimport { Chunky as BaconStyle } from \"./one\";\n\nconsole.log(BaconStyle);\n```\n\nThe value of `importedExport.name` for the import in `two.js` would be `Chunky`.\n\nIf you change this string, then which export you pull in from `two.js` would change:\n\n```js\n// If you did this:\nimportDef.importedExport.name = \"default\";\n\n// Then it would change into a default import:\nimport BaconStyle from \"./one\";\n\n// If you did this:\nimportDef.importedExport.name = \"*\";\n\n// Then it would change into a namespace import:\nimport * as BaconStyle from \"./one\";\n\n// If you did anything else:\nimportDef.importedExport.name = \"Bacon\";\n\n// Then it would change which named export is imported:\nimport { Bacon as BaconStyle } from \"./one\";\n```\n\n\u003e NOTE: Attempting to change `importedExport.name` on an `ImportDefinition` referring to a dynamic import (`import(\"foo\")`) or bare import (`import \"foo\";`) will throw an Error.\n\n### `importedExport.isImportedAsCJS`\n\nThis refers to the whether the import is using CommonJS or not. Changing this to `true` will change an import statement into a require call, and changing this to `false` will change a require call into an import statement.\n\n```js\n// Given this code:\nimport Default from \"somewhere\";\nimport * as Star from \"somewhere-else\";\nimport { Named } from \"somewhere-else-else\";\n\n// If you did this to each ImportDefinition:\nimportDef.importedExport.isImportedAsCJS = true;\n\n// Then the code would change into this:\nconst { default: Default } = require(\"somewhere\");\nconst Star = require(\"somewhere-else\");\nconst { Named } = require(\"somewhere-else-else\");\n\n// Likewise, given this code:\nconst All = require(\"all\");\nconst { Some, Members } = require(\"members\");\n\n// If you did this to each ImportDefinition:\nimportDef.importedExport.isImportedAsCJS = false;\n\n// Then the code would change into this:\nimport * as All from \"all\";\nimport { Some, Members } from \"members\";\n```\n\nNote that in `const Foo = require(\"foo\")`, `importedExport.name` is `\"*\"`, not `\"default\"` like might be expected. This is because `\"*\"` is the most accurate representation of the way CommonJS imports work in most compilation pipelines.\n\n\u003e NOTE: Attempting to change `importedExport.isImportedAsCJS` on an `ImportDefinition` referring to a dynamic import (`import(\"foo\")`) or bare import (`import \"foo\";`) will throw an Error.\n\n### `kind`\n\nThis value indicates whether the import is a flow type/typeof import, or if it is a normal import (a value import). Possible values are `\"type\"`, `\"typeof\"`, and `\"value\"`. Changing this value will change the import into a type, typeof, or value import.\n\n```js\n// Given this code:\nimport Default from \"somewhere\";\nimport * as Star from \"somewhere-else\";\nimport { Named } from \"somewhere-else-else\";\n\n// If you did this to each ImportDefinition:\nimportDef.kind = \"type\";\n\n// Then the code would change into this:\nimport type Default from \"somewhere\";\nimport type * as Star from \"somewhere-else\";\nimport type { Named } from \"somewhere-else-else\";\n\n// Likewise, if you did this to each ImportDefinition:\nimportDef.kind = \"typeof\";\n\n// Then the code would change into this:\nimport typeof Default from \"somewhere\";\nimport typeof * as Star from \"somewhere-else\";\nimport typeof { Named } from \"somewhere-else-else\";\n```\n\nIf you change a require call's kind into type or typeof, then it will turn into an import statement according to the rules established when changing `importedExport.isImportedAsCJS`:\n\n```js\n// Given this code:\nconst All = require(\"all\");\nconst { Some, Members } = require(\"members\");\n\n// If you did this to each ImportDefinition:\nimportDef.kind = \"type\";\n\n// Then the code would change into this:\nimport type * as All from \"all\";\nimport type { Some, Members } from \"members\";\n```\n\n\u003e NOTE: Attempting to change `kind` on an `ImportDefinition` referring to a dynamic import (`import(\"foo\")`) or bare import (`import \"foo\";`) will throw an Error.\n\n### `isDynamicImport`\n\nWhether the import is a dynamic import (`import(\"something\")`).\n\nThis property is not writable.\n\n### `remove()`\n\nCalling this method removes the import specifier associated with this `ImportDefinition` from the source code.\n\n```js\n// Given this code:\nimport * as Everything from \"everything\";\n\nEverything.isAwesome();\n\n// Doing this:\nimportDef.remove();\n\n// Would change the code to this:\nEverything.isAwesome();\n```\n\nIf the `ImportDefinition` refers to an import that is not alone in its import/require statement, then only it will be removed:\n\n```js\n// Given this code:\nimport { One, Two } from \"every-number\";\n\nconsole.log(One \u003c Two);\n\n// Doing this to the ImportDefinition referring to `One`:\nimportDef.remove();\n\n// Would change the code to this:\nimport { Two } from \"every-number\";\n\nconsole.log(One \u003c Two);\n```\n\n\u003e NOTE: Attempting to call `remove()` on an `ImportDefinition` referring to a dynamic import (`import()`) will throw an Error.\n\n### `fork()`\n\nCalling this method will split an import specifier away from its related specifiers into its own statement:\n\n```js\n// Given this code:\nimport { One, Two } from \"every-number\";\n\n// Doing this to the ImportDefinition referring to `One`:\nimportDef.fork();\n\n// Would change the code to this:\nimport { Two } from \"every-number\";\nimport { One } from \"every-number\";\n```\n\nNote that the new import/require declaration is inserted _after_ the existing one by default. To change this behavior, call `fork` with `{ insert: \"before\" }`:\n\n```js\n// Given this code:\nimport { One, Two } from \"every-number\";\n\n// Doing this to the ImportDefinition referring to `One`:\nimportDef.fork({ insert: \"before\" });\n\n// Would change the code to this:\nimport { One } from \"every-number\";\nimport { Two } from \"every-number\";\n```\n\n`fork()` is automatically called when you change properties of an `ImportDefinition` such that it cannot remain with its sibling specifiers in the same statement anymore:\n\n```js\n// Given this code:\nimport { One, Two } from \"every-number\";\n\n// Doing this to the ImportDefinition referring to `One`:\nimportDef.source = \"most-numbers\";\n\n// Would change the code to this:\nimport { Two } from \"every-number\";\nimport { One } from \"most-numbers\";\n```\n\n## Usage with jscodeshift\n\n`transform-imports` uses [recast](https://github.com/benjamn/recast), so untouched source styling is preserved. This means that it's suitable for usage in jscodeshift:\n\n```js\n// An example jscodeshift transform module that turns\n//   import React, { PropTypes } from \"react\";\n// into\n//   import * as React from \"react\";\n//   import PropTypes from \"prop-types\";\nconst transformImports = require(\"transform-imports\");\n\nmodule.exports = function (fileInfo, api, options) {\n  return transformImports(fileInfo.source, (importDefs) =\u003e {\n    importDefs.forEach((importDef) =\u003e {\n      if (importDef.source !== \"react\") {\n        return;\n      }\n\n      if (\n        importDef.importedExport.name === \"default\" \u0026\u0026\n        importDef.importedExport.isImportedAsCJS === false\n      ) {\n        importDef.fork({ insert: \"before\" });\n        importDef.importedExport.name = \"*\";\n      }\n\n      if (\n        importDef.variableName === \"PropTypes\" \u0026\u0026\n        importDef.importedExport.name === \"PropTypes\"\n      ) {\n        importDef.importedExport.name = \"default\";\n        importDef.source = \"prop-types\";\n      }\n    });\n  });\n};\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsuchipi%2Ftransform-imports","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsuchipi%2Ftransform-imports","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsuchipi%2Ftransform-imports/lists"}