Open nijk opened 6 years ago
@nijk Thanks for the reproduction. It sounds like a bug.
Typescript output is also not processed. It contains propTypes inside of class iife but this plugins handles only top level propTypes assignments.
I'm experiencing same thing. At first I thought the plugin was not removing any propTypes but after reading this issue and looking into the build I noticed it was only the functional component's propTypes not being removed i.e. plugin removed propTypes from class components only.
I'm closing, the react popper issue is too high level. It doesn't mean it's an issue with this Babel plugin. Library authors should use the wrap mode. They should have the prop types in the modules they publish to npm. For a UMD release, this depends on the dev vs prod target.
@oliviertassinari Thanks, I've spent a few minutes generating a minimal reproduction of the issue here.
I may well be doing something wrong but here's what I found:
remove
mode (default) the propTypes were not removed from either SFC or the ClassComponent.wrap
mode, the propTypes are wrapped with process.env
- this is a problem for 3rd party React libs that can't really expect process.env
to be available in the consuming app.
- When using the remove mode (default) the propTypes were not removed from either SFC or the ClassComponent.
We should fix that: https://github.com/nijk/babel-plugin-transform-react-remove-prop-types-issue-140.
- When using the wrap mode, the propTypes are wrapped with process.env - this is a problem for 3rd party React libs that can't really expect process.env to be available in the consuming app.
This is a no problem: https://unpkg.com/react.
@oliviertassinari is that not the development version of React? The production version doesn't attempt to access process.env
.
Sorry, ignore that - I've just re-read the file you linked to
I'm aware that issues have been raised for this previously and work done to fix it.
However I'm seeing issues with a library (ReactPopper) that uses this plugin. The library currently uses this plugin but with
{ mode: 'wrap' }
which results in minified builds that referenceprocess.env
- which is not something we want, react-popper GH Issue here. I've forked the library and made the config change tobabel-plugin-transform-react-remove-prop-types
here but I'm seeing thatpropTypes
still exist on the stateless functional components:Steps to reproduce
git clone https://github.com/nijk/react-popper.git
git checkout v0.x
cd react-popper
npm install
grep propType dist/react-popper.min.js
propTypes
exists in thegrep
output, namely on theTarget
&Arrow
components - both of which are stateless functional components.