From cc0078f64355ed0982a7c8e24b6f8d0767249e8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=B9=A4=E4=BB=99?= Date: Mon, 18 Mar 2024 09:48:35 +0800 Subject: [PATCH 1/2] refactor: replace lodash/assignWith with vanilla js --- package.json | 2 +- pnpm-lock.yaml | 6 +++--- src/utils/with-default-props.tsx | 18 ++++++++---------- 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/package.json b/package.json index 9f74a19637..cb41ae4de3 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,6 @@ "classnames": "^2.3.2", "dayjs": "^1.11.7", "deepmerge": "^4.3.1", - "lodash": "^4.17.21", "nano-memoize": "^3.0.16", "rc-field-form": "~1.27.4", "rc-util": "^5.38.1", @@ -101,6 +100,7 @@ "jest-environment-jsdom": "^28.1.3", "jest-watch-typeahead": "^1.1.0", "less": "^4.1.3", + "lodash": "^4.17.21", "lorem-ipsum": "^2.0.8", "lz-string": "^1.5.0", "mockdate": "^3.0.5", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 561eb91dde..154b469014 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -39,9 +39,6 @@ dependencies: deepmerge: specifier: ^4.3.1 version: 4.3.1 - lodash: - specifier: ^4.17.21 - version: 4.17.21 nano-memoize: specifier: ^3.0.16 version: 3.0.16 @@ -254,6 +251,9 @@ devDependencies: less: specifier: ^4.1.3 version: 4.2.0 + lodash: + specifier: ^4.17.21 + version: 4.17.21 lorem-ipsum: specifier: ^2.0.8 version: 2.0.8 diff --git a/src/utils/with-default-props.tsx b/src/utils/with-default-props.tsx index 1780272000..3446d7dea6 100644 --- a/src/utils/with-default-props.tsx +++ b/src/utils/with-default-props.tsx @@ -1,15 +1,13 @@ -import assignWith from 'lodash/assignWith' - export function mergeProps(a: A, b: B): B & A export function mergeProps(a: A, b: B, c: C): C & B & A export function mergeProps(...items: any[]) { - function customizer(objValue: any, srcValue: any) { - return srcValue === undefined ? objValue : srcValue - } - - let ret = { ...items[0] } - for (let i = 1; i < items.length; i++) { - ret = assignWith(ret, items[i], customizer) - } + const ret: any = {} + items.forEach(item => { + Object.keys(item).forEach(key => { + if (item[key] !== undefined) { + ret[key] = item[key] + } + }) + }) return ret } From ba6540506bc393b66fb27b69205a82e8b1527e08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=B9=A4=E4=BB=99?= Date: Thu, 28 Mar 2024 10:05:45 +0800 Subject: [PATCH 2/2] fix: size limit --- .github/workflows/size-limit.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/size-limit.yml b/.github/workflows/size-limit.yml index 1ae1950fee..e0f4e15c83 100644 --- a/.github/workflows/size-limit.yml +++ b/.github/workflows/size-limit.yml @@ -5,12 +5,14 @@ on: types: [opened, synchronize] permissions: - contents: read + contents: write + pull-requests: write jobs: size: permissions: - contents: read + checks: read + contents: write pull-requests: write runs-on: ubuntu-latest