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.19 to 0.4.20

28

lib/index.js

@@ -97,3 +97,3 @@ "use strict";

if (!memberExpression) {
if (!memberExpression || memberExpression.type !== 'MemberExpression') {
// This case is currently unhandled by this plugin.

@@ -164,5 +164,25 @@ return null;

}),
wrapTemplate: template("\n LEFT = process.env.NODE_ENV !== \"production\" ? RIGHT : {}\n ", {
placeholderPattern: /^(LEFT|RIGHT)$/
}),
wrapTemplate: function wrapTemplate(_ref) {
var LEFT = _ref.LEFT,
RIGHT = _ref.RIGHT;
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var _options$as = options.as,
as = _options$as === void 0 ? 'assignmentExpression' : _options$as;
var right = template.expression("\n process.env.NODE_ENV !== \"production\" ? RIGHT : {}\n ", {
placeholderPattern: /^(LEFT|RIGHT)$/
})({
RIGHT: RIGHT
});
switch (as) {
case 'variableDeclarator':
return types.variableDeclarator(LEFT, right);
case 'assignmentExpression':
return types.assignmentExpression('=', LEFT, right);
default:
throw new Error("unrecognized template type ".concat(as));
}
},
mode: state.opts.mode || 'remove',

@@ -169,0 +189,0 @@ ignoreFilenames: ignoreFilenames,

@@ -112,2 +112,4 @@ "use strict";

RIGHT: path.node.init
}, {
as: 'variableDeclarator'
}));

@@ -114,0 +116,0 @@ }

2

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

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

@@ -81,3 +81,3 @@ /* eslint-disable global-require, import/no-dynamic-require */

if (!memberExpression) {
if (!memberExpression || memberExpression.type !== 'MemberExpression') {
// This case is currently unhandled by this plugin.

@@ -156,8 +156,19 @@ return null

),
wrapTemplate: template(
`
LEFT = process.env.NODE_ENV !== "production" ? RIGHT : {}
`,
{ placeholderPattern: /^(LEFT|RIGHT)$/ }
),
wrapTemplate: ({ LEFT, RIGHT }, options = {}) => {
const { as = 'assignmentExpression' } = options
const right = template.expression(
`
process.env.NODE_ENV !== "production" ? RIGHT : {}
`,
{ placeholderPattern: /^(LEFT|RIGHT)$/ }
)({ RIGHT })
switch (as) {
case 'variableDeclarator':
return types.variableDeclarator(LEFT, right)
case 'assignmentExpression':
return types.assignmentExpression('=', LEFT, right)
default:
throw new Error(`unrecognized template type ${as}`)
}
},
mode: state.opts.mode || 'remove',

@@ -164,0 +175,0 @@ ignoreFilenames,

@@ -116,6 +116,9 @@ /* eslint-disable no-param-reassign */

path.replaceWith(
wrapTemplate({
LEFT: path.node.id,
RIGHT: path.node.init,
})
wrapTemplate(
{
LEFT: path.node.id,
RIGHT: path.node.init,
},
{ as: 'variableDeclarator' }
)
)

@@ -122,0 +125,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