Gathering detailed insights and metrics for @vlad-zhukov/babel-plugin-transform-react-remove-prop-types
Gathering detailed insights and metrics for @vlad-zhukov/babel-plugin-transform-react-remove-prop-types
npm install @vlad-zhukov/babel-plugin-transform-react-remove-prop-types
Typescript
Module System
Node Version
NPM Version
72.3
Supply Chain
98.4
Quality
75.1
Maintenance
100
Vulnerability
100
License
JavaScript (100%)
Total Downloads
752
Last Day
1
Last Week
2
Last Month
9
Last Year
64
895 Stars
254 Commits
61 Forks
15 Watching
4 Branches
27 Contributors
Minified
Minified + Gzipped
Latest Version
0.0.2
Package Id
@vlad-zhukov/babel-plugin-transform-react-remove-prop-types@0.0.2
Size
7.84 kB
NPM Version
5.4.2
Node Version
8.6.0
Cumulative downloads
Total Downloads
Last day
0%
1
Compared to previous day
Last week
0%
2
Compared to previous week
Last month
50%
9
Compared to previous month
Last year
-43.4%
64
Compared to previous year
23
Remove unnecessary React propTypes from the production build.
1npm install --save-dev babel-plugin-transform-react-remove-prop-types
Remove React propTypes
from the production build, as they are only used in development.
You can save bandwidth by removing them.
In
1const Baz = (props) => ( 2 <div {...props} /> 3); 4 5Baz.propTypes = { 6 className: PropTypes.string 7};
Out
1const Baz = (props) => ( 2 <div {...props} /> 3);
The majority of cases should be addressed by default by this plugin.
In some cases, for example when using HOCs (High Order Components), like react-redux's connect
, or component inheritance (although it's NOT recommended), a comment after the propTypes
definition may be used to force the removal:
1Component.propTypes /* remove-proptypes */ = {}
.babelrc
(Recommended).babelrc
without options:
1{ 2 "env": { 3 "production": { 4 "plugins": ["transform-react-remove-prop-types"] 5 } 6 } 7}
with options:
1{ 2 "env": { 3 "production": { 4 "plugins": [ 5 ["transform-react-remove-prop-types", { 6 "mode": "wrap", 7 "ignoreFilenames": ["node_modules"] 8 }] 9 ] 10 } 11 } 12}
1babel --plugins transform-react-remove-prop-types script.js
without options:
1require('babel-core').transform('code', { 2 plugins: [ 3 'transform-react-remove-prop-types', 4 ], 5});
with options:
1require('babel-core').transform('code', { 2 plugins: [ 3 [ 4 'transform-react-remove-prop-types', 5 { 6 mode: 'wrap', 7 ignoreFilenames: ['node_modules'], 8 }, 9 ], 10 ], 11});
mode
remove
(default):
the propTypes
definitions are removed from the source code.wrap
:
the propTypes
definitions are wrapped with the following code:1Component.propTypes = process.env.NODE_ENV !== "production" ? { 2 // ... 3} : {};
Accessing 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 breaks.
unsafe-wrap
:
the propTypes
definitions are wrapped with the following code:1if (process.env.NODE_ENV !== "production") { 2 Component.propTypes = { 3 // ... 4 } 5}
Accessing Component.propTypes.className
will throw.
The wrap modes are targeting React libraries like material-ui or react-native-web. They are not intended to be used by application authors.
removeImport
true
: the import statements are removed as well. This option only works if mode
is set to remove
:1import PropTypes from 'prop-types'
false
(default): does not remove the import statements.ignoreFilenames
This filter generates a regular expression. Any filenames containing one of the array's strings will be ignored. By default, we match everything.
Following the Is it safe? section, you might encounter a component
depending on the propTypes
at runtime to work.
For this reason, we provide an array options to filter out some files and folders.
For instance, you can ignore all the npm modules:
1ignoreFilenames: ['node_modules'],
additionalLibraries
This option gives the possibility to remove other propTypes
in addition to the canonical prop-types
.
For instance, by default
1import PropTypes from 'prop-types' 2import ImmutablePropTypes from 'react-immutable-proptypes'
will result in the latter not to be removed, while with:
1additionalLibraries: ['react-immutable-proptypes'],
both will be removed.
If you are using the propTypes
in a conventional way,
i.e by using them to perform type checking on the properties, that plugin should be safe to use.
However, some libraries are accessing the propTypes
on the component directly.
For instance react-native-vector-icons use them to split the properties between two components:
1const touchableProps = pick(restProps, Object.keys(TouchableHighlight.propTypes));
:warning: The plugin is breaking that code if it ends up removing TouchableHighlight.propTypes
.
Make sure you are:
propTypes
to work around that limitation.node_modules
.
If you do, test that your code is still working before shipping into production.eslint-plugin-react has a rule forbid-foreign-prop-types that can help you make this plugin safer to use.
MIT
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 12/28 approved changesets -- score normalized to 4
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
39 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-01-27
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More