Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

babel-plugin-transform-react-remove-prop-types

Package Overview
Dependencies
Maintainers
1
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-transform-react-remove-prop-types - npm Package Compare versions

Comparing version 0.4.0 to 0.4.1

32

lib/index.js

@@ -27,3 +27,4 @@ 'use strict';

ignoreFilenames: ignoreFilenames,
types: types
types: types,
removeImport: state.opts.removeImport || false
};

@@ -104,2 +105,31 @@

});
if (globalOptions.removeImport && globalOptions.mode === 'remove') {
programPath.scope.crawl();
programPath.traverse({
ImportDeclaration: function ImportDeclaration(path) {
var _path$node = path.node,
source = _path$node.source,
specifiers = _path$node.specifiers;
if (source.value !== 'prop-types') {
return;
}
var haveUsedSpecifiers = specifiers.some(function (specifier) {
var importedIdentifierName = specifier.local.name;
var _path$scope$getBindin = path.scope.getBinding(importedIdentifierName),
referencePaths = _path$scope$getBindin.referencePaths;
return referencePaths.length > 0;
});
if (!haveUsedSpecifiers) {
path.remove();
}
path.stop();
}
});
}
}

@@ -106,0 +136,0 @@ }

2

package.json
{
"name": "babel-plugin-transform-react-remove-prop-types",
"version": "0.4.0",
"version": "0.4.1",
"description": "Remove unnecessary React propTypes from the production build",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -20,3 +20,2 @@ # babel-plugin-transform-react-remove-prop-types

Remove React `propTypes` from the production build, as they are only used in development.

@@ -113,2 +112,3 @@ You can **save bandwidth** by removing them.

### `mode`
- `remove` (default):

@@ -127,3 +127,10 @@ the `propTypes` definitions are removed from the source code.

### `removeImport`
- `true`: the import statements are removed as well. This option only works if `mode` is set to `remove`:
```js
import PropTypes from 'prop-types'
```
- `false` (default): does not remove the import statements.
### `ignoreFilenames`

@@ -133,3 +140,3 @@

Any filenames containing one of the array's strings will be ignored.
By default, we match everything.
By **default**, we match everything.

@@ -144,3 +151,2 @@ Following the [Is it safe?](#user-content-is-it-safe) section, you might encounter a component

## Is it safe?

@@ -147,0 +153,0 @@

@@ -69,2 +69,3 @@ // @flow weak

types,
removeImport: state.opts.removeImport || false,
};

@@ -147,2 +148,25 @@

});
if (globalOptions.removeImport && globalOptions.mode === 'remove') {
programPath.scope.crawl();
programPath.traverse({
ImportDeclaration(path) {
const { source, specifiers } = path.node;
if (source.value !== 'prop-types') {
return;
}
const haveUsedSpecifiers = specifiers.some((specifier) => {
const importedIdentifierName = specifier.local.name;
const { referencePaths } = path.scope.getBinding(importedIdentifierName);
return referencePaths.length > 0;
});
if (!haveUsedSpecifiers) {
path.remove();
}
path.stop();
},
});
}
},

@@ -149,0 +173,0 @@ },

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc