File tree 6 files changed +27
-10
lines changed
6 files changed +27
-10
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,12 @@ import * as data from 'myproject/data.json';
6
6
7
7
export { DATA as XYZ } from '@commons' ;
8
8
9
+ console . log ( DATA ) ;
10
+
11
+ if ( DATA !== 'mydata' ) {
12
+ throw new Error ( 'Bad resolution' ) ;
13
+ }
14
+
9
15
console . log ( DATA ) ;
10
16
console . log ( CUSTOM_MODULE ) ;
11
17
console . log ( EXTRA ) ;
Original file line number Diff line number Diff line change 10
10
"resolveJsonModule" : true ,
11
11
"paths" : {
12
12
"myproject/*" : [" ./*" ],
13
- "@commons" : [" lib/commons/index.ts" ],
13
+ "@commons" : [" libo/commo/index-1.ts " , " lib/commons/index.ts" ],
14
14
"custom/*" : [" custom_modules/*" , " custom_modules/modules/*" ],
15
15
"extra" : [" ../../project2/index" ]
16
16
}
Original file line number Diff line number Diff line change @@ -115,7 +115,7 @@ export function findBasePathOfAlias(config: IProjectConfig) {
115
115
* folder in the output folder (outDir).
116
116
*/
117
117
if ( aliasPath . path . match ( / ^ ( \. \/ | ) n o d e _ m o d u l e s / g) ) {
118
- aliasPath . basePath = resolve ( config . baseUrl , aliasPath . path ) ;
118
+ aliasPath . basePath = resolve ( config . baseUrl , 'node_modules' ) ;
119
119
aliasPath . isExtra = false ;
120
120
return aliasPath ;
121
121
}
Original file line number Diff line number Diff line change @@ -36,7 +36,9 @@ export default function replaceBaseUrlImport({
36
36
let relativePath : string = normalizePath (
37
37
relative (
38
38
dirname ( file ) ,
39
- config . pathCache . getAbsoluteAliasPath ( config . outPath , '' )
39
+ config . pathCache
40
+ . getAbsoluteAliasPath ( config . outPath , '' )
41
+ . replace ( '---' , '' )
40
42
)
41
43
) ;
42
44
if ( ! relativePath . startsWith ( '.' ) ) {
Original file line number Diff line number Diff line change @@ -56,7 +56,7 @@ export default function replaceImportStatement({
56
56
57
57
if ( isAlias ) {
58
58
for ( let i = 0 ; i < alias . paths . length ; i ++ ) {
59
- const absoluteAliasPath = config . pathCache . getAbsoluteAliasPath (
59
+ let absoluteAliasPath = config . pathCache . getAbsoluteAliasPath (
60
60
alias . paths [ i ] . basePath ,
61
61
alias . paths [ i ] . path
62
62
) ;
@@ -65,6 +65,14 @@ export default function replaceImportStatement({
65
65
absoluteAliasPath
66
66
) ;
67
67
68
+ if ( absoluteAliasPath . startsWith ( '---' ) ) {
69
+ if ( i === alias . paths . length - 1 ) {
70
+ absoluteAliasPath = absoluteAliasPath . replace ( '---' , '' ) ;
71
+ } else {
72
+ continue ;
73
+ }
74
+ }
75
+
68
76
// Check if path is valid.
69
77
if (
70
78
! config . pathCache . existsResolvedAlias (
Original file line number Diff line number Diff line change @@ -97,19 +97,20 @@ export class PathCache {
97
97
98
98
let aliasPathPart = aliasPathParts . shift ( ) || '' ;
99
99
100
- let pathExists : boolean ;
100
+ let pathExists = false ;
101
+
101
102
while (
102
103
! ( pathExists = this . exists ( join ( basePath , aliasPathPart ) ) ) &&
103
104
aliasPathParts . length
104
105
) {
105
106
aliasPathPart = aliasPathParts . shift ( ) ;
106
107
}
107
108
108
- return join (
109
- basePath ,
110
- pathExists ? aliasPathPart : '' ,
111
- aliasPathParts . join ( '/' )
112
- ) ;
109
+ if ( pathExists ) {
110
+ return join ( basePath , aliasPathPart , aliasPathParts . join ( '/' ) ) ;
111
+ }
112
+
113
+ return '---' + join ( basePath , aliasPathParts . join ( '/' ) ) ;
113
114
}
114
115
115
116
/**
You can’t perform that action at this time.
0 commit comments