1
0
mirror of https://github.com/verdaccio/verdaccio.git synced 2025-02-21 07:29:37 +01:00

fix: improve bundle size

lodash should not be imported globally
This commit is contained in:
Juan Picado @jotadeveloper 2018-06-03 17:33:09 +02:00
parent 4951131ec2
commit a79d87bd7f
No known key found for this signature in database
GPG Key ID: 18AC54485952D158
2 changed files with 13 additions and 10 deletions

@ -1,6 +1,6 @@
import React from 'react';
import PropTypes from 'prop-types';
import _ from 'lodash';
import get from 'lodash/size';
import Module from '../../Module';
import classes from './style.scss';
@ -13,7 +13,7 @@ export default class Dependencies extends React.Component {
};
get dependencies() {
return _.get(this, 'props.packageMeta.latest.dependencies', {});
return get(this, 'props.packageMeta.latest.dependencies', {});
}
render() {

@ -1,6 +1,9 @@
import React from 'react';
import PropTypes from 'prop-types';
import _ from 'lodash';
import get from 'lodash/get';
import filter from 'lodash/filter';
import size from 'lodash/size';
import uniqBy from 'lodash/uniqBy';
import Module from '../../Module';
import classes from './style.scss';
@ -19,27 +22,27 @@ export default class Maintainers extends React.Component {
}
get author() {
return _.get(this, 'props.packageMeta.latest.author');
return get(this, 'props.packageMeta.latest.author');
}
get contributors() {
let contributors = _.get(this, 'props.packageMeta.latest.contributors', {});
return _.filter(contributors, (contributor) => {
let contributors = get(this, 'props.packageMeta.latest.contributors', {});
return filter(contributors, (contributor) => {
return (
contributor.name !== _.get(this, 'author.name') &&
contributor.email !== _.get(this, 'author.email')
contributor.name !== get(this, 'author.name') &&
contributor.email !== get(this, 'author.email')
);
});
}
get showAllContributors() {
return this.state.showAllContributors || _.size(this.contributors) <= 5;
return this.state.showAllContributors || size(this.contributors) <= 5;
}
get uniqueContributors() {
if (!this.contributors) return [];
return _.uniqBy(this.contributors, (contributor) => contributor.name).slice(0, 5);
return uniqBy(this.contributors, (contributor) => contributor.name).slice(0, 5);
}
handleShowAllContributors() {