From e09efdead14961d3cc9ec0c24a182f66241436de Mon Sep 17 00:00:00 2001 From: afc163 Date: Wed, 30 Aug 2023 18:05:20 +0800 Subject: [PATCH] perf: remove lodash/camelCase for smaller bundle size (#595) --- packages/icons-react/package.json | 1 - packages/icons-react/src/utils.ts | 5 ++++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/icons-react/package.json b/packages/icons-react/package.json index 8f84d7489..c46ef78c7 100644 --- a/packages/icons-react/package.json +++ b/packages/icons-react/package.json @@ -32,7 +32,6 @@ "@ant-design/icons-svg": "^4.3.0", "@babel/runtime": "^7.11.2", "classnames": "^2.2.6", - "lodash": "^4.17.21", "rc-util": "^5.31.1" }, "devDependencies": { diff --git a/packages/icons-react/src/utils.ts b/packages/icons-react/src/utils.ts index 113637680..b5e5716a7 100644 --- a/packages/icons-react/src/utils.ts +++ b/packages/icons-react/src/utils.ts @@ -1,12 +1,15 @@ import { generate as generateColor } from '@ant-design/colors'; import type { AbstractNode, IconDefinition } from '@ant-design/icons-svg/lib/types'; -import camelCase from 'lodash/camelCase'; import { updateCSS } from 'rc-util/lib/Dom/dynamicCSS'; import { getShadowRoot } from 'rc-util/lib/Dom/shadow'; import warn from 'rc-util/lib/warning'; import React, { useContext, useEffect } from 'react'; import IconContext from './components/Context'; +function camelCase(input: string) { + return input.replace(/-(.)/g, (match, g) => g.toUpperCase()); +} + export function warning(valid: boolean, message: string) { warn(valid, `[@ant-design/icons] ${message}`); }