babel-plugin-transform-react-remove-prop-types
babel-plugin-transform-react-remove-prop-types copied to clipboard
mode wrap broken in 0.4.20(#168)
We end up with
template.expression is not a function
at wrapTemplate (/*/node_modules/babel-plugin-transform-react-remove-prop-types
From here https://github.com/oliviertassinari/babel-plugin-transform-react-remove-prop-types/pull/168/files#diff-1fdf421c05c1140f6d71444ea2b27638R157
When we are using mode: wrap
for our code-base
Installing 0.4.19
works as a workaround
/cc @oliviertassinari
@PeoB I have upgraded the dependency to v0.4.20 in https://github.com/mui-org/material-ui/pull/13540 without any issue. Do you have a reproduction example?
Sorry, company firewall is preventing me from pushing the example right now. But essentially:
example.jsx
import React from "react";
import PropTypes from "prop-types";
export const FooBar = ({hello}) => (
<h1>{hello}</h1>
);
FooBar.propTypes = {
hello: PropTypes.string
};
.babelrc
{
"presets": [
"react"
],
"plugins": [
["transform-react-remove-prop-types", {
"mode": "wrap"
}]
]
}
package.json
{
"name": "babel-remove-prop-types-error",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"babel-plugin-transform-react-remove-prop-types": "^0.4.20",
"babel-preset-react": "^6.24.1",
"prop-types": "^15.6.2",
"react": "^16.6.1"
},
"devDependencies": {
"babel-cli": "^6.26.0"
}
}
babel example.jsx
babel example.jsx
TypeError: example.jsx: template.expression is not a function
at wrapTemplate (/projects/temp/babel-fail/node_modules/babel-plugin-transform-react-remove-prop-types/lib/index.js:169:34)
at remove (/projects/temp/babel-fail/node_modules/babel-plugin-transform-react-remove-prop-types/lib/remove.js:94:28)
at AssignmentExpression (/projects/temp/babel-fail/node_modules/babel-plugin-transform-react-remove-prop-types/lib/index.js:298:35)
at NodePath._call (/projects/temp/babel-fail/node_modules/babel-traverse/lib/path/context.js:76:18)
at NodePath.call (/projects/temp/babel-fail/node_modules/babel-traverse/lib/path/context.js:48:17)
at NodePath.visit (/projects/temp/babel-fail/node_modules/babel-traverse/lib/path/context.js:105:12)
at TraversalContext.visitQueue (/projects/temp/babel-fail/node_modules/babel-traverse/lib/context.js:150:16)
at TraversalContext.visitSingle (/projects/temp/babel-fail/node_modules/babel-traverse/lib/context.js:108:19)
at TraversalContext.visit (/projects/temp/babel-fail/node_modules/babel-traverse/lib/context.js:192:19)
at Function.traverse.node (/projects/temp/babel-fail/node_modules/babel-traverse/lib/index.js:114:17)