Skip to content
This repository was archived by the owner on Aug 7, 2021. It is now read-only.

Commit 9902999

Browse files
author
Dimitar Tachev
authored
Merge pull request #1108 from NativeScript/tachev/ng-aot-scoped
fix: add missing tsconfig paths when the app is using only scoped core modules and Angular
2 parents c0c285b + 87ec157 commit 9902999

File tree

2 files changed

+42
-7
lines changed

2 files changed

+42
-7
lines changed

Diff for: index.js

+41-6
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,42 @@ Object.assign(exports, require("./plugins"));
1111
Object.assign(exports, require("./host/resolver"));
1212

1313
exports.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

2133
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({
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
}

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nativescript-dev-webpack",
3-
"version": "1.4.0",
3+
"version": "1.4.1",
44
"main": "index",
55
"description": "",
66
"homepage": "http://www.telerik.com",

0 commit comments

Comments
 (0)