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

Remove unnecessary React propTypes from the production build. :balloon:
MIT License
897 stars 61 forks source link

Fix babel readonly #167

Closed eps1lon closed 5 years ago

eps1lon commented 5 years ago

Without the fix the new test case for *-wrap-es5 would transpile to

var variants = (babelHelpers.readOnlyError("variants"), process.env.NODE_ENV !== "production" ? [null] : {});;

Which throws at runtime. Overall problem is that the template returns an AssignmentExpression which is used in this code as a VariableDeclarator which confuses babel.

A clean fix would be to check if the scope of declarations is already wrapped but that is not trivial (as is wrapping/removing unused references anyway) and I wanted this fix to be as simple as possible to fix mui-org/material-ui#13245