@@ -6,6 +6,7 @@ import type {
66 ExportAllDeclaration ,
77 ExportNamedDeclaration ,
88} from '@babel/types' ;
9+ import isFabricComponentFile from './utils/isFabricComponentFile' ;
910
1011type Options = {
1112 /**
@@ -38,17 +39,18 @@ const isDirectory = (filename: string): boolean => {
3839 return exists ;
3940} ;
4041
41- const isModule = (
42+ const checkExts = (
4243 filename : string ,
4344 extension : string ,
44- platforms : string [ ]
45+ platforms : string [ ] ,
46+ callback : ( ext : string ) => boolean
4547) : boolean => {
4648 const exts = [ 'js' , 'ts' , 'jsx' , 'tsx' , extension ] ;
4749
4850 return exts . some (
4951 ( ext ) =>
50- isFile ( `${ filename } .${ ext } ` ) &&
51- platforms . every ( ( platform ) => ! isFile ( `${ filename } .${ platform } .${ ext } ` ) )
52+ callback ( `${ filename } .${ ext } ` ) &&
53+ platforms . every ( ( platform ) => ! callback ( `${ filename } .${ platform } .${ ext } ` ) )
5254 ) ;
5355} ;
5456
@@ -112,22 +114,29 @@ export default function (
112114 node . source . value
113115 ) ;
114116
117+ // Skip if file is a fabric view
118+ if (
119+ checkExts ( filename , extension , platforms , ( f ) => isFabricComponentFile ( f ) )
120+ ) {
121+ return ;
122+ }
123+
115124 // Replace .ts extension with .js if file with extension is explicitly imported
116125 if ( isFile ( filename ) ) {
117126 node . source . value = node . source . value . replace ( / \. t s x ? $ / , `.${ extension } ` ) ;
118127 return ;
119128 }
120129
121130 // Add extension if .ts file or file with extension exists
122- if ( isModule ( filename , extension , platforms ) ) {
131+ if ( checkExts ( filename , extension , platforms , isFile ) ) {
123132 node . source . value += `.${ extension } ` ;
124133 return ;
125134 }
126135
127136 // Expand folder imports to index and add extension
128137 if (
129138 isDirectory ( filename ) &&
130- isModule ( path . join ( filename , 'index' ) , extension , platforms )
139+ checkExts ( path . join ( filename , 'index' ) , extension , platforms , isFile )
131140 ) {
132141 node . source . value = node . source . value . replace (
133142 / \/ ? $ / ,
0 commit comments