babel-plugin-transform-react-remove-prop-types
Advanced tools
Comparing version 0.4.19 to 0.4.20
@@ -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 @@ } |
{ | ||
"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 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
47031
1028