{"id":13422573,"url":"https://github.com/oliviertassinari/babel-plugin-transform-react-remove-prop-types","last_synced_at":"2025-10-20T06:24:05.951Z","repository":{"id":45913283,"uuid":"48693660","full_name":"oliviertassinari/babel-plugin-transform-react-remove-prop-types","owner":"oliviertassinari","description":"Remove unnecessary React propTypes from the production build. :balloon:","archived":false,"fork":false,"pushed_at":"2021-11-28T23:45:33.000Z","size":571,"stargazers_count":890,"open_issues_count":17,"forks_count":46,"subscribers_count":13,"default_branch":"master","last_synced_at":"2025-10-14T20:23:41.179Z","etag":null,"topics":["babel","babel-plugin","minification","proptypes","react"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/oliviertassinari.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2015-12-28T13:23:33.000Z","updated_at":"2025-10-13T02:36:53.000Z","dependencies_parsed_at":"2022-09-10T18:22:36.216Z","dependency_job_id":null,"html_url":"https://github.com/oliviertassinari/babel-plugin-transform-react-remove-prop-types","commit_stats":null,"previous_names":[],"tags_count":42,"template":false,"template_full_name":null,"purl":"pkg:github/oliviertassinari/babel-plugin-transform-react-remove-prop-types","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oliviertassinari%2Fbabel-plugin-transform-react-remove-prop-types","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oliviertassinari%2Fbabel-plugin-transform-react-remove-prop-types/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oliviertassinari%2Fbabel-plugin-transform-react-remove-prop-types/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oliviertassinari%2Fbabel-plugin-transform-react-remove-prop-types/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oliviertassinari","download_url":"https://codeload.github.com/oliviertassinari/babel-plugin-transform-react-remove-prop-types/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oliviertassinari%2Fbabel-plugin-transform-react-remove-prop-types/sbom","scorecard":{"id":705430,"data":{"date":"2025-08-11","repo":{"name":"github.com/oliviertassinari/babel-plugin-transform-react-remove-prop-types","commit":"25bffc28f8a842ae0a27aba0c2228bf9599caedc"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.6,"checks":[{"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":"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":"Code-Review","score":4,"reason":"Found 12/28 approved changesets -- score normalized to 4","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":"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":"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":"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":"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":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"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":"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":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"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 17 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":0,"reason":"42 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-968p-4wvh-cqc8","Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92","Warn: Project is vulnerable to: GHSA-6chw-6frg-f759","Warn: Project is vulnerable to: GHSA-v88g-cgmw-v5xw","Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-w8qv-6jwh-64r5","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c","Warn: Project is vulnerable to: GHSA-w573-4hg7-7wgq","Warn: Project is vulnerable to: GHSA-h6ch-v84p-w6p9","Warn: Project is vulnerable to: GHSA-8r6j-v8pm-fqw3","Warn: Project is vulnerable to: MAL-2023-462","Warn: Project is vulnerable to: GHSA-4q6p-r6v2-jvc5","Warn: Project is vulnerable to: GHSA-43f8-2h32-f4cj","Warn: Project is vulnerable to: GHSA-qqgx-2p2h-9c37","Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h","Warn: Project is vulnerable to: GHSA-6c8f-qphg-qjgp","Warn: Project is vulnerable to: GHSA-4xc9-xhrj-v574","Warn: Project is vulnerable to: GHSA-x5rq-j2xg-h7qm","Warn: Project is vulnerable to: GHSA-jf85-cpcp-j695","Warn: Project is vulnerable to: GHSA-p6mc-m468-83gw","Warn: Project is vulnerable to: GHSA-29mw-wpgm-hmr9","Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm","Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv","Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3","Warn: Project is vulnerable to: GHSA-vh95-rmgr-6w4m","Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h","Warn: Project is vulnerable to: GHSA-fhjf-83wg-r2j9","Warn: Project is vulnerable to: GHSA-hj48-42vr-x3v9","Warn: Project is vulnerable to: GHSA-g6ww-v8xp-vmwg","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw","Warn: Project is vulnerable to: GHSA-4g88-fppr-53pp","Warn: Project is vulnerable to: GHSA-4jqc-8m5r-9rpr","Warn: Project is vulnerable to: GHSA-3jfq-g458-7qm9","Warn: Project is vulnerable to: GHSA-r628-mhmh-qjhw","Warn: Project is vulnerable to: GHSA-9r2w-394v-53qc","Warn: Project is vulnerable to: GHSA-5955-9wpr-37jh","Warn: Project is vulnerable to: GHSA-qq89-hq3f-393p","Warn: Project is vulnerable to: GHSA-f5x3-32g6-xq36","Warn: Project is vulnerable to: GHSA-52f5-9888-hmc6"],"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-22T06:25:00.163Z","repository_id":45913283,"created_at":"2025-08-22T06:25:00.163Z","updated_at":"2025-08-22T06:25:00.163Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279120216,"owners_count":26108263,"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-10-15T02:00:07.814Z","response_time":56,"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":["babel","babel-plugin","minification","proptypes","react"],"created_at":"2024-07-30T23:00:48.098Z","updated_at":"2025-10-20T06:24:05.924Z","avatar_url":"https://github.com/oliviertassinari.png","language":"JavaScript","readme":"# babel-plugin-transform-react-remove-prop-types\n\n\u003e Remove unnecessary React propTypes from the production build.\n\n[![npm version](https://img.shields.io/npm/v/babel-plugin-transform-react-remove-prop-types.svg)](https://www.npmjs.com/package/babel-plugin-transform-react-remove-prop-types)\n[![npm downloads](https://img.shields.io/npm/dm/babel-plugin-transform-react-remove-prop-types.svg)](https://www.npmjs.com/package/babel-plugin-transform-react-remove-prop-types)\n[![Build Status](https://travis-ci.org/oliviertassinari/babel-plugin-transform-react-remove-prop-types.svg?branch=master)](https://travis-ci.org/oliviertassinari/babel-plugin-transform-react-remove-prop-types)\n\n[![Dependencies](https://img.shields.io/david/oliviertassinari/babel-plugin-transform-react-remove-prop-types.svg)](https://david-dm.org/oliviertassinari/babel-plugin-transform-react-remove-prop-types)\n[![DevDependencies](https://img.shields.io/david/dev/oliviertassinari/babel-plugin-transform-react-remove-prop-types.svg)](https://david-dm.org/oliviertassinari/babel-plugin-transform-react-remove-prop-types?type=dev)\n\n## Installation\n\n```sh\nnpm install --save-dev babel-plugin-transform-react-remove-prop-types\n```\n\n## The problem solved\n\nRemove React `propTypes` from the production build, as they are only used in development.\nYou can **save bandwidth** by removing them.\n\n## Example\n\n**In**\n```jsx\nconst Baz = (props) =\u003e (\n  \u003cdiv {...props} /\u003e\n);\n\nBaz.propTypes = {\n  className: PropTypes.string\n};\n```\n\n**Out**\n```jsx\nconst Baz = (props) =\u003e (\n  \u003cdiv {...props} /\u003e\n);\n```\n\n### With comment annotation\n\nThe majority of cases should be addressed by default by this plugin.\n\nIn some cases, for example when using HOCs (High Order Components), like *react-redux*'s `connect`, or component inheritance ([although it's NOT recommended](https://facebook.github.io/react/docs/composition-vs-inheritance.html)), a comment after the `propTypes` definition may be used to force the removal:\n\n```js\nComponent.propTypes /* remove-proptypes */ = {}\n```\n\n## Usage\n\n### Via `.babelrc` (Recommended)\n\n**.babelrc**\n\nwithout options:\n```json\n{\n  \"env\": {\n    \"production\": {\n      \"plugins\": [\"transform-react-remove-prop-types\"]\n    }\n  }\n}\n```\n\nwith options:\n```json\n{\n  \"env\": {\n    \"production\": {\n      \"plugins\": [\n        [\"transform-react-remove-prop-types\", {\n          \"mode\": \"wrap\",\n          \"ignoreFilenames\": [\"node_modules\"]\n        }]\n      ]\n    }\n  }\n}\n```\n\n### Via CLI\n\n```sh\nbabel --plugins transform-react-remove-prop-types script.js\n```\n\n### Via Node API\n\nwithout options:\n```js\nrequire('babel-core').transform('code', {\n  plugins: [\n    'transform-react-remove-prop-types',\n  ],\n});\n```\n\nwith options:\n```js\nrequire('babel-core').transform('code', {\n  plugins: [\n    [\n      'transform-react-remove-prop-types',\n      {\n        mode: 'wrap',\n        ignoreFilenames: ['node_modules'],\n      },\n    ],\n  ],\n});\n```\n\n## Options\n\n### `mode`\n\n - `remove` (default):\nthe `propTypes` definitions are removed from the source code.\n - `wrap`:\nthe `propTypes` definitions are wrapped with the following code:\n```js\nComponent.propTypes = process.env.NODE_ENV !== \"production\" ? {\n  // ...\n} : {};\n```\nAccessing `Component.propTypes.className` won't throw. It's a tradeoff between the size of the output file and the likelihood libraries like [react-native-hyperlink](https://github.com/obipawan/react-native-hyperlink/pull/11) breaks.\n - `unsafe-wrap`:\nthe `propTypes` definitions are wrapped with the following code:\n```js\nif (process.env.NODE_ENV !== \"production\") {\n  Component.propTypes = {\n    // ...\n  }\n}\n```\nAccessing `Component.propTypes.className` will throw.\n\nThe *wrap* modes are targeting React libraries like [material-ui](https://github.com/callemall/material-ui) or [react-native-web](https://github.com/necolas/react-native-web).\nThey are not intended to be used by application authors.\n\n### `removeImport`\n\n - `true`: the import statements are removed as well. This option only works if `mode` is set to `remove`:\n```js\nimport PropTypes from 'prop-types'\n```\n - `false` (default): does not remove the import statements.\n\n### `ignoreFilenames`\n\nThis filter generates a regular expression.\nAny filenames containing one of the array's strings will be ignored.\nBy **default**, we match everything.\n\nFollowing the [Is it safe?](#user-content-is-it-safe) section, you might encounter a component\ndepending on the `propTypes` at runtime to work.\nFor this reason, we provide an array options to filter out some files and folders.\nFor instance, you can ignore all the npm modules:\n```js\nignoreFilenames: ['node_modules'],\n```\n\n### `additionalLibraries`\n\nThis option gives the possibility to remove other `propTypes` in addition to the canonical `prop-types`.\n\nFor instance, by default\n```js\nimport PropTypes from 'prop-types'\nimport ImmutablePropTypes from 'react-immutable-proptypes'\n```\nwill result in the latter not to be removed, while with:\n```js\nadditionalLibraries: ['react-immutable-proptypes'],\n```\nboth will be removed.\n\n#### Regular expressions\n\nIf you are using Babel 7 or newer and your config is stored in [`babel.config.js`](https://babeljs.io/docs/en/configuration#babelconfigjs), you can also use a regular expression to describe modules, which should be removed.\n\nThis would be particularly useful when using custom prop types validators, implemented as part of your own source code. For example\n\n```js\nimport CustomPropTypes from '../../prop-types/my-own-validator'\nimport OtherCustomPropTypes from '../../prop-types/my-other-validator'\n```\n\nwould be removed with the following setting\n\n```js\nadditionalLibraries: [/\\/prop-types\\/.*$/]\n```\n\nIf you use an index file\n\n```js\nimport CustomPropTypes from '../../prop-types'\n```\n\nyou could set it up as\n\n```js\nadditionalLibraries: [/\\/prop-types$/]\n```\n\n### `classNameMatchers`\n\nUse this option to enable this plugin to run on components that extend a class different than `React.Component` or `React.PureComponent`.\n\nGiven this example:\n```js\nclass MyComponent extends BaseComponent {\n  ...\n}\n```\n\nYou would use:\n```js\nclassNameMatchers: [\"BaseComponent\"]\n```\n\n### `createReactClassName`\n\nUse this option to set a custom name for the import of the `create-react-class` package that is different than `createReactClass`.\n\nGiven this example:\n\n```js\nimport createClass from 'create-react-class';\n```\n\nYou would use:\n\n```js\ncreateReactClassName: 'createClass'\n```\n\n## Is it safe?\n\nIf you are using the `propTypes` in a conventional way,\ni.e by using them to perform type checking on the properties, that plugin should be **safe to use**.\n\nHowever, some libraries are accessing the `propTypes` on the component directly.\nFor instance [react-native-vector-icons](https://github.com/oblador/react-native-vector-icons/blob/3d1f2a5b7175d6e4c8985676940240776543ff60/lib/icon-button.js#L59) use them to split the properties between two components:\n```js\nconst touchableProps = pick(restProps, Object.keys(TouchableHighlight.propTypes));\n```\n:warning: The plugin is breaking that code if it ends up removing `TouchableHighlight.propTypes`.\n\nMake sure you are:\n- Not using that pattern in your source code.\nIf you do, explicitly **export** the `propTypes` to work around that limitation.\n- Not parsing the `node_modules`.\nIf you do, test that your code is still working before shipping into production.\n\n[eslint-plugin-react has a rule forbid-foreign-prop-types](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/forbid-foreign-prop-types.md) that can help you make this plugin safer to use.\n\n## License\n\nMIT\n","funding_links":[],"categories":["Performance","Uncategorized","JavaScript","babel","Plugins"],"sub_categories":["App Size","Uncategorized","非 JavaScript 编译工具","React"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foliviertassinari%2Fbabel-plugin-transform-react-remove-prop-types","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foliviertassinari%2Fbabel-plugin-transform-react-remove-prop-types","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foliviertassinari%2Fbabel-plugin-transform-react-remove-prop-types/lists"}