Skip to content

Commit 0da4c90

Browse files
committed
chore: WIP for making this plugin follow the Angular Package Format and support Ivy
Steps for testing: - cd nativescript-angular - npm run pack - cd yourProj - npm i your nativescript-angular tgz - install `next` versions of all Angular deps - edit `node_modules/@angular/compiler-cli/src/ngcc/src/packages/dependency_resolver.js` in order to comment out the following code: // This entry point has dependencies that are missing // so remove it from the graph. // removeNodes(entryPoint, Array.from(missing)); <--- this line - enable Ivy in the tsconfig with: "angularCompilerOptions": { "enableIvy": true, "allowEmptyCodegenFiles": true, }, - run ./node_modules/.bin/ivy-ngcc - edit nativescript-angular package.json in order to set `fesm2015/nativescript-angular.js` for both `main` and `module` - edit `fesm2015/nativescript-angular.js` in order to remove the duplicate `_0_Template` - edit `fesm2015/nativescript-angular.js` in order to move import { install } from 'tns-core-modules/globals';install(); on the first line - fix the nativescript-angular imports in your app and the AOT transformer: - 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), - 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 - tns run android/ios --bundle --env.ios
1 parent 9b3a3ba commit 0da4c90

File tree

11 files changed

+1689
-1707
lines changed

11 files changed

+1689
-1707
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ hooks
44
tags
55
**/*.js.map
66
**/*.metadata.json
7-
7+
dist
88
/nativescript-angular/**/*.d.ts
99
/nativescript-angular/**/*.js
1010

nativescript-angular/forms/forms.module.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
CheckedValueAccessor,
66
DateValueAccessor,
77
TimeValueAccessor,
8-
NumberValueAccessor,
8+
NsNumberValueAccessor,
99
SelectedIndexValueAccessor
1010
} from "./value-accessors";
1111

@@ -15,7 +15,7 @@ export const FORMS_DIRECTIVES = [
1515
DateValueAccessor,
1616
TimeValueAccessor,
1717
SelectedIndexValueAccessor,
18-
NumberValueAccessor,
18+
NsNumberValueAccessor,
1919
];
2020

