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

@@ -1,4 +1,3 @@
import _ from 'lodash';
import React, { Component } from 'react';
import { CloudWatchLogsQuery } from '../types';

View File

@@ -1,5 +1,5 @@
import React, { FunctionComponent, Fragment, useState, useEffect } from 'react';
import isEqual from 'lodash/isEqual';
import { isEqual } from 'lodash';
import { SelectableValue } from '@grafana/data';
import { SegmentAsync, Icon } from '@grafana/ui';
import { SelectableStrings } from '../types';

View File

@@ -4,11 +4,10 @@ import { CloudWatchLogsQueryField } from './LogsQueryField';
import { ExploreId } from '../../../../types';
import { DescribeLogGroupsRequest } from '../types';
import { SelectableValue } from '@grafana/data';
// eslint-disable-next-line lodash/import-scope
import _, { Cancelable } from 'lodash';
jest.mock('lodash/debounce', () => {
const fakeDebounce = (func: () => any, period: number) => func;
return fakeDebounce;
});
jest.spyOn(_, 'debounce').mockImplementation((func: ((...args: any) => any) & Cancelable, wait: number) => func);
describe('CloudWatchLogsQueryField', () => {
it('updates upstream query log groups on region change', async () => {

View File

@@ -1,8 +1,6 @@
// Libraries
import React, { ReactNode } from 'react';
import intersectionBy from 'lodash/intersectionBy';
import debounce from 'lodash/debounce';
import unionBy from 'lodash/unionBy';
import { intersectionBy, debounce, unionBy } from 'lodash';
import {
BracesPlugin,

View File

@@ -1,5 +1,5 @@
import React, { PureComponent, ChangeEvent } from 'react';
import isEmpty from 'lodash/isEmpty';
import { isEmpty } from 'lodash';
import { ExploreQueryFieldProps } from '@grafana/data';
import { LegacyForms, ValidationEvents, EventsWithValidation, Icon } from '@grafana/ui';

View File

@@ -1,5 +1,5 @@
import React, { PureComponent } from 'react';
import pick from 'lodash/pick';
import { pick } from 'lodash';
import { ExploreQueryFieldProps, ExploreMode } from '@grafana/data';
import { Segment } from '@grafana/ui';
import { CloudWatchJsonData, CloudWatchQuery } from '../types';