Skip to content

Commit 26c0ca2

Browse files
author
vakrilov
committed
docs: descriptions of current problems for ng-team
1 parent 31832e0 commit 26c0ca2

File tree

2 files changed

+66
-20
lines changed

2 files changed

+66
-20
lines changed

build-for-ivy.md

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,50 @@ resolve: {
4141

4242
- Currently the ./bin scripts are not packed in the npm package
4343
- Zone.js distribution is modified to be TS compilable
44-
- There are no secondary (ex. `nativescript-angular/router`) entry points for `nativescript-angular`, which is a breaking change
44+
- There are no secondary (ex. `nativescript-angular/router`) entry points for `nativescript-angular`, which is a breaking change
45+
46+
47+
## Questions for Angular Team
48+
49+
### 1. CommonJS Support
50+
No support for commonJS currently. The `nativescript-angular` package is not picked up by the compatibility compiler (`ivy-ngcc`)
51+
52+
**Note:** We noticed that `ngcc` reads the entry-point based on `package.json` files. In the `nativescript-angular`package there are many files that can be imported directly ex. `nativescript-angular/router` or `nativescript-angular/modal-dialog` which are not separate modules and don't have a dedicated `package.json` file describing them. Is there a way to make sure **all** files in an npm package are traversed by `ngcc` when it starts to support commonjs?
53+
54+
### 2. Platform-specific Files in NGCC Resolver
55+
We tried to pack `nativescript-angular` with `ng-packger`. However, our main entry point gets ignored by the `ngcc`. The reason - it includes `tns-core-modules\application` which is plat-specific file (has `application.andorid.js` and `application.ios.js`). The `ngcc` could not resolve the import and decides to skip tha package. We patched it by commenting this line (just for the sake of spike): https://github.com/angular/angular/blob/41737bb4d3489bbfe1d2631cc1a7e9f4a732b8ff/packages/compiler-cli/ngcc/src/packages/dependency_resolver.ts#L117.
56+
We probably need to be able to pass in custom resolver that can understand `.[android/ios].js` extension as this is a common way for defining platform-specific files in NativeScript.
57+
58+
59+
### 3. Generated Compat Code Imports
60+
Running `ivy-ngcc` adds two imports at the start of the file:
61+
62+
```
63+
import * as ɵngcc0 from '@angular/core';
64+
import * as ɵngcc1 from '@angular/common';
65+
66+
import 'tns-core-modules/globals';
67+
```
68+
However, importing `@angular/core` before `tns-core-modules/globals` (the first import in the file) causes the following runtime crash: `ReferenceError: Can't find variable: setTimeout`. This is because `setTimeout` is defined in the global scope by `tns-core-modules/globals`. We traced the usage of `setTimeout` to here: https://github.com/angular/angular/blob/41737bb4d3489bbfe1d2631cc1a7e9f4a732b8ff/packages/core/src/render3/util/misc_utils.ts#L39-L42
69+
We have couple of suggestions to resolve this:
70+
71+
1. Add the generated `ɵngcc0` imports after all other imports in the file. This will assure that side-effects introduced by imports are handled the same way before and after the file is converted by the `ngcc`.
72+
2. Have the `defaultScheduler` initialized when first needed or injected by the platform.
73+
74+
75+
### 4. Generated Compat Function With Duplicating Name
76+
`ivy-ngcc` generate the following code just after import statements:
77+
```
78+
const _c0 = ["loader", ""];
79+
const _c1 = [];
80+
const _c2 = [4, "ngIf"];
81+
function _0_Template(rf, ctx) { if (rf & 1) {
82+
ɵngcc0.ɵprojection(0, 0, ["*ngIf", "show"]);
83+
} }
84+
function _0_Template(rf, ctx) { if (rf & 1) {
85+
ɵngcc0.ɵprojection(0, 0, ["*ngIf", "show"]);
86+
} }
87+
const _c3 = ["isEmptyOutlet", "true"];
88+
```
89+
90+
The function `_0_Template` is duplicated. This happens when compiling the templates for this file: https://github.com/NativeScript/nativescript-angular/blob/master/nativescript-angular/directives/platform-filters.ts . We tried splitting the file into two separate component and changing the templates to be different, but the generated code remains the same. Seems like a bug in the `ngcc`

nativescript-angular/package.json

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -45,37 +45,37 @@
4545
"reflect-metadata": "^0.1.8"
4646
},
4747
"peerDependencies": {
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",
48+
"@angular/platform-browser-dynamic": "8.0.0-beta.8",
49+
"@angular/common": "8.0.0-beta.9",
50+
"@angular/compiler": "8.0.0-beta.9",
51+
"@angular/core": "8.0.0-beta.9",
52+
"@angular/forms": "8.0.0-beta.9",
53+
"@angular/http": "8.0.0-beta.9",
54+
"@angular/platform-browser": "8.0.0-beta.9",
55+
"@angular/router": "8.0.0-beta.9",
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": "~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",
62+
"@angular/animations": "8.0.0-beta.9",
63+
"@angular/common": "8.0.0-beta.9",
64+
"@angular/compiler": "8.0.0-beta.9",
65+
"@angular/compiler-cli": "8.0.0-beta.9",
66+
"@angular/core": "8.0.0-beta.9",
67+
"@angular/forms": "8.0.0-beta.9",
68+
"@angular/http": "8.0.0-beta.9",
69+
"@angular/platform-browser": "8.0.0-beta.9",
70+
"@angular/platform-browser-dynamic": "8.0.0-beta.9",
71+
"@angular/router": "8.0.0-beta.9",
7272
"codelyzer": "^4.5.0",
7373
"ng-packagr": "^4.7.1",
7474
"rxjs": "~6.3.3",
7575
"tns-core-modules": "next",
7676
"tsickle": "^0.34.3",
7777
"tslint": "^5.5.0",
78-
"typescript": "~3.1.1",
78+
"typescript": "~3.3.4000",
7979
"zone.js": "^0.8.4"
8080
}
8181
}

0 commit comments

Comments
 (0)