@@ -11,18 +11,42 @@ Object.assign(exports, require("./plugins"));
1111Object . assign ( exports , require ( "./host/resolver" ) ) ;
1212
1313exports . processTsPathsForScopedModules = function ( { compilerOptions } ) {
14- return replacePathInCompilerOptions ( {
14+ const tnsModulesOldPackage = "tns-core-modules" ;
15+ const tnsModulesNewPackage = "@nativescript/core" ;
16+ replacePathInCompilerOptions ( {
1517 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 } /*`
1830 } ) ;
1931}
2032
2133exports . 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 ( {
2347 compilerOptions,
24- targetPath : "nativescript-angular" ,
25- replacementPath : "@nativescript/angular"
48+ sourcePath : ` ${ nsAngularOldPackage } /*` ,
49+ destinationPath : `./node_modules/ ${ nsAngularNewPackage } /*`
2650 } ) ;
2751}
2852
@@ -215,4 +239,15 @@ function replacePathInCompilerOptions({ compilerOptions, targetPath, replacement
215239 }
216240 }
217241 }
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+ }
218253}
0 commit comments