mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-25 23:22:02 +00:00
perf(nuxt): cache createClientOnly
wrapper using weakmap (#7297)
This commit is contained in:
parent
0a775e3f70
commit
f8f5771646
@ -18,7 +18,13 @@ export default defineComponent({
|
||||
}
|
||||
})
|
||||
|
||||
const cache = new WeakMap()
|
||||
|
||||
export function createClientOnly (component) {
|
||||
if (cache.has(component)) {
|
||||
return cache.get(component)
|
||||
}
|
||||
|
||||
const clone = { ...component }
|
||||
|
||||
if (clone.render) {
|
||||
@ -53,5 +59,7 @@ export function createClientOnly (component) {
|
||||
})
|
||||
}
|
||||
|
||||
cache.set(component, clone)
|
||||
|
||||
return clone
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user