Skip to content

Commit 291acd2

Browse files
authored
perf: 🧰 lodash bundle size optimization #137 [ dev ]
perf: 🧰 lodash bundle size optimization.
2 parents 0d82c83 + f30a50b commit 291acd2

File tree

9 files changed

+87
-70
lines changed

9 files changed

+87
-70
lines changed

packages/hooks/docs/.vitepress/theme/home/HomeTeam.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script setup lang="ts">
2-
import { contributors, coreTeamMembers } from '../../../contributors'
2+
import { coreTeamMembers } from '../../../contributors'
33
import TeamMember from './TeamMember.vue'
44
</script>
55

@@ -23,6 +23,8 @@
2323
2424
h2 {
2525
text-align: center;
26+
font-weight: 600;
27+
transform: scale(0.6);
2628
color: var(--vp-font-color);
2729
}
2830

packages/hooks/docs/.vitepress/theme/home/TeamMember.vue

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,16 @@
2525
:alt="`${data.name}'s avatar`"
2626
/>
2727
<div class="name">
28-
{{ data.name }}
28+
<a v-if="data.github" :href="`https://github.com/${data.github}`" target="_blank">{{
29+
data.name
30+
}}</a>
31+
<div v-else>{{ data.name }}</div>
2932
</div>
3033
<div class="description" v-html="data.description" />
3134

3235
<div flex="~ inline gap-2" py2 text-2xl>
3336
<a
37+
v-if="data.github"
3438
class="i-carbon-logo-github inline-block text-current op30 hover:op100 mya transition duration-200"
3539
:href="`https://github.com/${data.github}`"
3640
target="_blank"
@@ -70,7 +74,7 @@
7074
<div class="code">
7175
<img class="icon" :src="funcIcon" alt="" />
7276
<div class="code-container">
73-
<a v-for="f of data.functions" :key="f" :href="`/${f}`" target="_blank">
77+
<a v-for="f of data.functions" :key="f" :href="`/${f}/`" target="_blank">
7478
<code>{{ f }}</code>
7579
</a>
7680
</div>
@@ -101,10 +105,14 @@
101105
min-width: 4.75rem;
102106
border-radius: 4.75rem;
103107
}
108+
.name {
109+
cursor: pointer;
110+
}
104111
.name,
105112
.description {
106113
margin-top: 16px;
107114
zoom: 0.85;
115+
height: 60px;
108116
}
109117
.description {
110118
color: var(--vp-font-color);

packages/hooks/docs/contributors.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,22 @@ const coreTeamMembers: CoreTeam[] = [
3333
github: 'NelsonYong',
3434
twitter: 'Yong_Git',
3535
sponsors: true,
36-
description: 'vue-hooks-plus 作者',
36+
description: "VueHooks Plus's Author",
3737
packages: ['vue-hooks-plus'],
3838
},
3939
{
4040
avatar: contributorsAvatars.hongaah,
4141
name: 'Hongaah',
4242
github: 'hongaah',
43-
description: '技术达人',
44-
functions: ['useFetch'],
43+
description: '',
44+
functions: ['useSetState', 'useWebSocket'],
45+
},
46+
{
47+
avatar: contributorsAvatars.Noobbbbbbb,
48+
name: 'Noobbbbbbb',
49+
github: 'Noobbbbbbb',
50+
description: '',
51+
functions: ['useFullscreen'],
4552
},
4653
]
4754
// .sort(

packages/hooks/src/useAsyncOrder/demo/demo.vue

Lines changed: 56 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -8,66 +8,66 @@
88
</template>
99

