Skip to content

Commit 0bacc61

Browse files
feat(angular): v9 support (#276)
1 parent 09e3ce6 commit 0bacc61

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+201
-575
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ This repository contains schematics for generating components in NativeScript An
66

77
### Install Angular CLI
88

9-
You should be using `@angular/cli@6.1.0` or newer.
9+
You should be using `@angular/cli@9.1.0` or newer.
1010

1111
```bash
1212
npm i -g @angular/cli
@@ -141,8 +141,8 @@ This includes the following steps:
141141
In a code sharing project to build:
142142

143143
* a `web` app call: `ng serve`,
144-
* an `iOS` app call: `tns run ios --bundle`,
145-
* an `Android` app call: `tns run android --bundle`
144+
* an `iOS` app call: `tns run ios --bundle --env.aot`,
145+
* an `Android` app call: `tns run android --bundle --env.aot`
146146

147147
## Templates
148148

package.json

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@nativescript/schematics",
3-
"version": "1.0.0",
3+
"version": "9.0.0",
44
"description": "Schematics for NativeScript Angular apps.",
55
"scripts": {
66
"build": "tsc -p tsconfig.json",
@@ -17,20 +17,21 @@
1717
},
1818
"schematics": "./src/collection.json",
1919
"dependencies": {
20-
"@angular-devkit/core": "~8.2.0",
21-
"@angular-devkit/schematics": "~8.2.0",
22-
"@nativescript/tslint-rules": "~0.0.3",
23-
"@phenomnomnominal/tsquery": "^3.0.0"
20+
"@angular-devkit/core": "~9.1.0",
21+
"@angular-devkit/schematics": "~9.1.0",
22+
"@nativescript/tslint-rules": "~0.0.5",
23+
"@phenomnomnominal/tsquery": "^4.1.0"
2424
},
2525
"devDependencies": {
26-
"@schematics/angular": "~8.2.0",
27-
"@types/jasmine": "^2.6.0",
28-
"@types/node": "^8.0.31",
26+
"@schematics/angular": "~9.1.0",
27+
"@types/jasmine": "~3.5.0",
28+
"@types/jasminewd2": "~2.0.3",
29+
"@types/node": "^12.11.1",
2930
"conventional-changelog-cli": "^2.0.1",
3031
"jasmine": "^2.8.0",
3132
"jasmine-spec-reporter": "^4.2.1",
32-
"tslint": "^5.18.0",
33-
"typescript": "3.5.3"
33+
"tslint": "~6.1.0",
34+
"typescript": "~3.8.3"
3435
},
3536
"repository": {
3637
"type": "git",
@@ -55,4 +56,4 @@
5556
"Sebastian Witalec <[email protected]>"
5657
],
5758
"license": "Apache-2.0"
58-
}
59+
}

src/add-ns/_ns-files/__sourceDir__/app/__entryModuleName@dasherize__.module__nsext__.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
11
import { NgModule, NO_ERRORS_SCHEMA } from '@angular/core';
2-
import { NativeScriptModule } from 'nativescript-angular/nativescript.module';
2+
import { NativeScriptModule } from '@nativescript/angular';
33

44
import { AppRoutingModule } from './app-routing.module<%= nsext %>';
55
import { <%= entryComponentClassName %> } from '<%= entryComponentImportPath %>';
66
<% if (sample) { %>
77
import { BarcelonaModule } from './barcelona/barcelona.module';<% } %>
88

9-
// Uncomment and add to NgModule imports if you need to use two-way binding
10-
// import { NativeScriptFormsModule } from 'nativescript-angular/forms';
11-
12-
// Uncomment and add to NgModule imports if you need to use the HTTP wrapper
13-
// import { NativeScriptHttpClientModule } from 'nativescript-angular/http-client';
9+
// Uncomment and add to NgModule imports if you need to use two-way binding and/or HTTP wrapper
10+
// import { NativeScriptFormsModule, NativeScriptHttpClientModule } from '@nativescript/angular';
1411

1512
@NgModule({
1613
declarations: [

src/add-ns/_ns-files/__sourceDir__/app/app-routing.module__nsext__.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { NgModule } from '@angular/core';
2-
import { NativeScriptRouterModule } from 'nativescript-angular/router';
2+
import { NativeScriptRouterModule } from '@nativescript/angular';
33
import { Routes } from '@angular/router';
44
<% if (!skipAutoGeneratedComponent) { %>
55
import { AutoGeneratedComponent } from './auto-generated/auto-generated.component';

src/add-ns/_ns-files/__sourceDir__/main__nsext__.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// this import should be first in order to load some required settings (like globals and reflect-metadata)
2-
import { platformNativeScriptDynamic } from 'nativescript-angular/platform';
2+
import { platformNativeScriptDynamic } from '@nativescript/angular/platform';
33

44
import { <%= entryModuleClassName %> } from '<%= entryModuleImportPath %>';
55

src/add-ns/_ns-files/ngcc.config.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
module.exports = {
2+
packages: {
3+
"@nativescript/angular": {
4+
entryPoints: {
5+
".": {
6+
override: {
7+
main: "./index.js",
8+
typings: "./index.d.ts",
9+
},
10+
ignoreMissingDependencies: true,
11+
}
12+
},
13+
ignorableDeepImportMatchers: [
14+
/tns-core-modules\//,
15+
/@nativescript\/core\//,
16+
]
17+
}
18+
}
19+
};

src/add-ns/_ns-files/tsconfig__nsext__.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"extends": "./tsconfig.json",
33
"compilerOptions": {
4-
"module": "es2015",
4+
"module": "ESNext",
55
"moduleResolution": "node",
66
"skipLibCheck": true,
77
"paths": {

src/add-ns/_sample-files/barcelona/barcelona.module__nsext__.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { NgModule, NO_ERRORS_SCHEMA } from '@angular/core';
2-
import { NativeScriptCommonModule } from 'nativescript-angular/common';
3-
import { NativeScriptRouterModule } from 'nativescript-angular/router';
2+
import { NativeScriptCommonModule, NativeScriptRouterModule } from '@nativescript/angular';
43

54
import {
65
componentDeclarations,
@@ -11,7 +10,6 @@ import {
1110
@NgModule({
1211
imports: [
1312
NativeScriptCommonModule,
14-
NativeScriptRouterModule,
1513
NativeScriptRouterModule.forRoot(routes)
1614
],
1715
exports: [

src/add-ns/index.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -223,10 +223,12 @@ const addRunScriptsToPackageJson = (tree: Tree, context: SchematicContext) => {
223223
const packageJson = getPackageJson(tree);
224224

225225
const scriptsToAdd = {
226-
android: 'tns run android',
227-
ios: 'tns run ios',
226+
android: 'tns run android --env.aot',
227+
ios: 'tns run ios --env.aot',
228228
mobile: 'tns run',
229229
preview: 'tns preview',
230+
ngcc: 'ngcc --properties es2015 module main --first-only',
231+
postinstall: 'npm run ngcc'
230232
};
231233
packageJson.scripts = {...scriptsToAdd, ...packageJson.scripts};
232234

@@ -362,17 +364,17 @@ const addDependencies = () => (tree: Tree, context: SchematicContext) => {
362364

363365
// @UPGRADE: Update all versions whenever {N} version updates
364366
const depsToAdd = {
365-
'nativescript-angular': '~8.20.0',
367+
'@nativescript/angular': '~9.0.0',
368+
'@nativescript/core': '~6.5.5',
366369
'@nativescript/theme': '~2.2.1',
367370
'reflect-metadata': '~0.1.12',
368-
'tns-core-modules': '~6.3.0',
369371
'tslib': '1.10.0',
370372
};
371373
packageJson.dependencies = {...depsToAdd, ...packageJson.dependencies};
372374

373375
const devDepsToAdd = {
374-
'nativescript-dev-webpack': '~1.4.0',
375-
'@nativescript/schematics': '~1.0.0',
376+
'nativescript-dev-webpack': '~1.5.0',
377+
'@nativescript/schematics': '~2.0.0',
376378
'@nativescript/tslint-rules': '~0.0.5',
377379
};
378380
packageJson.devDependencies = {...devDepsToAdd, ...packageJson.devDependencies};

src/add-ns/index_spec.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { getFileContent } from '@schematics/angular/utility/test';
88

99
describe('Add {N} schematic', () => {
1010
const schematicRunner = new SchematicTestRunner(
11-
'nativescript-schematics',
11+
'@nativescript/schematics',
1212
resolve(__dirname, '../collection.json'),
1313
);
1414
const project = 'foo';
@@ -44,6 +44,7 @@ describe('Add {N} schematic', () => {
4444
it('should add {N} specific files', () => {
4545
const files = appTree.files;
4646

47+
expect(files).toContain('/ngcc.config.js');
4748
expect(files).toContain('/nsconfig.json');
4849
expect(files).toContain('/tsconfig.tns.json');
4950
expect(files).toContain('/src/app.css');
@@ -77,9 +78,9 @@ describe('Add {N} schematic', () => {
7778
const packageJson = JSON.parse(getFileContent(appTree, packageJsonPath));
7879
const { dependencies, devDependencies } = packageJson;
7980
expect(dependencies).toBeDefined();
80-
expect(dependencies['nativescript-angular']).toBeDefined();
81+
expect(dependencies['@nativescript/angular']).toBeDefined();
8182
expect(dependencies['@nativescript/theme']).toBeDefined();
82-
expect(dependencies['tns-core-modules']).toBeDefined();
83+
expect(dependencies['@nativescript/core']).toBeDefined();
8384
expect(dependencies['reflect-metadata']).toBeDefined();
8485

8586
expect(devDependencies['nativescript-dev-webpack']).toBeDefined();
@@ -94,8 +95,10 @@ describe('Add {N} schematic', () => {
9495
const packageJson = JSON.parse(getFileContent(appTree, packageJsonPath));
9596
const { scripts } = packageJson;
9697
expect(scripts).toBeDefined();
97-
expect(scripts.android).toEqual('tns run android');
98-
expect(scripts.ios).toEqual('tns run ios');
98+
expect(scripts.android).toEqual('tns run android --env.aot');
99+
expect(scripts.ios).toEqual('tns run ios --env.aot');
100+
expect(scripts.ngcc).toEqual('ngcc --properties es2015 module main --first-only');
101+
expect(scripts.postinstall).toEqual('npm run ngcc');
99102
});
100103

101104
it('should add NativeScript key to the package json', () => {

0 commit comments

Comments
 (0)