@@ -10,7 +10,7 @@ const compatPackageName = '@ui5/webcomponents-react-compat';
1010
1111const packageNames = [ mainPackageName , basePackageName , chartsPackageName , aiPackageName , compatPackageName ] ;
1212
13- const ignoredImportedNames = new Set ( [
13+ const internalTypes = new Set ( [
1414 'ReducedReactNode' ,
1515 'ReducedReactNodeWithBoolean' ,
1616 'UI5WCSlotsNode' ,
8585 console . warn ( `⚠️ Could not read utils index at ${ utilsIndexPath } .` , e ) ;
8686}
8787
88- // Mapping functions
8988function resolveBaseExport ( importedName : string ) : string | undefined {
9089 const directMap : Record < string , string > = {
9190 Device : `${ basePackageName } /Device` ,
@@ -146,7 +145,7 @@ export default function transform(file: FileInfo, api: API): string | undefined
146145 }
147146
148147 let isDirty = false ;
149-
148+ let shouldKeepOldImport = false ;
150149 packageNames . forEach ( ( pkg ) => {
151150 root . find ( j . ImportDeclaration , { source : { value : pkg } } ) . forEach ( ( importPath ) => {
152151 const specifiers = importPath . node . specifiers || [ ] ;
@@ -157,8 +156,28 @@ export default function transform(file: FileInfo, api: API): string | undefined
157156 }
158157
159158 const importedName = spec . imported . name as string ;
160-
161- if ( ignoredImportedNames . has ( importedName ) ) {
159+ shouldKeepOldImport = false ;
160+ if ( internalTypes . has ( importedName ) ) {
161+ if ( pkg === mainPackageName ) {
162+ const newImport = j . importDeclaration (
163+ [
164+ j . importSpecifier (
165+ j . identifier ( importedName ) ,
166+ j . identifier ( spec . local && typeof spec . local . name === 'string' ? spec . local . name : importedName ) ,
167+ ) ,
168+ ] ,
169+ j . literal ( `${ basePackageName } /dist/types/index.js` ) ,
170+ ) ;
171+ if ( 'importKind' in spec && spec . importKind === 'type' ) {
172+ newImport . importKind = 'type' ;
173+ }
174+ j ( importPath ) . insertBefore ( newImport ) ;
175+ isDirty = true ;
176+ } else {
177+ // todo: clarify if this should be included as well
178+ // If from base package, keep import as is for now
179+ shouldKeepOldImport = true ;
180+ }
162181 return ;
163182 }
164183
@@ -202,7 +221,10 @@ export default function transform(file: FileInfo, api: API): string | undefined
202221 j ( importPath ) . insertBefore ( newImport ) ;
203222 isDirty = true ;
204223 } ) ;
205- j ( importPath ) . remove ( ) ;
224+
225+ if ( ! shouldKeepOldImport ) {
226+ j ( importPath ) . remove ( ) ;
227+ }
206228 } ) ;
207229 } ) ;
208230
0 commit comments