From cd0e67f087e06aec88782675c293efb659f476d0 Mon Sep 17 00:00:00 2001 From: Koza Date: Wed, 14 Dec 2022 16:14:20 +0100 Subject: [PATCH] Reduce the size impact of lodash by picking the required modules only --- src/I18n.ts | 4 +++- src/Locales.ts | 2 +- src/helpers/camelCaseKeys.ts | 2 +- src/helpers/formatNumber.ts | 2 +- src/helpers/lookup.ts | 2 +- src/helpers/numberToHuman.ts | 3 ++- src/helpers/propertyFlatList.ts | 5 ++++- src/helpers/timeAgoInWords.ts | 2 +- 8 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/I18n.ts b/src/I18n.ts index 9cdda23..3229d35 100644 --- a/src/I18n.ts +++ b/src/I18n.ts @@ -1,6 +1,8 @@ /* eslint-disable class-methods-use-this, no-underscore-dangle */ -import { get, has, set } from "lodash"; +import get from "lodash/get"; +import has from "lodash/has"; +import set from "lodash/set"; import { DateTime, diff --git a/src/Locales.ts b/src/Locales.ts index 958c916..82e5107 100644 --- a/src/Locales.ts +++ b/src/Locales.ts @@ -1,4 +1,4 @@ -import { uniq } from "lodash"; +import uniq from "lodash/uniq"; import { Dict, LocaleResolver } from "./typing"; import { I18n } from "./I18n"; diff --git a/src/helpers/camelCaseKeys.ts b/src/helpers/camelCaseKeys.ts index c9e3d05..f35d7ee 100644 --- a/src/helpers/camelCaseKeys.ts +++ b/src/helpers/camelCaseKeys.ts @@ -1,4 +1,4 @@ -import { camelCase } from "lodash"; +import camelCase from "lodash/camelCase"; import { Dict } from "../typing"; diff --git a/src/helpers/formatNumber.ts b/src/helpers/formatNumber.ts index 68b7ac0..edab74c 100644 --- a/src/helpers/formatNumber.ts +++ b/src/helpers/formatNumber.ts @@ -1,5 +1,5 @@ import BigNumber from "bignumber.js"; -import { repeat } from "lodash"; +import repeat from "lodash/repeat"; import { FormatNumberOptions, Numeric } from "../typing"; import { roundNumber } from "./roundNumber"; diff --git a/src/helpers/lookup.ts b/src/helpers/lookup.ts index dc8b87f..595d17c 100644 --- a/src/helpers/lookup.ts +++ b/src/helpers/lookup.ts @@ -1,4 +1,4 @@ -import { get } from "lodash"; +import get from "lodash/get"; import { Dict, Scope } from "../typing"; import { I18n } from "../I18n"; diff --git a/src/helpers/numberToHuman.ts b/src/helpers/numberToHuman.ts index 59a53a6..327c173 100644 --- a/src/helpers/numberToHuman.ts +++ b/src/helpers/numberToHuman.ts @@ -1,5 +1,6 @@ import BigNumber from "bignumber.js"; -import { sortBy, zipObject } from "lodash"; +import sortBy from "lodash/sortBy"; +import zipObject from "lodash/zipObject"; import { I18n } from "../I18n"; import { Numeric, NumberToHumanOptions, NumberToHumanUnits } from "../typing"; diff --git a/src/helpers/propertyFlatList.ts b/src/helpers/propertyFlatList.ts index 9a9c51d..5ebc9e2 100644 --- a/src/helpers/propertyFlatList.ts +++ b/src/helpers/propertyFlatList.ts @@ -1,4 +1,7 @@ -import { isArray, isObject, flattenDeep } from "lodash"; +import isArray from "lodash/isArray"; +import isObject from "lodash/isObject"; +import flattenDeep from "lodash/flattenDeep"; + import { Dict } from "../typing"; interface Indexable { diff --git a/src/helpers/timeAgoInWords.ts b/src/helpers/timeAgoInWords.ts index 69a83ea..f7e5d0c 100644 --- a/src/helpers/timeAgoInWords.ts +++ b/src/helpers/timeAgoInWords.ts @@ -1,4 +1,4 @@ -import { range } from "lodash"; +import range from "lodash/range"; import { I18n } from "../I18n"; import { DateTime, TimeAgoInWordsOptions } from "../typing";