1010
<script lang="ts" setup>
11-
import { ref } from 'vue'
12-
import { useAsyncOrder } from 'vue-hooks-plus'
11+
import { ref } from 'vue'
12+
import { useAsyncOrder } from 'vue-hooks-plus'
1313
14-
const error = ref<number>(0)
15-
const list = ref<string[]>([])
14+
const error = ref<number>(0)
15+
const list = ref<string[]>([])
1616
17-
function getUsername(): Promise<string> {
18-
return new Promise((resolve, reject) => {
19-
setTimeout(() => {
20-
resolve('No.1')
21-
}, 3000)
22-
})
23-
}
17+
function getUsername(): Promise<string> {
18+
return new Promise((resolve, reject) => {
19+
setTimeout(() => {
20+
resolve('No.1')
21+
}, 3000)
22+
})
23+
}
2424
25-
function getUsername2(): Promise<string> {
26-
return new Promise((resolve, reject) => {
27-
setTimeout(() => {
28-
resolve('No.2')
29-
}, 2000)
30-
})
31-
}
25+
function getUsername2(): Promise<string> {
26+
return new Promise((resolve, reject) => {
27+
setTimeout(() => {
28+
resolve('No.2')
29+
}, 2000)
30+
})
31+
}
3232
33-
function getUsername3(): Promise<string> {
34-
return new Promise((resolve, reject) => {
35-
setTimeout(() => {
36-
resolve('No.3')
37-
}, 2000)
38-
})
39-
}
33+
function getUsername3(): Promise<string> {
34+
return new Promise((resolve, reject) => {
35+
setTimeout(() => {
36+
resolve('No.3')
37+
}, 2000)
38+
})
39+
}
4040
41-
useAsyncOrder({
42-
task: [
43-
resolve => {
44-
getUsername().then(res => {
45-
resolve?.(res)
46-
})
47-
},
48-
resolve => {
49-
getUsername2().then(res => {
50-
resolve?.(res)
51-
})
52-
},
53-
(_, reject) => {
54-
getUsername2().then(() => {
55-
reject?.({ err: 'error' })
56-
})
41+
useAsyncOrder({
42+
task: [
43+
resolve => {
44+
getUsername().then(res => {
45+
resolve?.(res)
46+
})
47+
},
48+
resolve => {
49+
getUsername2().then(res => {
50+
resolve?.(res)
51+
})
52+
},
53+
(_, reject) => {
54+
getUsername2().then(() => {
55+
reject?.({ err: 'error' })
56+
})
57+
},
58+
(_, reject) => {
59+
getUsername3().then(() => {
60+
reject?.({ error: 'error' })
61+
})
62+
},
63+
],
64+
option: {
65+
onError: err => {
66+
error.value += 1
67+
},
68+
onSuccess: res => {
69+
list.value.push(res as string)
70+
},
5771
},
58-
(_, reject) => {
59-
getUsername3().then(() => {
60-
reject?.({ error: 'error' })
61-
})
62-
},
63-
],
64-
option: {
65-
onError: err => {
66-
error.value += 1
67-
},
68-
onSuccess: res => {
69-
list.value.push(res as string)
70-
},
71-
},
72-
})
72+
})
7373
</script>

packages/hooks/src/useAsyncOrder/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ export default function useAsyncOrder({ task, option }: UseAsyncOrderType) {
5050
}
5151
}
5252
const runTask = () => {
53-
// eslint-disable-next-line @typescript-eslint/no-extra-semi
5453
Array(...task.keys())?.reduce((promise, index) => {
5554
const promise_ = promise.then((res: any) => {
5655
if (!res?.error) {

packages/hooks/src/useEventEmitter/event.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import _ from 'lodash'
1+
import cloneDeep from 'lodash/cloneDeep'
22
import { ref, watchEffect } from 'vue'
33

44
type SubscriptionParams<T = any> = {
@@ -52,13 +52,13 @@ class EventEmitter<T> {
5252
const subscriptionValuesCallback = this.subscriptions.get(event)
5353
subscriptionValuesCallback?.forEach(callback => {
5454
callback?.({
55-
params: _.cloneDeep(args) as any,
55+
params: cloneDeep(args) as any,
5656
event,
5757
})
5858
})
5959

6060
this.emitEffectCache.set(event, {
61-
params: _.cloneDeep(args) as any,
61+
params: cloneDeep(args) as any,
6262
event,
6363
})
6464
} else throw new TypeError('event must be string or number !')

packages/hooks/src/useKeyPress/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { ref } from 'vue'
2-
import { isFunction, isNumber, isString } from 'lodash'
2+
// import { isFunction, isNumber, isString } from 'lodash'
33
import { BasicTarget, getTargetElement } from '../utils/domTarget'
44
import useDeepCompareEffectWithTarget from '../utils/useDeepCompareWithTarget'
5+
import { isNumber, isFunction, isString } from '../utils'
56

67
export type UseKeyPressKeyPredicate = (event: KeyboardEvent) => boolean
78
export type UseKeyPressKeyType = number | string

packages/hooks/src/useRequest/plugins/useDebouncePlugin.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ const useDebouncePlugin: UseRequestPlugin<unknown, unknown[]> = (
1414
const debounceTrailing_ = unref(debounceTrailing)
1515
const debounceMaxWait_ = unref(debounceMaxWait)
1616
if (debounceLeading_ !== undefined) {
17-
ret.leading =debounceLeading_;
17+
ret.leading = debounceLeading_;
1818
}
1919
if (debounceTrailing_ !== undefined) {
2020
ret.trailing = debounceTrailing_
2121
}
2222
if (debounceMaxWait_ !== undefined) {
23-
ret.maxWait =debounceMaxWait_;
23+
ret.maxWait = debounceMaxWait_;
2424
}
2525
return ret;
2626
});

packages/use-worker/vite.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export default defineConfig({
2121
},
2222
chunkSizeWarningLimit: 1000,
2323
rollupOptions: {
24-
external: ['vue', 'lodash/isEqual'],
24+
external: ['vue'],
2525
output: {
2626
globals: {
2727
vue: 'Vue',

0 commit comments

Comments
 (0)