Skip to content

Remove lodash dependency #742

@acasazza

Description

@acasazza

🎯 Summary

Remove lodash and @types/lodash packages from the project and replace all usages with native JavaScript/TypeScript equivalents.

💡 Motivation

  • 📦 Lodash adds unnecessary bundle weight; modern JS/TS covers most of its utilities natively.
  • 🔒 Reduces the dependency surface and simplifies maintenance.
  • 🌲 Improves tree-shaking and overall bundle size.

📂 Affected files

🗂️ Dependencies (packages/react-components/package.json)

  • lodash ^4.17.21
  • @types/lodash ^4.17.21

📄 Source files using lodash

⚙️ Reducers

  • src/reducers/AddressReducer.ts
  • src/reducers/PlaceOrderReducer.ts
  • src/reducers/GiftCardReducer.ts
  • src/reducers/OrderReducer.ts

🧩 Components

  • src/components/payment_gateways/StripeGateway.tsx
  • src/components/payment_gateways/ExternalGateway.tsx
  • src/components/payment_gateways/CheckoutComGateway.tsx
  • src/components/payment_gateways/KlarnaGateway.tsx
  • src/components/payment_gateways/BraintreeGateway.tsx
  • src/components/payment_gateways/AdyenGateway.tsx
  • src/components/payment_gateways/PaypalGateway.tsx
  • src/components/payment_gateways/WireTransferGateway.tsx
  • src/components/payment_source/PaymentSourceBrandName.tsx
  • src/components/payment_source/PaypalPayment.tsx
  • src/components/payment_source/BraintreePayment.tsx
  • src/components/gift_cards/GiftCard.tsx
  • src/components/line_items/LineItemOption.tsx
  • src/components/utils/BaseOrderPrice.tsx
  • src/components/shipping_methods/ShippingMethod.tsx
  • src/components/SubmitButton.tsx
  • src/components/orders/PlaceOrderButton.tsx
  • src/components/orders/OrderListRow.tsx
  • src/components/addresses/SaveAddressesButton.tsx
  • src/components/addresses/Address.tsx
  • src/components/addresses/AddressStateSelector.tsx
  • src/components/shipments/ShipmentField.tsx
  • src/components/shipments/ShipmentsContainer.tsx
  • src/components/customers/SaveCustomerButton.tsx

🛠️ Utils

  • src/utils/countryStateCity.ts
  • src/utils/promisify.ts
  • src/utils/addressesManager.ts
  • src/utils/getErrors.ts
  • src/utils/shipments.ts
  • src/utils/validateFormFields.ts
  • src/utils/getAmount.ts
  • src/utils/getPrices.tsx

✅ Acceptance criteria

  • All import ... from "lodash" (or lodash/*) statements are removed.
  • Replaced with native equivalents (e.g. Object.assign, Array.prototype methods, optional chaining, nullish coalescing, etc.).
  • lodash and @types/lodash removed from package.json.
  • All existing tests still pass.

🔗 References

Metadata

Metadata

Assignees

Labels

componentsComponents packagedependenciesPull requests that update a dependency fileenhancementNew feature or requestjavascriptPull requests that update javascript coderefactor

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions