Comments (4)
@piuccio I think that it's out of the scope of this modules.
Besides, the displayName
are already removed by Uglify when using the ES6 class and the stateless functional component API.
Are you using the soon deprecated React.createClass
API?
from babel-plugin-transform-react-remove-prop-types.
I'm using stateless functions
export default commentCount;
function commentCount ({ count }) {
return (
<span>comments <span className="comment-count">({count})</span></span>
);
}
commentCount.displayName = 'CommentCount';
commentCount.propTypes = {
count: React.PropTypes.number
};
Which becomes
function commentCount(_ref) {
var count = _ref.count;
return React.createElement(
"span",
null,
"comments ",
React.createElement(
"span",
{ className: "comment-count" },
"(",
count,
")"
)
);
}
commentCount.displayName = 'CommentCount';
.displayName
isn't removed by uglify, and I don't see why it should.
I understand it's out of scope, but was hoping someone had a solution. A quick google search didn't give much.
from babel-plugin-transform-react-remove-prop-types.
I'm using stateless functions
Oh, why not using the following syntax?
const CommentCount = ({ count }) => (
<span>
comments <span className="comment-count">{count}</span>
</span>
);
CommentCount.propTypes = {
count: React.PropTypes.number
};
export default CommentCount;
You still get the name of the component in the dev tool and a small output.
After babel transpilation:
"use strict";
exports.__esModule = true;
var CommentCount = function CommentCount(_ref) {
var count = _ref.count;
return React.createElement(
"span",
null,
"comments ",
React.createElement(
"span",
{ className: "comment-count" },
count
)
);
};
CommentCount.propTypes = {
count: React.PropTypes.number
};
exports.default = CommentCount;
After Uglify minification:
"use strict"
exports.__esModule=!0
var CommentCount=function(e){var t=e.count
return React.createElement("span",null,"comments ",React.createElement("span",{className:"comment-count"},t))}
CommentCount.propTypes={count:React.PropTypes.number},exports["default"]=CommentCount
from babel-plugin-transform-react-remove-prop-types.
great, that worked! thanks
from babel-plugin-transform-react-remove-prop-types.
Related Issues (20)
- 0.4.16 bug: Cannot read property 'referencePaths' of undefined at VariableDeclarator, lib/index.js:292:56 HOT 6
- Cannot read property 'type' of undefined at memberExpressionRootIdentifier HOT 1
- react-portal remove prop-types HOT 2
- mode wrap broken in 0.4.20(#168) HOT 2
- Ability to remove `contextTypes` HOT 6
- "unsafe-wrap" mode crashes when a type is referenced from a variable
- Support createReactClass alternatives via config HOT 4
- Cannot get "name" of undefined
- Is it supports react-native? HOT 9
- Destructured PropTypes are not removed HOT 4
- Doesn't work with react-navigation library
- Issue when used with `createReactClass` HOT 1
- Option to include only certain files
- Support for configure wrap condition HOT 4
- Rename wrongly in switch/case statement
- Not working for SFC forwardRef() and createContext()
- Doesnโt remove propTypes in certain situations HOT 2
- Transform error with mode=wrap for TypeScript class component static propTypes type definition HOT 4
- How to use it with multiple environments in babel-env?
- swc support HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from babel-plugin-transform-react-remove-prop-types.