@@ -6,6 +6,7 @@ import type {
6
6
ExportAllDeclaration ,
7
7
ExportNamedDeclaration ,
8
8
} from '@babel/types' ;
9
+ import isFabricComponentFile from './utils/isFabricComponentFile' ;
9
10
10
11
type Options = {
11
12
/**
@@ -38,17 +39,18 @@ const isDirectory = (filename: string): boolean => {
38
39
return exists ;
39
40
} ;
40
41
41
- const isModule = (
42
+ const checkExts = (
42
43
filename : string ,
43
44
extension : string ,
44
- platforms : string [ ]
45
+ platforms : string [ ] ,
46
+ callback : ( ext : string ) => boolean
45
47
) : boolean => {
46
48
const exts = [ 'js' , 'ts' , 'jsx' , 'tsx' , extension ] ;
47
49
48
50
return exts . some (
49
51
( 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 } ` ) )
52
54
) ;
53
55
} ;
54
56
@@ -112,22 +114,29 @@ export default function (
112
114
node . source . value
113
115
) ;
114
116
117
+ // Skip if file is a fabric view
118
+ if (
119
+ checkExts ( filename , extension , platforms , ( f ) => isFabricComponentFile ( f ) )
120
+ ) {
121
+ return ;
122
+ }
123
+
115
124
// Replace .ts extension with .js if file with extension is explicitly imported
116
125
if ( isFile ( filename ) ) {
117
126
node . source . value = node . source . value . replace ( / \. t s x ? $ / , `.${ extension } ` ) ;
118
127
return ;
119
128
}
120
129
121
130
// Add extension if .ts file or file with extension exists
122
- if ( isModule ( filename , extension , platforms ) ) {
131
+ if ( checkExts ( filename , extension , platforms , isFile ) ) {
123
132
node . source . value += `.${ extension } ` ;
124
133
return ;
125
134
}
126
135
127
136
// Expand folder imports to index and add extension
128
137
if (
129
138
isDirectory ( filename ) &&
130
- isModule ( path . join ( filename , 'index' ) , extension , platforms )
139
+ checkExts ( path . join ( filename , 'index' ) , extension , platforms , isFile )
131
140
) {
132
141
node . source . value = node . source . value . replace (
133
142
/ \/ ? $ / ,
0 commit comments