Skip to content

Commit

Permalink
build(deps): use lodash-es reduce package size
Browse files Browse the repository at this point in the history
  • Loading branch information
kangfenmao committed Nov 29, 2023
1 parent 597cf3c commit 9d5ff1f
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 8 deletions.
5 changes: 4 additions & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,24 @@
"build:go": "tsc && BUILD_GO=true vite build",
"prebuild:go": "rm -rf ../backend/web/assets && rm -rf ../backend/web/public",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"preview": "vite preview"
"preview": "vite preview",
"bundle": "npx vite-bundle-visualizer"
},
"dependencies": {
"@uiw/react-md-editor": "^4.0.0",
"axios": "^1.6.2",
"dayjs": "^1.11.10",
"eventemitter3": "^5.0.1",
"lodash": "^4.17.21",
"lodash-es": "^4.17.21",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router-dom": "^6.19.0",
"swr": "^2.2.4"
},
"devDependencies": {
"@types/lodash": "^4.14.202",
"@types/lodash-es": "^4.17.12",
"@types/node": "^20.9.0",
"@types/react": "^18.2.15",
"@types/react-dom": "^18.2.7",
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/TopView.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useCallback, useEffect, useState } from 'react'
import { findIndex, pullAt } from 'lodash'
import { findIndex, pullAt } from 'lodash-es'
import EventEmitter from 'eventemitter3'

const DeviceEventEmitter = new EventEmitter()
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/screens/NotesScreen/GroupedNotes.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react'
import _ from 'lodash'
import { groupBy, sortBy } from 'lodash-es'
import { NoteType } from '@/types'
import { displayName } from '@/utils'
import { Link } from 'react-router-dom'
Expand All @@ -10,9 +10,9 @@ interface Props {
}

const GroupedNotes: React.FC<Props> = ({ data }) => {
const sortedNotes = _.sortBy(data, 'name')
const sortedNotes = sortBy(data, 'name')

const groupedData = _.groupBy(sortedNotes, item => {
const groupedData = groupBy(sortedNotes, item => {
const firstChar = item.name[0]
// eslint-disable-next-line no-control-regex
return /[^\u0000-\u00FF]/.test(firstChar) ? '#' : firstChar.toUpperCase()
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/screens/NotesScreen/NotesScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import useRequest from '@/hooks/useRequest.ts'
import useDebouncedValue from '@/hooks/useDebouncedValue.ts'
import LoadingView from '@/components/LoadingView.tsx'
import GroupedNotes from '@/screens/NotesScreen/GroupedNotes.tsx'
import { isEmpty } from 'lodash'
import { isEmpty } from 'lodash-es'

let cachedNotes: NoteType[] = []

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/screens/SearchScreen/SearchScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import './index.css'
import LoadingView from '@/components/LoadingView.tsx'
import useDebouncedValue from '@/hooks/useDebouncedValue.ts'
import EmptyView from '@/components/EmptyView.tsx'
import { isEmpty } from 'lodash'
import { isEmpty } from 'lodash-es'
import dayjs from 'dayjs'

interface SearchResponse {
Expand Down
14 changes: 13 additions & 1 deletion frontend/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,14 @@
resolved "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz"
integrity sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==

"@types/lodash@^4.14.202":
"@types/lodash-es@^4.17.12":
version "4.17.12"
resolved "https://registry.yarnpkg.com/@types/lodash-es/-/lodash-es-4.17.12.tgz#65f6d1e5f80539aa7cfbfc962de5def0cf4f341b"
integrity sha512-0NgftHUcV4v34VhXm8QBSftKVXtbkBG3ViCjs6+eJ5a6y6Mi/jiFGPc1sC7QK+9BFhWrURE3EOggmWaSxL9OzQ==
dependencies:
"@types/lodash" "*"

"@types/lodash@*", "@types/lodash@^4.14.202":
version "4.14.202"
resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.202.tgz#f09dbd2fb082d507178b2f2a5c7e74bd72ff98f8"
integrity sha512-OvlIYQK9tNneDlS0VN54LLd5uiPCBOp7gS5Z0f1mjoJYBrtStzgmJBxONW3U6OZqdtNzZPmn9BS/7WI7BFFcFQ==
Expand Down Expand Up @@ -1875,6 +1882,11 @@ locate-path@^6.0.0:
dependencies:
p-locate "^5.0.0"

lodash-es@^4.17.21:
version "4.17.21"
resolved "https://registry.yarnpkg.com/lodash-es/-/lodash-es-4.17.21.tgz#43e626c46e6591b7750beb2b50117390c609e3ee"
integrity sha512-mKnC+QJ9pWVzv+C4/U3rRsHapFfHvQFoFB92e52xeyGMcX6/OlIl78je1u8vePzYZSkkogMPJ2yjxxsb89cxyw==

lodash.merge@^4.6.2:
version "4.6.2"
resolved "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz"
Expand Down

0 comments on commit 9d5ff1f

Please sign in to comment.