2121
@NgModule({

nativescript-angular/forms/value-accessors/number-value-accessor.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { Slider } from "tns-core-modules/ui/slider";
55

66
const NUMBER_VALUE_ACCESSOR = {
77
provide: NG_VALUE_ACCESSOR,
8-
useExisting: forwardRef(() => NumberValueAccessor),
8+
useExisting: forwardRef(() => NsNumberValueAccessor),
99
multi: true,
1010
};
1111

@@ -27,7 +27,7 @@ const NUMBER_VALUE_ACCESSOR = {
2727
"(valueChange)": "onChange($event.value)",
2828
},
2929
})
30-
export class NumberValueAccessor extends BaseValueAccessor<Slider> { // tslint:disable-line:directive-class-suffix
30+
export class NsNumberValueAccessor extends BaseValueAccessor<Slider> { // tslint:disable-line:directive-class-suffix
3131
constructor(elementRef: ElementRef) {
3232
super(elementRef.nativeElement);
3333
}

nativescript-angular/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { install } from "tns-core-modules/globals";
2+
install();
13
import "tns-core-modules/application";
24

35
export * from "./platform-common";
@@ -15,6 +17,7 @@ export * from "./modal-dialog";
1517
export * from "./renderer";
1618
export * from "./view-util";
1719
export * from "./resource-loader";
20+
export * from "./nativescript.module";
1821

1922
export {
2023
ViewClass,
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// TODO: export nativescript.module for backwards compatibility
2+
const a = 0;
3+
export default a;
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"name": "nativescript-angular/nativescript.module",
3+
"main": "index",
4+
"ngPackage": {
5+
"lib": {
6+
"entryFile": "index.ts"
7+
}
8+
}
9+
}

nativescript-angular/package.json

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
{
22
"name": "nativescript-angular",
33
"version": "7.3.0",
4+
"$schema": "./node_modules/ng-packagr/package.schema.json",
5+
"ngPackage": {
6+
"whitelistedNonPeerDependencies": [
7+
"nativescript-intl",
8+
"reflect-metadata"
9+
],
10+
"lib": {
11+
"entryFile": "index.ts"
12+
}
13+
},
414
"description": "An Angular renderer that lets you build mobile apps with NativeScript.",
515
"homepage": "https://www.nativescript.org/",
616
"bugs": "https://github.com/NativeScript/nativescript-angular/issues",
@@ -28,16 +38,7 @@
2838
"url": "https://github.com/NativeScript/nativescript-angular.git"
2939
},
3040
"scripts": {
31-
"tslint": "tslint --project tsconfig.json --config tslint.json",
32-
"postinstall": "node postinstall.js",
33-
"tsc": "tsc -p tsconfig.json",
34-
"tsc-w": "tsc -p tsconfig.json -w",
35-
"ngc": "ngc -p tsconfig.json",
36-
"prepare": "npm run ngc",
37-
"version": "rm -rf package-lock.json && conventional-changelog -p angular -i ../CHANGELOG.md -s && git add ../CHANGELOG.md"
38-
},
39-
"bin": {
40-
"update-app-ng-deps": "./bin/update-app-ng-deps"
41+
"pack": "ng-packagr -p package.json && cp -rf hooks dist/hooks && cd dist && npm pack"
4142
},
4243
"dependencies": {
4344
"nativescript-intl": "^3.0.0",
@@ -69,10 +70,12 @@
6970
"@angular/platform-browser-dynamic": "~7.2.0",
7071
"@angular/router": "~7.2.0",
7172
"codelyzer": "^4.5.0",
73+
"ng-packagr": "^4.7.1",
7274
"rxjs": "~6.3.3",
7375
"tns-core-modules": "next",
76+
"tsickle": "^0.34.3",
7477
"tslint": "^5.5.0",
7578
"typescript": "~3.1.1",
7679
"zone.js": "^0.8.4"
7780
}
78-
}
81+
}

nativescript-angular/router/router.module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import { NativeScriptCommonModule } from "../common";
1212
import { FrameService } from "../platform-providers";
1313
import { NSEmptyOutletComponent } from "./ns-empty-outlet.component";
1414

15+
export { NSRouterLink } from "./ns-router-link";
16+
export { NSRouterLinkActive } from "./ns-router-link-active";
1517
export { PageRoute } from "./page-router-outlet";
1618
export { RouterExtensions } from "./router-extensions";
1719
export { NSModuleFactoryLoader } from "./ns-module-factory-loader";

nativescript-angular/tsconfig.json

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"compilerOptions": {
3-
"target": "es5",
4-
"module": "commonjs",
3+
"module": "es2015",
4+
"target": "es2015",
55
"moduleResolution": "node",
66
"sourceMap": true,
77
"emitDecoratorMetadata": true,
@@ -13,22 +13,25 @@
1313
"noEmitOnError": true,
1414
"noImplicitAny": false,
1515
"lib": [
16-
"dom",
17-
"es6",
18-
"es2015.iterable"
16+
"dom",
17+
"es6",
18+
"es2015.iterable"
1919
],
2020
"baseUrl": ".",
2121
"paths": {
22-
"*": [
23-
"./node_modules/tns-core-modules/*",
24-
"./node_modules/*"
25-
]
22+
"*": [
23+
"./node_modules/tns-core-modules/*",
24+
"./node_modules/*"
25+
]
2626
}
2727
},
2828
"angularCompilerOptions": {
2929
"genDir": ".",
3030
"skipMetadataEmit": false,
3131
"skipTemplateCodegen": true,
32-
"strictMetadataEmit": true
32+
"annotateForClosureCompiler": true,
33+
"strictMetadataEmit": false,
34+
"flatModuleOutFile": "nativescript-angular.js",
35+
"flatModuleId": "nativescript-angular"
3336
}
34-
}
37+
}

0 commit comments

Comments
 (0)