mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
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:
@@ -1,4 +1,3 @@
|
||||
import _ from 'lodash';
|
||||
import React, { Component } from 'react';
|
||||
|
||||
import { CloudWatchLogsQuery } from '../types';
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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 () => {
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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';
|
||||
|
||||
Reference in New Issue
Block a user