@@ -17,7 +17,12 @@ export const extractUsedSvelteComponents = (
1717
1818 const traverse = ( currentNode : RenderableTreeNode | null | undefined ) => {
1919 // If current node can't be a component, skip it
20- if ( ! currentNode || typeof currentNode === 'string' || typeof currentNode === 'number' || typeof currentNode === 'boolean' )
20+ if (
21+ ! currentNode ||
22+ typeof currentNode === "string" ||
23+ typeof currentNode === "number" ||
24+ typeof currentNode === "boolean"
25+ )
2126 return ;
2227
2328 // Recursively work through children of arrays until get to objects
@@ -31,7 +36,11 @@ export const extractUsedSvelteComponents = (
3136 // Check if this RenderableTreeNode object itself represents a Svelte component.
3237 // 'currentNode.name' here is the name of the component/tag to be rendered.
3338 // Convention: if node.name starts with an uppercase letter, it's a Svelte component.
34- if ( currentNode . name && typeof currentNode . name === 'string' && / \p{ Lu} / u. test ( currentNode . name ) ) {
39+ if (
40+ currentNode . name &&
41+ typeof currentNode . name === "string" &&
42+ / \p{ Lu} / u. test ( currentNode . name )
43+ ) {
3544 usedComponents . add ( currentNode . name ) ;
3645 }
3746
@@ -41,7 +50,7 @@ export const extractUsedSvelteComponents = (
4150 traverse ( child as RenderableTreeNode | null | undefined ) ;
4251 }
4352 }
44- }
53+ } ;
4554
4655 traverse ( node ) ;
4756 return usedComponents ;
@@ -63,7 +72,7 @@ export const getComponentImports = (
6372 for ( const componentName of usedSvelteComponentNames ) {
6473 // Use Vite's normalizePath for proper cross-platform path handling
6574 const componentPath = normalizePath (
66- `${ componentDirPath } /${ componentName } .svelte`
75+ `${ componentDirPath } /${ componentName } .svelte` ,
6776 ) ;
6877
6978 // Generate the import statement
0 commit comments