Skip to content

Commit ce75ea2

Browse files
author
vakrilov
committed
feat: ng-packager imporvements
1 parent 0da4c90 commit ce75ea2

File tree

10 files changed

+112
-65
lines changed

10 files changed

+112
-65
lines changed

build-for-ivy.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
Steps for testing:
2+
3+
- cd nativescript-angular
4+
- npm run pack
5+
- cd yourProj
6+
- npm i your nativescript-angular tgz (NOTE: tgz is in the `dist` folder)
7+
- install `next` versions of all Angular deps
8+
- edit `node_modules/@angular/compiler-cli/src/ngcc/src/packages/dependency_resolver.js` in order to comment out the following code:
9+
// This entry point has dependencies that are missing
10+
// so remove it from the graph.
11+
// removeNodes(entryPoint, Array.from(missing)); <--- this line
12+
13+
- enable Ivy in the tsconfig with:
14+
"angularCompilerOptions": {
15+
"enableIvy": true,
16+
"allowEmptyCodegenFiles": true,
17+
},
18+
- run ./node_modules/.bin/ivy-ngcc
19+
20+
- configure webpack to read `fesm2015` entry-points whem loading package.json:
21+
```
22+
resolve: {
23+
extensions: ....
24+
// ....
25+
mainFields: ['fesm2015', 'module', 'main']
26+
},
27+
```
28+
29+
- edit `fesm2015/nativescript-angular.js` in order to remove the duplicate `_0_Template`
30+
- edit `fesm2015/nativescript-angular.js` in order to move `import 'tns-core-modules/globals'` on the first line (before `import * as ɵngcc0 from '@angular/core';`)
31+
32+
- fix the nativescript-angular imports in your app and the AOT transformer:
33+
- edit `/Users/tachev/Work/Test/ngIvy/node_modules/nativescript-dev-webpack/transformers/ns-replace-bootstrap.js` and set ...transformers_1.insertStarImport(sourceFile, idPlatformNativeScript, 'nativescript-angular', firstNode, true),
34+
- edit your main.ts, app.module.ts and everywhere else in your app in order to import from `nativescript-angular'` instead of the deep imports
35+
36+
- tns run android/ios --bundle --env.aot
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { Component, Inject } from "@angular/core";
2+
import { Device, platformNames } from "tns-core-modules/platform";
3+
import { DEVICE } from "../platform-providers";
4+
5+
@Component({
6+
selector: "android",
7+
template: `<ng-content *ngIf="show"></ng-content>`,
8+
})
9+
export class AndroidFilterComponent {
10+
public show: boolean;
11+
constructor( @Inject(DEVICE) device: Device) {
12+
this.show = (device.os === platformNames.android);
13+
}
14+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { Component, Inject } from "@angular/core";
2+
import { Device, platformNames } from "tns-core-modules/platform";
3+
import { DEVICE } from "../platform-providers";
4+
5+
@Component({
6+
selector: "ios",
7+
template: `<ng-content *ngIf="show"></ng-content>`,
8+
})
9+
export class IosFilterComponent {
10+
public show: boolean;
11+
constructor( @Inject(DEVICE) device: Device) {
12+
this.show = (device.os === platformNames.ios);
13+
}
14+
}
Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,2 @@
1-
import { Component, Inject } from "@angular/core";
2-
import { Device, platformNames } from "tns-core-modules/platform";
3-
import { DEVICE } from "../platform-providers";
4-
5-
@Component({
6-
selector: "android",
7-
template: `<ng-content *ngIf="show"></ng-content>`,
8-
})
9-
export class AndroidFilterComponent {
10-
public show: boolean;
11-
constructor( @Inject(DEVICE) device: Device) {
12-
this.show = (device.os === platformNames.android);
13-
}
14-
}
15-
16-
@Component({
17-
selector: "ios",
18-
template: `<ng-content *ngIf="show"></ng-content>`,
19-
})
20-
export class IosFilterComponent {
21-
public show: boolean;
22-
constructor( @Inject(DEVICE) device: Device) {
23-
this.show = (device.os === platformNames.ios);
24-
}
25-
}
1+
export { AndroidFilterComponent } from "./platform-filter-android";
2+
export { IosFilterComponent } from "./platform-filter-ios";

nativescript-angular/forms/forms.module.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,15 @@ export const FORMS_DIRECTIVES = [
1818
NsNumberValueAccessor,
1919
];
2020

21+
export {
22+
TextValueAccessor,
23+
CheckedValueAccessor,
24+
DateValueAccessor,
25+
TimeValueAccessor,
26+
NsNumberValueAccessor,
27+
SelectedIndexValueAccessor
28+
} from "./value-accessors";
29+
2130
@NgModule({
2231
declarations: FORMS_DIRECTIVES,
2332
providers: [

nativescript-angular/index.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
import { install } from "tns-core-modules/globals";
2-
install();
3-
import "tns-core-modules/application";
1+
import "./init-globals";
42

53
export * from "./platform-common";
64
export * from "./platform";

nativescript-angular/init-globals.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Initial imports and polyfills
2+
import "tns-core-modules/globals";
3+
4+
// Require application early to work around a circular import
5+
import "tns-core-modules/application";
6+
7+
// Require zone to patch timers
8+
import "./zone-js/dist/zone-nativescript";
9+
import "./polyfills/array";
10+
import "./polyfills/console";
11+
12+
// This should come last as it import @angular
13+
import "./dom-adapter";

nativescript-angular/nativescript.module.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
import "tns-core-modules/globals";
2-
// Require application early to work around a circular import
3-
import "tns-core-modules/application";
4-
import "./zone-js/dist/zone-nativescript";
5-
6-
import "./polyfills/array";
7-
import "./polyfills/console";
8-
91
import {
102
ApplicationModule,
113
ErrorHandler,

nativescript-angular/package.json

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nativescript-angular",
3-
"version": "7.3.0",
3+
"version": "8.0.0",
44
"$schema": "./node_modules/ng-packagr/package.schema.json",
55
"ngPackage": {
66
"whitelistedNonPeerDependencies": [
@@ -38,37 +38,37 @@
3838
"url": "https://github.com/NativeScript/nativescript-angular.git"
3939
},
4040
"scripts": {
41-
"pack": "ng-packagr -p package.json && cp -rf hooks dist/hooks && cd dist && npm pack"
41+
"pack": "rm -rf dist && tsc && ng-packagr -p package.json && cp -rf hooks dist/hooks && cd dist && npm pack"
4242
},
4343
"dependencies": {
4444
"nativescript-intl": "^3.0.0",
4545
"reflect-metadata": "^0.1.8"
4646
},
4747
"peerDependencies": {
48-
"@angular/platform-browser-dynamic": "~7.2.0",
49-
"@angular/common": "~7.2.0",
50-
"@angular/compiler": "~7.2.0",
51-
"@angular/core": "~7.2.0",
52-
"@angular/forms": "~7.2.0",
53-
"@angular/http": "~7.2.0",
54-
"@angular/platform-browser": "~7.2.0",
55-
"@angular/router": "~7.2.0",
48+
"@angular/platform-browser-dynamic": "~8.0.0-beta.7",
49+
"@angular/common": "~8.0.0-beta.7",
50+
"@angular/compiler": "~8.0.0-beta.7",
51+
"@angular/core": "~8.0.0-beta.7",
52+
"@angular/forms": "~8.0.0-beta.7",
53+
"@angular/http": "~8.0.0-beta.7",
54+
"@angular/platform-browser": "~8.0.0-beta.7",
55+
"@angular/router": "~8.0.0-beta.7",
5656
"rxjs": "^6.3.3",
5757
"tns-core-modules": "^5.1.0 || >5.1.0- || >5.2.0-",
5858
"typescript": "~3.1.1",
5959
"zone.js": "^0.8.4"
6060
},
6161
"devDependencies": {
62-
"@angular/animations": "~7.2.0",
63-
"@angular/common": "~7.2.0",
64-
"@angular/compiler": "~7.2.0",
65-
"@angular/compiler-cli": "~7.2.0",
66-
"@angular/core": "~7.2.0",
67-
"@angular/forms": "~7.2.0",
68-
"@angular/http": "~7.2.0",
69-
"@angular/platform-browser": "~7.2.0",
70-
"@angular/platform-browser-dynamic": "~7.2.0",
71-
"@angular/router": "~7.2.0",
62+
"@angular/animations": "~8.0.0-beta.7",
63+
"@angular/common": "~8.0.0-beta.7",
64+
"@angular/compiler": "~8.0.0-beta.7",
65+
"@angular/compiler-cli": "~8.0.0-beta.7",
66+
"@angular/core": "~8.0.0-beta.7",
67+
"@angular/forms": "~8.0.0-beta.7",
68+
"@angular/http": "~8.0.0-beta.7",
69+
"@angular/platform-browser": "~8.0.0-beta.7",
70+
"@angular/platform-browser-dynamic": "~8.0.0-beta.7",
71+
"@angular/router": "~8.0.0-beta.7",
7272
"codelyzer": "^4.5.0",
7373
"ng-packagr": "^4.7.1",
7474
"rxjs": "~6.3.3",
@@ -78,4 +78,4 @@
7878
"typescript": "~3.1.1",
7979
"zone.js": "^0.8.4"
8080
}
81-
}
81+
}

nativescript-angular/platform-common.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
1-
// Initial imports and polyfills
2-
import "tns-core-modules/globals";
3-
// Require application early to work around a circular import
4-
import "tns-core-modules/application";
5-
import "./zone-js/dist/zone-nativescript";
6-
import "./polyfills/array";
7-
import "./polyfills/console";
1+
2+
import "./init-globals";
83
import { profile, uptime } from "tns-core-modules/profiling";
9-
import "./dom-adapter";
104

115
import {
126
Type,

0 commit comments

Comments
 (0)