@@ -11,18 +11,42 @@ Object.assign(exports, require("./plugins"));
11
11
Object . assign ( exports , require ( "./host/resolver" ) ) ;
12
12
13
13
exports . processTsPathsForScopedModules = function ( { compilerOptions } ) {
14
- return replacePathInCompilerOptions ( {
14
+ const tnsModulesOldPackage = "tns-core-modules" ;
15
+ const tnsModulesNewPackage = "@nativescript/core" ;
16
+ replacePathInCompilerOptions ( {
15
17
compilerOptions,
16
- targetPath : "tns-core-modules" ,
17
- replacementPath : "@nativescript/core"
18
+ targetPath : tnsModulesOldPackage ,
19
+ replacementPath : tnsModulesNewPackage
20
+ } ) ;
21
+ ensurePathInCompilerOptions ( {
22
+ compilerOptions,
23
+ sourcePath : tnsModulesOldPackage ,
24
+ destinationPath : `./node_modules/${ tnsModulesNewPackage } `
25
+ } ) ;
26
+ ensurePathInCompilerOptions ( {
27
+ compilerOptions,
28
+ sourcePath : `${ tnsModulesOldPackage } /*` ,
29
+ destinationPath : `./node_modules/${ tnsModulesNewPackage } /*`
18
30
} ) ;
19
31
}
20
32
21
33
exports . processTsPathsForScopedAngular = function ( { compilerOptions } ) {
22
- return replacePathInCompilerOptions ( {
34
+ const nsAngularOldPackage = "nativescript-angular" ;
35
+ const nsAngularNewPackage = "@nativescript/angular" ;
36
+ replacePathInCompilerOptions ( {
37
+ compilerOptions,
38
+ targetPath : nsAngularOldPackage ,
39
+ replacementPath : nsAngularNewPackage
40
+ } ) ;
41
+ ensurePathInCompilerOptions ( {
42
+ compilerOptions,
43
+ sourcePath : nsAngularOldPackage ,
44
+ destinationPath : `./node_modules/${ nsAngularNewPackage } `
45
+ } ) ;
46
+ ensurePathInCompilerOptions ( {
23
47
compilerOptions,
24
- targetPath : "nativescript-angular" ,
25
- replacementPath : "@nativescript/angular"
48
+ sourcePath : ` ${ nsAngularOldPackage } /*` ,
49
+ destinationPath : `./node_modules/ ${ nsAngularNewPackage } /*`
26
50
} ) ;
27
51
}
28
52
@@ -215,4 +239,15 @@ function replacePathInCompilerOptions({ compilerOptions, targetPath, replacement
215
239
}
216
240
}
217
241
}
242
+ }
243
+
244
+ function ensurePathInCompilerOptions ( { compilerOptions, sourcePath, destinationPath } ) {
245
+ const paths = ( compilerOptions && compilerOptions . paths ) || { } ;
246
+ if ( paths [ sourcePath ] ) {
247
+ if ( Array . isArray ( paths [ sourcePath ] ) && paths [ sourcePath ] . indexOf ( destinationPath ) === - 1 ) {
248
+ paths [ sourcePath ] . push ( destinationPath ) ;
249
+ }
250
+ } else {
251
+ paths [ sourcePath ] = [ destinationPath ] ;
252
+ }
218
253
}
0 commit comments