File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,9 @@ import type { NuxtIconModuleContext } from './context'
4
4
export function registerClientBundle (
5
5
ctx : NuxtIconModuleContext ,
6
6
) : void {
7
+ let cacheSize = 0
8
+ let cacheData : string | null = null
9
+
7
10
// Client bundle
8
11
addTemplate ( {
9
12
filename : 'nuxt-icon-client-bundle.mjs' ,
@@ -13,8 +16,13 @@ export function registerClientBundle(
13
16
sizeLimitKb = 256 ,
14
17
} = ctx . options . clientBundle || { }
15
18
19
+ // TODO: find a granular way to cache this
16
20
const { collections, count, failed } = await ctx . loadClientBundleCollections ( )
17
21
22
+ if ( cacheSize === count && cacheData ) {
23
+ return cacheData
24
+ }
25
+
18
26
if ( failed . length ) {
19
27
const msg = `Nuxt Icon could not fetch the icon data for client bundle:\n${ failed . map ( f => ' - ' + f ) . join ( '\n' ) } `
20
28
if ( ctx . nuxt . options . _build )
@@ -43,7 +51,7 @@ export function registerClientBundle(
43
51
44
52
const collectionsRaw = `JSON.parse(${ JSON . stringify ( valuesCompat ) } )`
45
53
46
- return [
54
+ cacheData = [
47
55
'let _initialized = false' ,
48
56
'export function init(addIcon) {' ,
49
57
' if (_initialized)' ,
@@ -57,6 +65,8 @@ export function registerClientBundle(
57
65
' _initialized = true' ,
58
66
'}' ,
59
67
] . join ( '\n' )
68
+ cacheSize = count
69
+ return cacheData
60
70
} ,
61
71
} )
62
72
}
You can’t perform that action at this time.
0 commit comments