1- import type { API , FileInfo , Options , ASTPath , ImportDeclaration } from 'jscodeshift' ;
1+ import type {
2+ API ,
3+ FileInfo ,
4+ Options ,
5+ ASTPath ,
6+ ImportDeclaration ,
7+ } from 'jscodeshift' ;
28
39const REMOVED_COMPONENTS : Record < string , string > = {
410 'uui-caret' : 'uui-symbol-expand' ,
@@ -17,8 +23,9 @@ function mapSource(source: string): MapResult {
1723 }
1824
1925 // Match @umbraco -ui/uui-{name} with optional /lib/{file} (strip trailing .js)
20- const match =
21- / ^ @ u m b r a c o - u i \/ u u i - ( [ ^ / ] + ?) (?: \/ l i b \/ ( .+ ?) (?: \. j s ) ? ) ? $ / . exec ( source ) ;
26+ const match = / ^ @ u m b r a c o - u i \/ u u i - ( [ ^ / ] + ?) (?: \/ l i b \/ ( .+ ?) (?: \. j s ) ? ) ? $ / . exec (
27+ source ,
28+ ) ;
2229 if ( ! match ) return { target : null } ;
2330
2431 const [ , name , libFile ] = match ;
@@ -172,35 +179,39 @@ export default function transform(
172179 // --- Dynamic imports: import('...') ---
173180 // tsx parser: CallExpression with callee.type === 'Import'
174181
175- root
176- . find ( j . CallExpression , { callee : { type : 'Import' } } )
177- . forEach ( path => {
178- const arg = path . node . arguments [ 0 ] ;
179- if ( ! arg ) return ;
180-
181- let source : string | null = null ;
182- if ( arg . type === 'StringLiteral' ) {
183- source = arg . value ;
184- } else if ( arg . type === 'Literal' && typeof arg . value === 'string' ) {
185- source = arg . value ;
186- }
182+ root . find ( j . CallExpression , { callee : { type : 'Import' } } ) . forEach ( path => {
183+ const arg = path . node . arguments [ 0 ] ;
184+ if ( ! arg ) return ;
187185
188- if ( ! source ) return ;
186+ let source : string | null = null ;
187+ if ( arg . type === 'StringLiteral' ) {
188+ source = arg . value ;
189+ } else if ( arg . type === 'Literal' && typeof arg . value === 'string' ) {
190+ source = arg . value ;
191+ }
189192
190- const result = mapSource ( source ) ;
191- if ( result . warning ) warnings . push ( result . warning ) ;
192- if ( result . target ) {
193- arg . value = result . target ;
194- hasChanges = true ;
195- }
196- } ) ;
193+ if ( ! source ) return ;
194+
195+ const result = mapSource ( source ) ;
196+ if ( result . warning ) warnings . push ( result . warning ) ;
197+ if ( result . target ) {
198+ arg . value = result . target ;
199+ hasChanges = true ;
200+ }
201+ } ) ;
197202
198203 // --- Path-based references (string literals in configs, template literals in HTML) ---
199204 // Handles e.g. vite-plugin-static-copy targets and <link> tags in Lit templates.
200205
201206 const PATH_REPLACEMENTS : [ RegExp , string ] [ ] = [
202- [ / @ u m b r a c o - u i \/ u u i - c s s \/ d i s t \/ u u i - c s s \. c s s / g, '@umbraco-ui/uui/dist/themes/light.css' ] ,
203- [ / @ u m b r a c o - u i \/ u u i - c s s \/ a s s e t s \/ f o n t s / g, '@umbraco-ui/uui/dist/assets/fonts' ] ,
207+ [
208+ / @ u m b r a c o - u i \/ u u i - c s s \/ d i s t \/ u u i - c s s \. c s s / g,
209+ '@umbraco-ui/uui/dist/themes/light.css' ,
210+ ] ,
211+ [
212+ / @ u m b r a c o - u i \/ u u i - c s s \/ a s s e t s \/ f o n t s / g,
213+ '@umbraco-ui/uui/dist/assets/fonts' ,
214+ ] ,
204215 ] ;
205216
206217 function rewritePaths ( value : string ) : string | null {
0 commit comments