@@ -39,32 +39,36 @@ class VueProgram {
39
39
public static resolveNonTsModuleName ( moduleName : string , containingFile : string , basedir : string , options : ts . CompilerOptions ) {
40
40
const baseUrl = options . baseUrl ? options . baseUrl : basedir ;
41
41
const discartedSymbols = [ '.' , '..' , '/' ] ;
42
- let wildcards : string [ ] = [ ] ;
43
- Object . keys ( options . paths ) . forEach ( path => {
44
- const pathSymbol = path [ 0 ] ;
45
- if ( discartedSymbols . indexOf ( pathSymbol ) < 0 && wildcards . indexOf ( pathSymbol ) < 0 ) {
46
- wildcards . push ( pathSymbol ) ;
47
- }
48
- } ) ;
42
+ const wildcards : string [ ] = [ ] ;
49
43
50
- const isRelative = ! path . isAbsolute ( moduleName ) ;
51
- let correctWildcard ;
52
-
53
- wildcards . forEach ( wildcard => {
54
- if ( moduleName . substr ( 0 , 2 ) === `${ wildcard } /` ) {
55
- correctWildcard = wildcard ;
56
- }
57
- } ) ;
58
-
59
- if ( correctWildcard ) {
60
- const pattern = options . paths ? options . paths [ `${ correctWildcard } /*` ] : undefined ;
61
- const substitution = pattern ? options . paths [ `${ correctWildcard } /*` ] [ 0 ] . replace ( '*' , '' ) : 'src' ;
62
- moduleName = path . resolve ( baseUrl , substitution , moduleName . substr ( 2 ) ) ;
63
- }
64
- else if ( isRelative ) {
65
- moduleName = path . resolve ( path . dirname ( containingFile ) , moduleName ) ;
44
+ if ( options . paths ) {
45
+ Object . keys ( options . paths ) . forEach ( key => {
46
+ const pathSymbol = key [ 0 ] ;
47
+ if ( discartedSymbols . indexOf ( pathSymbol ) < 0 && wildcards . indexOf ( pathSymbol ) < 0 ) {
48
+ wildcards . push ( pathSymbol ) ;
66
49
}
67
- return moduleName ;
50
+ } ) ;
51
+ } else {
52
+ wildcards . push ( '@' ) ;
53
+ }
54
+
55
+ const isRelative = ! path . isAbsolute ( moduleName ) ;
56
+ let correctWildcard ;
57
+
58
+ wildcards . forEach ( wildcard => {
59
+ if ( moduleName . substr ( 0 , 2 ) === `${ wildcard } /` ) {
60
+ correctWildcard = wildcard ;
61
+ }
62
+ } ) ;
63
+
64
+ if ( correctWildcard ) {
65
+ const pattern = options . paths ? options . paths [ `${ correctWildcard } /*` ] : undefined ;
66
+ const substitution = pattern ? options . paths [ `${ correctWildcard } /*` ] [ 0 ] . replace ( '*' , '' ) : 'src' ;
67
+ moduleName = path . resolve ( baseUrl , substitution , moduleName . substr ( 2 ) ) ;
68
+ } else if ( isRelative ) {
69
+ moduleName = path . resolve ( path . dirname ( containingFile ) , moduleName ) ;
70
+ }
71
+ return moduleName ;
68
72
}
69
73
70
74
public static isVue ( filePath : string ) {
0 commit comments