@@ -34,8 +34,8 @@ export function defineConfig(config: UserConfig) {
3434 presetIcons ( {
3535 collections : {
3636 ...readCustomIcons ( ) ,
37- ph : ( ) => loadIconifyCollection ( ' ph') ,
38- 'svg-spinners' : ( ) => loadIconifyCollection ( ' svg-spinners') ,
37+ ph : ( ) => import ( '@iconify-json/ ph') . then ( ( i ) => i . icons ) ,
38+ 'svg-spinners' : ( ) => import ( '@iconify-json/ svg-spinners') . then ( ( i ) => i . icons ) ,
3939 } ,
4040 } ) ,
4141 ] ,
@@ -87,51 +87,3 @@ const shortcuts: UserConfig['shortcuts'] = {
8787 'panel-button' :
8888 'flex items-center gap-1.5 whitespace-nowrap rounded-md text-sm transition-theme bg-tk-elements-panel-headerButton-backgroundColor hover:bg-tk-elements-panel-headerButton-backgroundColorHover text-tk-elements-panel-headerButton-textColor hover:text-tk-elements-panel-headerButton-textColorHover' ,
8989} ;
90-
91- async function loadIconifyCollection ( name : string ) {
92- // Try to require the package (works for CJS or when package exposes a CJS entry)
93- try {
94- // use createRequire to ensure resolution from the package context
95-
96- const pkg = require ( `@iconify-json/${ name } ` ) ;
97-
98- if ( pkg && pkg . icons ) {
99- return pkg . icons ;
100- }
101- } catch {
102- // fallthrough to fs-based resolution
103- }
104-
105- // Fall back: resolve package root and try to find a JSON file with icons
106- try {
107- const pkgJsonPath = require . resolve ( `@iconify-json/${ name } /package.json` , { paths : [ process . cwd ( ) ] } ) ;
108- const pkgRoot = dirname ( pkgJsonPath ) ;
109-
110- // Common icon file names
111- const candidates = [ 'icons.json' , 'index.json' , 'icons/index.json' ] ;
112-
113- for ( const cand of candidates ) {
114- try {
115- const full = resolve ( pkgRoot , cand ) ;
116- const text = await fs . readFile ( full , 'utf8' ) ;
117- const parsed = JSON . parse ( text ) ;
118-
119- if ( parsed && parsed . icons ) {
120- return parsed . icons ;
121- }
122-
123- // sometimes the package itself *is* the icons object
124- if ( parsed && Object . keys ( parsed ) . length ) {
125- return parsed ;
126- }
127- } catch {
128- // try next candidate
129- }
130- }
131- } catch {
132- // give up
133- }
134-
135- // Last resort: return an empty collection to avoid throwing at build-time
136- return { } ;
137- }
0 commit comments