From 5f07399f3befb4e8179129a31f6e201dfcc85ab5 Mon Sep 17 00:00:00 2001 From: Nathan Bierema Date: Tue, 13 Aug 2024 23:16:49 -0400 Subject: [PATCH] Remove lodash from redux-devtools --- packages/redux-devtools/package.json | 4 +--- packages/redux-devtools/src/persistState.ts | 18 +++++++++++------- pnpm-lock.yaml | 6 ------ 3 files changed, 12 insertions(+), 16 deletions(-) diff --git a/packages/redux-devtools/package.json b/packages/redux-devtools/package.json index 006c1d03..998e07c6 100644 --- a/packages/redux-devtools/package.json +++ b/packages/redux-devtools/package.json @@ -42,8 +42,7 @@ }, "dependencies": { "@babel/runtime": "^7.25.0", - "@redux-devtools/instrument": "^2.2.0", - "lodash-es": "^4.17.21" + "@redux-devtools/instrument": "^2.2.0" }, "devDependencies": { "@babel/cli": "^7.24.8", @@ -54,7 +53,6 @@ "@babel/preset-react": "^7.24.7", "@babel/preset-typescript": "^7.24.7", "@types/jest": "^29.5.12", - "@types/lodash-es": "^4.17.12", "@types/node": "^20.14.14", "@types/react": "^18.3.3", "jest": "^29.7.0", diff --git a/packages/redux-devtools/src/persistState.ts b/packages/redux-devtools/src/persistState.ts index 1624bc10..0a757498 100644 --- a/packages/redux-devtools/src/persistState.ts +++ b/packages/redux-devtools/src/persistState.ts @@ -1,11 +1,10 @@ -import { identity, mapValues } from 'lodash-es'; import { Action, Reducer, StoreEnhancer } from 'redux'; import { LiftedState } from '@redux-devtools/instrument'; export default function persistState, MonitorState>( sessionId?: string | null, - deserializeState: (state: S) => S = identity, - deserializeAction: (action: A) => A = identity, + deserializeState: (state: S) => S = (state) => state, + deserializeAction: (action: A) => A = (state) => state, ): StoreEnhancer { if (!sessionId) { return (next) => @@ -18,10 +17,15 @@ export default function persistState, MonitorState>( ): LiftedState { return { ...state, - actionsById: mapValues(state.actionsById, (liftedAction) => ({ - ...liftedAction, - action: deserializeAction(liftedAction.action), - })), + actionsById: Object.fromEntries( + Object.entries(state.actionsById).map(([actionId, liftedAction]) => [ + actionId, + { + ...liftedAction, + action: deserializeAction(liftedAction.action), + }, + ]), + ), committedState: deserializeState(state.committedState), computedStates: state.computedStates.map((computedState) => ({ ...computedState, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c3a91adc..cb41c761 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -617,9 +617,6 @@ importers: '@redux-devtools/instrument': specifier: ^2.2.0 version: link:../redux-devtools-instrument - lodash-es: - specifier: ^4.17.21 - version: 4.17.21 devDependencies: '@babel/cli': specifier: ^7.24.8 @@ -645,9 +642,6 @@ importers: '@types/jest': specifier: ^29.5.12 version: 29.5.12 - '@types/lodash-es': - specifier: ^4.17.12 - version: 4.17.12 '@types/node': specifier: ^20.14.14 version: 20.14.14