Skip to content

Commit

Permalink
Merge pull request #1564 from silx-kit/lodash-es
Browse files Browse the repository at this point in the history
Switch to `lodash-es` for ESM and tree-shaking
  • Loading branch information
axelboc authored Feb 7, 2024
2 parents 2178872 + 51b0aa5 commit bb9c610
Show file tree
Hide file tree
Showing 32 changed files with 61 additions and 52 deletions.
4 changes: 2 additions & 2 deletions apps/storybook/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"@react-three/fiber": "8.15.12",
"d3-format": "3.1.0",
"greenlet": "1.1.0",
"lodash": "4.17.21",
"lodash-es": "4.17.21",
"ndarray": "1.0.19",
"normalize.css": "8.0.1",
"react": "18.2.0",
Expand All @@ -36,7 +36,7 @@
"@storybook/react": "7.6.4",
"@storybook/react-vite": "7.6.4",
"@types/d3-format": "~3.0.4",
"@types/lodash": "~4.14.202",
"@types/lodash-es": "~4.17.12",
"@types/ndarray": "1.0.14",
"@types/node": "^20.10.5",
"@types/react": "^18.2.45",
Expand Down
2 changes: 1 addition & 1 deletion apps/storybook/src/AxialSelectToZoom.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
Zoom,
} from '@h5web/lib';
import type { Meta, StoryObj } from '@storybook/react';
import { range } from 'lodash';
import { range } from 'lodash-es';

import FillHeight from './decorators/FillHeight';

Expand Down
2 changes: 1 addition & 1 deletion apps/storybook/src/DataCurve.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
} from '@h5web/lib';
import { assertDefined } from '@h5web/shared/guards';
import type { Meta, StoryObj } from '@storybook/react';
import { range } from 'lodash';
import { range } from 'lodash-es';
import { useState } from 'react';

import FillHeight from './decorators/FillHeight';
Expand Down
2 changes: 1 addition & 1 deletion apps/storybook/src/ErrorBars.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
import { assertDefined } from '@h5web/shared/guards';
import { ScaleType } from '@h5web/shared/vis-models';
import type { Meta, StoryObj } from '@storybook/react';
import { range } from 'lodash';
import { range } from 'lodash-es';

import FillHeight from './decorators/FillHeight';

Expand Down
2 changes: 1 addition & 1 deletion apps/storybook/src/Glyphs.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
import { assertDefined } from '@h5web/shared/guards';
import { ScaleType } from '@h5web/shared/vis-models';
import type { Meta, StoryObj } from '@storybook/react';
import { range } from 'lodash';
import { range } from 'lodash-es';

import FillHeight from './decorators/FillHeight';

Expand Down
2 changes: 1 addition & 1 deletion apps/storybook/src/HeatmapMesh.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { assertDefined } from '@h5web/shared/guards';
import { ScaleType } from '@h5web/shared/vis-models';
import { COLOR_SCALE_TYPES, toTypedNdArray } from '@h5web/shared/vis-utils';
import type { Meta, StoryObj } from '@storybook/react';
import { range } from 'lodash';
import { range } from 'lodash-es';
import ndarray from 'ndarray';
import { LinearFilter, NearestFilter } from 'three';

Expand Down
2 changes: 1 addition & 1 deletion apps/storybook/src/Line.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
import { assertDefined } from '@h5web/shared/guards';
import { ScaleType } from '@h5web/shared/vis-models';
import type { Meta, StoryObj } from '@storybook/react';
import { range } from 'lodash';
import { range } from 'lodash-es';

import FillHeight from './decorators/FillHeight';

Expand Down
2 changes: 1 addition & 1 deletion apps/storybook/src/TiledHeatmapMesh/checkerboard-api.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Size } from '@h5web/lib';
import { getLayerSizes, TilesApi } from '@h5web/lib';
import greenlet from 'greenlet';
import { clamp } from 'lodash';
import { clamp } from 'lodash-es';
import type { NdArray } from 'ndarray';
import ndarray from 'ndarray';
import { createFetchStore } from 'react-suspense-fetch';
Expand Down
2 changes: 1 addition & 1 deletion apps/storybook/src/TiledHeatmapMesh/mandlebrot-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { Size } from '@h5web/lib';
import { getLayerSizes, TilesApi } from '@h5web/lib';
import type { Domain } from '@h5web/shared/vis-models';
import greenlet from 'greenlet';
import { clamp } from 'lodash';
import { clamp } from 'lodash-es';
import type { NdArray } from 'ndarray';
import ndarray from 'ndarray';
import { createFetchStore } from 'react-suspense-fetch';
Expand Down
4 changes: 2 additions & 2 deletions packages/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"@react-three/fiber": "8.15.12",
"axios": "1.6.2",
"d3-format": "3.1.0",
"lodash": "4.17.21",
"lodash-es": "4.17.21",
"ndarray": "1.0.19",
"ndarray-ops": "1.2.2",
"react-error-boundary": "4.0.11",
Expand All @@ -73,7 +73,7 @@
"@testing-library/react": "14.1.2",
"@testing-library/user-event": "14.5.1",
"@types/d3-format": "~3.0.4",
"@types/lodash": "~4.14.202",
"@types/lodash-es": "~4.17.12",
"@types/ndarray": "1.0.14",
"@types/node": "^20.10.5",
"@types/react": "^18.2.45",
Expand Down
2 changes: 1 addition & 1 deletion packages/app/src/dimension-mapper/AxisMapper.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ToggleGroup } from '@h5web/lib';
import type { AxisMapping } from '@h5web/shared/nexus-models';
import type { Axis } from '@h5web/shared/vis-models';
import { isNumber } from 'lodash';
import { isNumber } from 'lodash-es';

