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

Commit 87680b6

Browse files
authored
refactor: stop adding TS as dependency (#406)
* refactor: stop adding TS as dependency as it should be added in project template * docs: remove note about dependencies * refactor: add scoped package prefix for @angular/compiler-cli
1 parent 1ad97ff commit 87680b6

File tree

2 files changed

+4
-65
lines changed

2 files changed

+4
-65
lines changed

README.md

-14
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,3 @@ $ tns run ios --bundle
2222

2323
For details, see the [NativeScript docs](http://docs.nativescript.org/angular/best-practices/bundling-with-webpack.html).
2424

25-
# Note about dependencies.
26-
27-
The `nativescript-dev-webpack` plugin adds a few devDependencies to the project. Make sure to run either `npm install` or `yarn` after installing the plugin.
28-
The versions of the newly added packages depend on the versions of some of your already added packages. More specifically - `tns-core-modules` and all packages from the `@angular` scope. Since version 0.4.0, nativescript-dev-webpack will automatically add the correct development dependencies, based on what you already have installed.
29-
You can force update your `package.json` using the `update-ns-webpack` script which you can find in `PROJECT_DIR/node_modules/.bin`.
30-
If the bundling process fails, please make sure you have the correct versions of the packages.
31-
32-
| Main packages versions | Plugins versions
33-
| --- | ---
34-
| `tns-core-modules`: **^3.0.0** <br> `@angular/`: **^4.0.0** | `nativescript-angular`: **^3.0.0** <br> `@ngtools/webpack`: **^1.3.0** <br> `typescript`: **^2.2.0**
35-
| `tns-core-modules`: **^2.5.0** <br> `@angular/`: **^4.0.0** | `nativescript-angular`: **^1.5.1** <br> `@ngtools/webpack`: **1.2.13** <br> `typescript`: **2.1.6**
36-
| `tns-core-modules`: **^2.5.0** <br> `@angular/`: **^2.4.0** | `nativescript-angular`: **^1.4.1** <br> ``@ngtools/webpack``: **1.2.10** <br> `typescript`: **2.1.6**
37-
38-
P.S. Also please make sure you are using the same version of all `@angular/` packages, including the devDependency of `@angular/compiler-cli`.

dependencyManager.js

+4-51
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,10 @@ function getRequiredDeps(packageJson) {
7171
};
7272

7373
if (isAngular({packageJson})) {
74-
const angularDeps = resolveAngularDeps(packageJson.dependencies);
75-
Object.assign(deps, angularDeps);
74+
Object.assign(deps, {
75+
"@angular/compiler-cli": packageJson.dependencies["@angular/core"],
76+
"@ngtools/webpack": "~1.9.4",
77+
});
7678
} else if (isTypeScript({packageJson})) {
7779
Object.assign(deps, { "awesome-typescript-loader": "~3.1.3" });
7880
}
@@ -84,55 +86,6 @@ function getRequiredDeps(packageJson) {
8486
return deps;
8587
}
8688

87-
function resolveAngularDeps(usedDependencies) {
88-
const depsToAdd = {
89-
"@angular/compiler-cli": usedDependencies["@angular/core"],
90-
};
91-
const tnsModulesVersion = getVersionWithoutPatch(usedDependencies["tns-core-modules"]);
92-
const angularCoreVersion = getVersionWithoutPatch(usedDependencies["@angular/core"]);
93-
94-
if (angularCoreVersion.startsWith("2.")) {
95-
Object.assign(depsToAdd, {
96-
"typescript": "~2.1.6",
97-
"@ngtools/webpack": "1.2.10",
98-
});
99-
} else if (tnsModulesVersion.startsWith("2.")) {
100-
Object.assign(depsToAdd, {
101-
"typescript": "~2.1.6",
102-
"@ngtools/webpack": "1.2.13",
103-
});
104-
} else if (angularCoreVersion.startsWith("5.0")) {
105-
Object.assign(depsToAdd, {
106-
"typescript": "~2.4.2",
107-
"@ngtools/webpack": "~1.8.2",
108-
});
109-
} else {
110-
Object.assign(depsToAdd, {
111-
"typescript": "~2.4.2",
112-
"@ngtools/webpack": "~1.9.1",
113-
});
114-
}
115-
116-
return depsToAdd;
117-
}
118-
119-
function getVersionWithoutPatch(fullVersion) {
120-
if (!fullVersion) {
121-
return "";
122-
}
123-
124-
const prereleaseVersions = Object.freeze(["next", "latest", "rc"]);
125-
if (prereleaseVersions.includes(fullVersion)) {
126-
return fullVersion;
127-
}
128-
129-
const version = fullVersion.substring(0, fullVersion.lastIndexOf("."));
130-
131-
return version.startsWith("~") || version.startsWith("^") ?
132-
version.substring(1) :
133-
version;
134-
}
135-
13689
function showHelperMessages({ newDepsAdded, hasOldDeps }) {
13790
console.info(USAGE_MESSAGE);
13891

0 commit comments

Comments
 (0)