Skip to content

Commit

Permalink
reduce bundle size related to lodash
Browse files Browse the repository at this point in the history
  • Loading branch information
christianvogt committed Jun 5, 2024
1 parent 7a5e952 commit 7d77cc3
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 13 deletions.
1 change: 1 addition & 0 deletions frontend/config/webpack.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ module.exports = (env) => {
extensions: ['.js', '.ts', '.tsx', '.jsx'],
alias: {
'~': path.resolve(SRC_DIR),
lodash: 'lodash-es',
},
symlinks: false,
cacheWithContext: false,
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/__mocks__/mockByon.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable camelcase */
import _ from 'lodash-es';
import * as _ from 'lodash-es';

import { RecursivePartial } from '~/typeHelpers';
import { BYONImage } from '~/types';
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/__mocks__/mockImageStreamK8sResource.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import _ from 'lodash-es';
import * as _ from 'lodash-es';
import { ImageStreamKind } from '~/k8sTypes';
import { RecursivePartial } from '~/typeHelpers';

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/__mocks__/mockNotebookK8sResource.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import _ from 'lodash-es';
import * as _ from 'lodash-es';
import { KnownLabels, NotebookKind } from '~/k8sTypes';
import { DEFAULT_NOTEBOOK_SIZES } from '~/pages/projects/screens/spawner/const';
import { ContainerResources, TolerationEffect, TolerationOperator } from '~/types';
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/__tests__/cypress/cypress/utils/k8s.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
type K8sResourceCommon,
type QueryParams,
} from '@openshift/dynamic-plugin-sdk-utils';
import { isEmpty } from 'lodash-es';
import * as _ from 'lodash-es';

export type QueryOptions = {
ns?: string;
Expand Down Expand Up @@ -85,7 +85,7 @@ const getK8sResourceURL = (

const filteredQueryParams = queryParams;

if (filteredQueryParams && !isEmpty(filteredQueryParams)) {
if (filteredQueryParams && !_.isEmpty(filteredQueryParams)) {
resourcePath += `?${getQueryString(filteredQueryParams)}`;
}

Expand Down
6 changes: 3 additions & 3 deletions frontend/src/components/table/useCheckboxTableBase.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { intersection, xor } from 'lodash-es';
import * as _ from 'lodash-es';
import type Table from './Table';

export type UseCheckboxTableBaseProps<DataType> = {
Expand Down Expand Up @@ -33,7 +33,7 @@ const useCheckboxTableBase = <T>(
return;
}

const newSelectedIds = intersection(selectedDataIds, dataIds);
const newSelectedIds = _.intersection(selectedDataIds, dataIds);
const newSelectedData = newSelectedIds
.map((id) => data.find((d) => dataMappingHelper(d) === id))
.filter((v): v is T => !!v);
Expand Down Expand Up @@ -71,7 +71,7 @@ const useCheckboxTableBase = <T>(

const headerSelected =
selectedDataIds.length > 0 &&
xor(selectedDataIds, checkable.map(dataMappingHelper)).length === 0;
_.xor(selectedDataIds, checkable.map(dataMappingHelper)).length === 0;

const allDisabled = selectedData.length === 0 && disabledData.length === data.length;

Expand Down
4 changes: 2 additions & 2 deletions frontend/src/redux/selectors/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isEqual } from 'lodash-es';
import * as _ from 'lodash-es';

export const isStateEqual = <T>(stateBefore: T, stateAfter: T): boolean =>
isEqual(stateBefore, stateAfter);
_.isEqual(stateBefore, stateAfter);
2 changes: 1 addition & 1 deletion frontend/src/utilities/tolerations.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Patch } from '@openshift/dynamic-plugin-sdk-utils';
import _ from 'lodash-es';
import * as _ from 'lodash-es';
import { Toleration, TolerationEffect, TolerationOperator, TolerationSettings } from '~/types';
import { DashboardConfigKind, NotebookKind } from '~/k8sTypes';
import { AcceleratorProfileState } from './useAcceleratorProfileState';
Expand Down
4 changes: 2 additions & 2 deletions frontend/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"rootDir": ".",
"outDir": "public",
"module": "esnext",
"target": "es5",
"lib": ["es6", "dom", "ES2023.Array"],
"target": "es2016",
"lib": ["dom", "ES2023.Array"],
"sourceMap": true,
"jsx": "react",
"moduleResolution": "node",
Expand Down

0 comments on commit 7d77cc3

Please sign in to comment.