File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ module.exports = {
22
22
return {
23
23
visitor : {
24
24
ImportDeclaration : function ( path , state ) {
25
+ if ( ! path . node . source ) return ;
25
26
var source = path . node . source . value ;
26
27
if ( source . match ( / ^ \. { 0 , 2 } \/ / ) && ! source . endsWith ( '.es.js' ) ) {
27
28
path . replaceWith (
@@ -32,6 +33,19 @@ module.exports = {
32
33
) ;
33
34
}
34
35
} ,
36
+ ExportNamedDeclaration : function ( path , state ) {
37
+ if ( ! path . node . source ) return ;
38
+ const source = path . node . source . value ;
39
+ if ( source . match ( / ^ \. { 0 , 2 } \/ / ) && ! source . endsWith ( '.es.js' ) ) {
40
+ path . replaceWith (
41
+ types . exportNamedDeclaration (
42
+ path . node . declaration ,
43
+ path . node . specifiers ,
44
+ types . stringLiteral ( source + '.es.js' ) ,
45
+ ) ,
46
+ ) ;
47
+ }
48
+ } ,
35
49
} ,
36
50
} ;
37
51
} ,
You can’t perform that action at this time.
0 commit comments