import styles from './DimensionMapper.module.css';
import type { DimensionMapping } from './models';
Expand Down
2 changes: 1 addition & 1 deletion packages/app/src/dimension-mapper/DimensionMapper.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { AxisMapping } from '@h5web/shared/nexus-models';
import { isNumber } from 'lodash';
import { isNumber } from 'lodash-es';

import AxisMapper from './AxisMapper';
import styles from './DimensionMapper.module.css';
Expand Down
2 changes: 1 addition & 1 deletion packages/app/src/dimension-mapper/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Axis } from '@h5web/shared/vis-models';
import { isNumber } from 'lodash';
import { isNumber } from 'lodash-es';

export function isAxis(elem: number | Axis): elem is Axis {
return !isNumber(elem);
Expand Down
2 changes: 1 addition & 1 deletion packages/app/src/metadata-viewer/MetadataViewer.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { isAbsolutePath, isDataset } from '@h5web/shared/guards';
import { EntityKind } from '@h5web/shared/hdf5-models';
import { buildEntityPath } from '@h5web/shared/hdf5-utils';
import { capitalize } from 'lodash';
import { capitalize } from 'lodash-es';
import { memo, Suspense } from 'react';
import { ErrorBoundary } from 'react-error-boundary';

Expand Down
2 changes: 1 addition & 1 deletion packages/app/src/vis-packs/core/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import type {
Value,
} from '@h5web/shared/hdf5-models';
import type { NumArray } from '@h5web/shared/vis-models';
import { castArray } from 'lodash';
import { castArray } from 'lodash-es';
import type { NdArray, TypedArray } from 'ndarray';
import { useMemo } from 'react';

Expand Down
2 changes: 1 addition & 1 deletion packages/app/src/vis-packs/core/line/config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { isDefined } from '@h5web/shared/guards';
import type { AxisScaleType } from '@h5web/shared/vis-models';
import { ScaleType } from '@h5web/shared/vis-models';
import { useMap } from '@react-hookz/web';
import { omit } from 'lodash';
import { omit } from 'lodash-es';
import { createContext, useContext, useState } from 'react';
import type { StoreApi } from 'zustand';
import { createStore, useStore } from 'zustand';
Expand Down
2 changes: 1 addition & 1 deletion packages/app/src/vis-packs/core/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { ArrayValue, NumericLikeType } from '@h5web/shared/hdf5-models';
import { DTypeClass } from '@h5web/shared/hdf5-models';
import type { Axis, Domain, NumArray } from '@h5web/shared/vis-models';
import { createArrayFromView } from '@h5web/shared/vis-utils';
import { isNumber } from 'lodash';
import { isNumber } from 'lodash-es';
import type { NdArray, TypedArray } from 'ndarray';
import ndarray from 'ndarray';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
assertGroup,
assertNumDims,
} from '@h5web/shared/guards';
import { isEqual } from 'lodash';
import { isEqual } from 'lodash-es';

import { useScatterConfig } from '../../core/scatter/config';
import MappedScatterVis from '../../core/scatter/MappedScatterVis';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ScaleType } from '@h5web/lib';
import { assertGroup, isAxisScaleType } from '@h5web/shared/guards';
import { isEqual } from 'lodash';
import { isEqual } from 'lodash-es';

