Skip to content

Commit a79d87b

Browse files
committed
fix: improve bundle size
lodash should not be imported globally
1 parent 4951131 commit a79d87b

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

src/webui/src/components/PackageSidebar/modules/Dependencies/index.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22
import PropTypes from 'prop-types';
3-
import _ from 'lodash';
3+
import get from 'lodash/size';
44
import Module from '../../Module';
55

66
import classes from './style.scss';
@@ -13,7 +13,7 @@ export default class Dependencies extends React.Component {
1313
};
1414

1515
get dependencies() {
16-
return _.get(this, 'props.packageMeta.latest.dependencies', {});
16+
return get(this, 'props.packageMeta.latest.dependencies', {});
1717
}
1818

1919
render() {

src/webui/src/components/PackageSidebar/modules/Maintainers/index.jsx

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import React from 'react';
22
import PropTypes from 'prop-types';
3-
import _ from 'lodash';
3+
import get from 'lodash/get';
4+
import filter from 'lodash/filter';
5+
import size from 'lodash/size';
6+
import uniqBy from 'lodash/uniqBy';
47
import Module from '../../Module';
58

69
import classes from './style.scss';
@@ -19,27 +22,27 @@ export default class Maintainers extends React.Component {
1922
}
2023

2124
get author() {
22-
return _.get(this, 'props.packageMeta.latest.author');
25+
return get(this, 'props.packageMeta.latest.author');
2326
}
2427

2528
get contributors() {
26-
let contributors = _.get(this, 'props.packageMeta.latest.contributors', {});
27-
return _.filter(contributors, (contributor) => {
29+
let contributors = get(this, 'props.packageMeta.latest.contributors', {});
30+
return filter(contributors, (contributor) => {
2831
return (
29-
contributor.name !== _.get(this, 'author.name') &&
30-
contributor.email !== _.get(this, 'author.email')
32+
contributor.name !== get(this, 'author.name') &&
33+
contributor.email !== get(this, 'author.email')
3134
);
3235
});
3336
}
3437

3538
get showAllContributors() {
36-
return this.state.showAllContributors || _.size(this.contributors) <= 5;
39+
return this.state.showAllContributors || size(this.contributors) <= 5;
3740
}
3841

3942
get uniqueContributors() {
4043
if (!this.contributors) return [];
4144

42-
return _.uniqBy(this.contributors, (contributor) => contributor.name).slice(0, 5);
45+
return uniqBy(this.contributors, (contributor) => contributor.name).slice(0, 5);
4346
}
4447

4548
handleShowAllContributors() {

0 commit comments

Comments
 (0)