Performance: Standardize lodash imports to use destructured members (#33040)

* Performance: Standardize lodash imports to use destructured members
Changes lodash imports of the form `import x from 'lodash/x'` to
`import { x } from 'lodash'` to reduce bundle size.

* Remove unnecessary _ import from Graph component

* Enforce lodash import style

* Fix remaining lodash imports
This commit is contained in:
kay delaney
2021-04-21 08:38:00 +01:00
committed by GitHub
parent 2bb7eb18d1
commit bad048b7ba
299 changed files with 1135 additions and 1137 deletions

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
import _range from 'lodash/range';
import { range as _range } from 'lodash';
import renderIntoCanvas, {
BG_COLOR,

View File

@ -13,9 +13,7 @@
// limitations under the License.
import * as React from 'react';
import _get from 'lodash/get';
import _maxBy from 'lodash/maxBy';
import _values from 'lodash/values';
import { get as _get, maxBy as _maxBy, values as _values } from 'lodash';
import MdKeyboardArrowRight from 'react-icons/lib/md/keyboard-arrow-right';
import { css } from '@emotion/css';
import cx from 'classnames';

View File

@ -14,7 +14,7 @@
import cx from 'classnames';
import { css } from '@emotion/css';
import _groupBy from 'lodash/groupBy';
import { groupBy as _groupBy } from 'lodash';
import React from 'react';
import { compose, onlyUpdateForKeys, withProps, withState } from 'recompose';
import { autoColor, createStyle, Theme } from '../Theme';

View File

@ -13,7 +13,7 @@
// limitations under the License.
import * as React from 'react';
import _sortBy from 'lodash/sortBy';
import { sortBy as _sortBy } from 'lodash';
import IoIosArrowDown from 'react-icons/lib/io/ios-arrow-down';
import IoIosArrowRight from 'react-icons/lib/io/ios-arrow-right';
import { css } from '@emotion/css';

View File

@ -13,7 +13,7 @@
// limitations under the License.
import React from 'react';
import _get from 'lodash/get';
import { get as _get } from 'lodash';
import IoChevronRight from 'react-icons/lib/io/chevron-right';
import IoIosArrowDown from 'react-icons/lib/io/ios-arrow-down';
import { css } from '@emotion/css';

View File

@ -14,12 +14,15 @@
import * as React from 'react';
import { shallow } from 'enzyme';
import debounceMock from 'lodash/debounce';
// eslint-disable-next-line lodash/import-scope
import _ from 'lodash';
import UiFindInput from './UiFindInput';
import { UIInput } from '../uiElementsContext';
jest.mock('lodash/debounce');
const debounceMock = jest.spyOn(_, 'debounce').mockImplementation((func) => {
return Object.assign(func, { cancel: jest.fn(), flush: jest.fn() });
});
describe('UiFindInput', () => {
const flushMock = jest.fn();

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
import _uniq from 'lodash/uniq';
import { uniq as _uniq } from 'lodash';
import memoize from 'lru-memoize';
import { getConfigValue } from '../utils/config/get-config';
import { getParent } from './span';

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
import _isEqual from 'lodash/isEqual';
import { isEqual as _isEqual } from 'lodash';
// @ts-ignore
import { getTraceSpanIdsAsTree } from '../selectors/trace';

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
import _values from 'lodash/values';
import { values as _values } from 'lodash';
import { followsFromRef } from './trace.fixture';
import {

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
import _get from 'lodash/get';
import { get as _get } from 'lodash';
import EUpdateTypes from './EUpdateTypes';
import { DraggableBounds, DraggingUpdate } from './types';

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
import _get from 'lodash/get';
import { get as _get } from 'lodash';
import defaultConfig from '../../constants/default-config';

View File

@ -13,7 +13,7 @@
// limitations under the License.
import moment from 'moment-timezone';
import _round from 'lodash/round';
import { round as _round } from 'lodash';
import { toFloatPrecision } from './number';

View File

@ -12,8 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
import _find from 'lodash/find';
import _get from 'lodash/get';
import { find as _find, get as _get } from 'lodash';
import { TNil } from '../types';
import { TraceSpan } from '../types/trace';