import DimensionMapper from '../../../dimension-mapper/DimensionMapper';
import { useDimMappingState } from '../../../dimension-mapper/hooks';
Expand Down
4 changes: 2 additions & 2 deletions packages/lib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
"d3-interpolate": "3.0.1",
"d3-scale": "4.0.2",
"d3-scale-chromatic": "3.0.0",
"lodash": "4.17.21",
"lodash-es": "4.17.21",
"ndarray": "1.0.19",
"ndarray-ops": "1.2.2",
"react-aria-menubutton": "7.0.3",
Expand All @@ -85,7 +85,7 @@
"@types/d3-interpolate": "~3.0.4",
"@types/d3-scale": "~4.0.8",
"@types/d3-scale-chromatic": "~3.0.3",
"@types/lodash": "~4.14.202",
"@types/lodash-es": "~4.17.12",
"@types/ndarray": "~1.0.14",
"@types/node": "^20.10.5",
"@types/react": "^18.2.45",
Expand Down
2 changes: 1 addition & 1 deletion packages/lib/src/interactions/hooks.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useEventListener, useSyncedRef, useToggle } from '@react-hookz/web';
import { useThree } from '@react-three/fiber';
import { castArray } from 'lodash';
import { castArray } from 'lodash-es';
import { useCallback, useEffect, useRef, useState } from 'react';
import { Vector3 } from 'three';

Expand Down
2 changes: 1 addition & 1 deletion packages/lib/src/interactions/interaction.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { castArray } from 'lodash';
import { castArray } from 'lodash-es';
import type { ModifierKey } from 'react';

import type { InteractionConfig } from './models';
Expand Down
2 changes: 1 addition & 1 deletion packages/lib/src/vis/heatmap/utils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Domain, NumArray } from '@h5web/shared/vis-models';
import { ScaleType } from '@h5web/shared/vis-models';
import { getDims, toTypedNdArray } from '@h5web/shared/vis-utils';
import { range } from 'lodash';
import { range } from 'lodash-es';
import type { NdArray } from 'ndarray';
import ndarray from 'ndarray';
import type { MagnificationTextureFilter } from 'three';
Expand Down
2 changes: 1 addition & 1 deletion packages/lib/src/vis/matrix/HeaderCells.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { range } from 'lodash';
import { range } from 'lodash-es';
import { useContext } from 'react';

import { SettingsContext } from './context';
Expand Down
2 changes: 1 addition & 1 deletion packages/lib/src/vis/scaleGamma.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import type {
ScalePower,
UnknownReturnType,
} from 'd3-scale';
import { isNumber } from 'lodash';
import { isNumber } from 'lodash-es';

import type { ScaleGammaConfig } from './models';

Expand Down
2 changes: 1 addition & 1 deletion packages/lib/src/vis/tiles/Tile.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { ThreeEvent } from '@react-three/fiber';
import { throttle } from 'lodash';
import { throttle } from 'lodash-es';
import { memo } from 'react';
import type { MagnificationTextureFilter } from 'three';
import { Vector2 } from 'three';
Expand Down
2 changes: 1 addition & 1 deletion packages/lib/src/vis/tiles/TiledHeatmapMesh.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { clamp, range } from 'lodash';
import { clamp, range } from 'lodash-es';
import { useRef } from 'react';
import type { Group } from 'three';

Expand Down
2 changes: 1 addition & 1 deletion packages/lib/src/vis/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
} from '@visx/scale';
import { range, tickStep } from 'd3-array';
import type { ScaleLinear, ScaleThreshold } from 'd3-scale';
import { clamp } from 'lodash';
import { clamp } from 'lodash-es';
import type { IUniform } from 'three';
import { BufferAttribute } from 'three';

Expand Down
6 changes: 3 additions & 3 deletions packages/shared/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,22 @@
},
"peerDependencies": {
"d3-format": "3.1.0",
"lodash": "4.17.21",
"lodash-es": "4.17.21",
"ndarray": "1.0.19",
"ndarray-ops": "1.2.2",
"react": ">=18"
},
"devDependencies": {
"@types/d3-format": "~3.0.4",
"@types/lodash": "~4.14.202",
"@types/lodash-es": "~4.17.12",
"@types/ndarray": "~1.0.14",
"@types/ndarray-ops": "~1.2.7",
"@types/node": "^20.10.5",
"@types/react": "^18.2.45",
"d3-format": "3.1.0",
"eslint": "8.56.0",
"eslint-config-galex": "4.5.2",
"lodash": "4.17.21",
"lodash-es": "4.17.21",
"ndarray": "1.0.19",
"ndarray-ops": "1.2.2",
"react": "18.2.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/src/guards.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isTypedArray as isTypedArrayLodash } from 'lodash';
import { isTypedArray as isTypedArrayLodash } from 'lodash-es';
import type { Data, NdArray, TypedArray } from 'ndarray';

import type {
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/src/mock-values.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { range } from 'lodash';
import { range } from 'lodash-es';
import type { NdArray } from 'ndarray';
import ndarray from 'ndarray';

Expand Down
Loading

0 comments on commit bb9c610

Please sign in to comment.