File tree Expand file tree Collapse file tree 2 files changed +14
-6
lines changed
packages/transform_import Expand file tree Collapse file tree 2 files changed +14
-6
lines changed Original file line number Diff line number Diff line change @@ -46,6 +46,8 @@ pub struct TransformImportConfig {
46
46
pub transform : String ,
47
47
pub style_path : Option < String > ,
48
48
pub transform_case : String ,
49
+ #[ serde( default ) ]
50
+ pub keep_import_conversion : bool ,
49
51
}
50
52
51
53
pub type TransformImportConfigs = HashMap < String , TransformImportConfig > ;
@@ -177,15 +179,19 @@ impl VisitMut for TransformImport {
177
179
& import_dclr. src ,
178
180
) ;
179
181
182
+ let new_specifier = if config. keep_import_conversion {
183
+ specifier. clone ( )
184
+ } else {
185
+ ImportSpecifier :: Default ( ImportDefaultSpecifier {
186
+ local : named_import. local . clone ( ) ,
187
+ span : named_import. span ,
188
+ } )
189
+ } ;
190
+
180
191
let new_node = ModuleItem :: ModuleDecl ( ModuleDecl :: Import (
181
192
ImportDecl {
182
193
span : import_dclr. span ,
183
- specifiers : vec ! [ ImportSpecifier :: Default (
184
- ImportDefaultSpecifier {
185
- local: named_import. local. clone( ) ,
186
- span: named_import. span,
187
- } ,
188
- ) ] ,
194
+ specifiers : vec ! [ new_specifier] ,
189
195
type_only : import_dclr. type_only ,
190
196
src : Box :: new ( transformed_path) ,
191
197
with : import_dclr. with . clone ( ) ,
Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ fn transform_import_fixture(input: PathBuf) {
26
26
transform_case : "kebab_case" . to_string ( ) ,
27
27
transform : "antd/lib/[[member]]" . to_string ( ) ,
28
28
style_path : Some ( "antd/lib/[[member]]/style" . to_string ( ) ) ,
29
+ keep_import_conversion : false ,
29
30
} ,
30
31
) ,
31
32
(
@@ -34,6 +35,7 @@ fn transform_import_fixture(input: PathBuf) {
34
35
transform_case : "" . to_string ( ) ,
35
36
transform : "lodash/[[member]]" . to_string ( ) ,
36
37
style_path : None ,
38
+ keep_import_conversion : false ,
37
39
} ,
38
40
) ,
39
41
] ) ) )
You can’t perform that action at this time.
0 commit comments