프로젝트
GitHub에서 보기
jamiebuilds/babel-react-optimize
소개
:rocket: React 코드를 최적화하는 Babel 프리셋 및 플러그인입니다.
웹 및 앱 개발측정된 스타 증가
- in 24h
- 0
- in 7 days
- 0
- in 15 days
- -1
- in 1 month
- -3
서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.
README.md
OriginalBabel React Optimize
A Babel preset and plugins for optimizing React code.
Optimizations
transform-react-constant-elements
Input:
class MyComponent extends React.Component {
render() {
return (
<div className={this.props.className}>
<span>Hello World</span>
</div>
);
}
}
Output:
var _ref = <span>Hello World</span>;
class MyComponent extends React.Component {
render() {
return (
<div className={this.props.className}>
{_ref}
</div>
);
}
}
transform-react-inline-elements
Input:
class MyComponent extends React.Component {
render() {
return (
<div className={this.props.className}>
<span>Hello World</span>
</div>
);
}
}
Output:
class MyComponent extends React.Component {
render() {
return (
_jsx('div', { className: this.props.className }, void 0,
_jsx('span', {}, void 0, 'Hello World')
)
);
}
}
Note: You should use this with
babel-runtimeandbabel-transform-runtimeto avoid duplicating the helper code in every file.
transform-react-remove-prop-types
Input:
class MyComponent extends React.Component {
static propTypes = {
className: React.PropTypes.string.isRequired
};
render() {
return (
<div className={this.props.className}>
<span>Hello World</span>
</div>
);
}
}
Output:
class MyComponent extends React.Component {
render() {
return (
<div className={this.props.className}>
<span>Hello World</span>
</div>
);
}
}
transform-react-pure-class-to-function
Input:
class MyComponent extends React.Component {
static propTypes = {
className: React.PropTypes.string.isRequired
};
render() {
return (
<div className={this.props.className}>
<span>Hello World</span>
</div>
);
}
}
Output:
function MyComponent(props) {
return (
<div className={props.className}>
<span>Hello World</span>
</div>
);
}
MyComponent.propTypes = {
className: React.PropTypes.string.isRequired
};
Install
$ npm install --save-dev babel-preset-react-optimize
Usage
.babelrc
{
"presets": ["es2015", "react"],
"env": {
"production": {
"presets": ["react-optimize"]
}
}
}
Benchmarks
We haven't yet much benchmark. But this post can give you an idea of what you can win in real life. Notice that the win depends a lot on how you are using the React API.
관련 프로젝트 살펴보기
불러오는 중…