{"id":22084921,"url":"https://github.com/abskrj/babel-plugin-function-injection","last_synced_at":"2025-03-23T21:44:02.800Z","repository":{"id":143845734,"uuid":"414890052","full_name":"abskrj/babel-plugin-function-injection","owner":"abskrj","description":null,"archived":false,"fork":false,"pushed_at":"2021-10-08T13:00:50.000Z","size":35,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-10T15:11:56.649Z","etag":null,"topics":["babel","hacktoberfest","hacktoberfest-accepted","hacktoberfest2021","js","plugin"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/babel-plugin-function-injection","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/abskrj.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}},"created_at":"2021-10-08T07:32:55.000Z","updated_at":"2022-02-25T05:13:04.000Z","dependencies_parsed_at":"2023-07-25T21:18:31.325Z","dependency_job_id":null,"html_url":"https://github.com/abskrj/babel-plugin-function-injection","commit_stats":null,"previous_names":["abskrj/babel-plugin-function-injection","abhishekraj272/babel-plugin-function-injection"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abskrj%2Fbabel-plugin-function-injection","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abskrj%2Fbabel-plugin-function-injection/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abskrj%2Fbabel-plugin-function-injection/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abskrj%2Fbabel-plugin-function-injection/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/abskrj","download_url":"https://codeload.github.com/abskrj/babel-plugin-function-injection/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245175356,"owners_count":20572781,"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","hacktoberfest","hacktoberfest-accepted","hacktoberfest2021","js","plugin"],"created_at":"2024-12-01T01:08:39.092Z","updated_at":"2025-03-23T21:44:02.780Z","avatar_url":"https://github.com/abskrj.png","language":"JavaScript","readme":"\u003ch1 align=\"center\"\u003ebabel-plugin-function-injection 👋\u003c/h1\u003e\n\u003cp\u003e\n  \u003ca href=\"https://www.npmjs.com/package/babel-plugin-function-injection\" target=\"_blank\"\u003e\n    \u003cimg alt=\"Version\" src=\"https://img.shields.io/npm/v/babel-plugin-function-injection.svg\"\u003e\n  \u003c/a\u003e\n  \u003cimg src=\"https://img.shields.io/badge/npm-%3E%3D1.0.0-blue.svg\" /\u003e\n  \u003cimg src=\"https://img.shields.io/badge/node-%3E%3D1.0.0-blue.svg\" /\u003e\n  \u003ca href=\"https://github.com/abhishekraj272/babel-plugin-function-injection#readme\" target=\"_blank\"\u003e\n    \u003cimg alt=\"Documentation\" src=\"https://img.shields.io/badge/documentation-yes-brightgreen.svg\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/abhishekraj272/babel-plugin-function-injection/graphs/commit-activity\" target=\"_blank\"\u003e\n    \u003cimg alt=\"Maintenance\" src=\"https://img.shields.io/badge/Maintained%3F-yes-green.svg\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/abhishekraj272/babel-plugin-function-injection/blob/master/LICENSE\" target=\"_blank\"\u003e\n    \u003cimg alt=\"License: MIT\" src=\"https://img.shields.io/github/license/abhishekraj272/babel-plugin-function-injection\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://twitter.com/abhishekraj272\" target=\"_blank\"\u003e\n    \u003cimg alt=\"Twitter: abhishekraj272\" src=\"https://img.shields.io/twitter/follow/abhishekraj272.svg?style=social\" /\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n\u003e A Babel plugin to inject and wrap a function on an exported object\n\n### 🏠 [Homepage](https://github.com/abhishekraj272/babel-plugin-function-injection#readme)\n\n## Prerequisites\n\n- npm \u003e=1.0.0\n- node \u003e=1.0.0\n\n## Install\n\n```sh\nyarn add -D babel-plugin-function-injection\n\n--OR--\n\nnpm i -D babel-plugin-function-injection\n```\n\n## Usage\n\nYou need to pass 2 keys to the plugin options.\n\n```js\n{\n  imports: IImport[],\n  target: RegEx // Files need to be injected\n}\n\ninterface IImport {\n  name: string;\n  lib: string;\n  defaultImport: boolean;\n}\n```\n\n## Example  \n\n```js\n// Plugin\n\nmodule.exports = function (api) {\n  api.cache(true);\n\n  const plugins = [\n    [\n      \"babel-plugin-function-injection\", \n      {\n        imports: [\n          {\n            name: \"connect\",\n            lib: \"react-redux\",\n            defaultImport: false,\n          },\n          {\n            name: \"mapStateToProps\",\n            lib: \"@utils/stateToProps\",\n            defaultImport: true,\n          },\n        ],\n        target: /(.*components.*index.[js|mjs|jsx|ts|tsx]*)/,\n      },\n    ],\n  ];\n\n  return {\n    plugins,\n  };\n};\n\n// Result\n\n// File: components/index.js\n\n// Input --\u003e to plugin\n\nexport { default } from './Navbar';\n\n----\n\nexport default Navbar;\n\n// Output \u003c-- from plugin\nimport { connect } from \"react-redux\";\nimport mapStateToProps from \"@utils/stateToProps\";\n\n\nexport const Something = connect(mapStateToProps)(Component);\n\n----\n\nexport default connect(mapStateToProps)(Navbar);\n```\n\n## 🤝 Contributing\n\nContributions, issues and feature requests are welcome!\u003cbr /\u003eFeel free to check [issues page](https://github.com/abhishekraj272/babel-plugin-function-injection/issues). You can also take a look at the [contributing guide]( ).\n\n## Show your support\n\nGive a ⭐️ if this project helped you!\n\n## 📝 License\n\nCopyright © 2021 [Abhishek Raj](https://github.com/abhishekraj272).\u003cbr /\u003e\nThis project is [MIT](https://github.com/abhishekraj272/babel-plugin-function-injection/blob/master/LICENSE) licensed.\n\n***\n_This README was generated with ❤️ by [readme-md-generator](https://github.com/kefranabg/readme-md-generator)_","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabskrj%2Fbabel-plugin-function-injection","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fabskrj%2Fbabel-plugin-function-injection","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabskrj%2Fbabel-plugin-function-injection/lists"}