angular: [Ivy -@9.0.0-rc.1 & -@9.0.0-rc.2] `ngcc` fails to compilate NativeScript-Angular package with error: "Error: Error on worker #3: RangeError: Maximum call stack size exceeded"
π bug report
Affected Package
@nativescript/angular
. This is the main package that contains the implementation that allows Angular to run in NativeScript.
Is this a regression?
No, because Ivy is a feature that we want to allow the users of NativeScript to benefit from.
Description
Currently we want to build the @nativescript/angular
package with ngc
(in order to support View engine) and want to make sure that the package is also correctly processed by ngcc
(in order to support Ivy)
π¬ Minimal Reproduction
As this is yet not merged and release because 9.0.0 is still not available officially. You cna observe the issue in a branch of @nativescript/angular
. Here is a show setup:
- Clone
git clone https://github.com/NativeScript/nativescript-angular.git
cd nativescript-angular
git checkout amiorkov/ivy
- From the root of the repo execute
cd nativescript-angular && npm i && npm run pack
(this will build the@nativescript/angular
package, make it into a .tgz and place it in adist
directory of the repo) - From the root of the repo execute
cd nativescript-angular-package && npm i && npm run pack-with-scoped-version /Users/amiorkov/Desktop/Work/nativescript-angular/dist/nativescript-angular-scoped.tgz
(this will create thenativescript-angular
package that uses the previously build@nativescript/angular
package as a dependency. Replace the path to thenativescript-angular-scoped.tgz
that is after thenpm run pack-with-scoped-version <path-to-scoped-tgz>
script)
After this you can proceed with running ngcc in the Test app (e2e/ivy-sample) (cd e2e/ivy-sample/ && npm i && ./node_modules/.bin/ngcc
)
Test app
- From root of repo
cd e2e/ivy-sample && npm i && ./node_modules/.bin/ngcc && tns run ios
- We would like to use a symlink in this app for thenativescript-angular
package. Can we makengcc
work with symlinked packages (the code that ngcc needs to compile is nested in an innternode_modules
)
π₯ Exception or Error
mcsofamiorkov:ivy-sample amiorkov$ ./node_modules/.bin/ngcc
Warning: Entry point '@nativescript/angular' contains deep imports into '/Users/amiorkov/Desktop/Work/nativescript-angular/e2e/ivy-sample/node_modules/tns-core-modules/ui/layouts/layout-base'. This is probably not a problem, but may cause the compilation of entry points to be out of order.
Compiling @nativescript/angular : main as commonjs
Error: Error on worker #3: RangeError: Maximum call stack size exceeded
at visitNode (/Users/amiorkov/Desktop/Work/nativescript-angular/e2e/ivy-sample/node_modules/typescript/lib/typescript.js:17006:23)
at Object.forEachChild (/Users/amiorkov/Desktop/Work/nativescript-angular/e2e/ivy-sample/node_modules/typescript/lib/typescript.js:17139:24)
at NodeObject.forEachChild (/Users/amiorkov/Desktop/Work/nativescript-angular/e2e/ivy-sample/node_modules/typescript/lib/typescript.js:124873:23)
at CommonJsReflectionHost.Esm2015ReflectionHost.findDecoratedVariableValue (/Users/amiorkov/Desktop/Work/nativescript-angular/e2e/ivy-sample/node_modules/@angular/compiler-cli/ngcc/src/host/esm2015_host.js:605:25)
at /Users/amiorkov/Desktop/Work/nativescript-angular/e2e/ivy-sample/node_modules/@angular/compiler-cli/ngcc/src/host/esm2015_host.js:605:69
at visitNodes (/Users/amiorkov/Desktop/Work/nativescript-angular/e2e/ivy-sample/node_modules/typescript/lib/typescript.js:17016:30)
at Object.forEachChild (/Users/amiorkov/Desktop/Work/nativescript-angular/e2e/ivy-sample/node_modules/typescript/lib/typescript.js:17140:21)
at NodeObject.forEachChild (/Users/amiorkov/Desktop/Work/nativescript-angular/e2e/ivy-sample/node_modules/typescript/lib/typescript.js:124873:23)
at CommonJsReflectionHost.Esm2015ReflectionHost.findDecoratedVariableValue (/Users/amiorkov/Desktop/Work/nativescript-angular/e2e/ivy-sample/node_modules/@angular/compiler-cli/ngcc/src/host/esm2015_host.js:605:25)
at /Users/amiorkov/Desktop/Work/nativescript-angular/e2e/ivy-sample/node_modules/@angular/compiler-cli/ngcc/src/host/esm2015_host.js:605:69
at ClusterMaster.onWorkerMessage (/Users/amiorkov/Desktop/Work/nativescript-angular/e2e/ivy-sample/node_modules/@angular/compiler-cli/ngcc/src/execution/cluster/master.js:158:27)
at /Users/amiorkov/Desktop/Work/nativescript-angular/e2e/ivy-sample/node_modules/@angular/compiler-cli/ngcc/src/execution/cluster/master.js:46:95
at ClusterMaster.<anonymous> (/Users/amiorkov/Desktop/Work/nativescript-angular/e2e/ivy-sample/node_modules/@angular/compiler-cli/ngcc/src/execution/cluster/master.js:238:57)
at step (/Users/amiorkov/Desktop/Work/nativescript-angular/e2e/ivy-sample/node_modules/tslib/tslib.js:136:27)
at Object.next (/Users/amiorkov/Desktop/Work/nativescript-angular/e2e/ivy-sample/node_modules/tslib/tslib.js:117:57)
at /Users/amiorkov/Desktop/Work/nativescript-angular/e2e/ivy-sample/node_modules/tslib/tslib.js:110:75
at new Promise (<anonymous>)
at Object.__awaiter (/Users/amiorkov/Desktop/Work/nativescript-angular/e2e/ivy-sample/node_modules/tslib/tslib.js:106:16)
at EventEmitter.<anonymous> (/Users/amiorkov/Desktop/Work/nativescript-angular/e2e/ivy-sample/node_modules/@angular/compiler-cli/ngcc/src/execution/cluster/master.js:232:32)
at EventEmitter.emit (events.js:189:13)
π Your Environment
Angular Version:
Angular CLI: 9.0.0-rc.1
Node: 10.15.2
OS: darwin x64
Angular: 9.0.0-rc.1
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router
Package Version
------------------------------------------------------
@angular-devkit/architect 0.900.0-rc.1 (cli-only)
@angular-devkit/core 9.0.0-rc.1
@angular-devkit/schematics 9.0.0-rc.1 (cli-only)
@ngtools/webpack 9.0.0-rc.1
@schematics/angular 9.0.0-rc.1 (cli-only)
@schematics/update 0.900.0-rc.1 (cli-only)
rxjs 6.5.3
typescript 3.6.4
webpack 4.27.1
Anything else relevant?
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 4
- Comments: 20 (9 by maintainers)
Commits related to this issue
- fix(ivy): avoid infinite recursion when evaluation source files When ngtsc comes across a source file during partial evaluation, it would determine all exported symbols from that module and evaluate ... — committed to JoostK/angular by JoostK 5 years ago
- fix(ivy): avoid infinite recursion when evaluation source files When ngtsc comes across a source file during partial evaluation, it would determine all exported symbols from that module and evaluate ... — committed to JoostK/angular by JoostK 5 years ago
- fix(ivy): avoid infinite recursion when evaluation source files When ngtsc comes across a source file during partial evaluation, it would determine all exported symbols from that module and evaluate ... — committed to gkalpak/angular by JoostK 5 years ago
- fix(ivy): avoid infinite recursion when evaluation source files When ngtsc comes across a source file during partial evaluation, it would determine all exported symbols from that module and evaluate ... — committed to gkalpak/angular by JoostK 5 years ago
- fix(ivy): avoid infinite recursion when evaluation source files (#33772) When ngtsc comes across a source file during partial evaluation, it would determine all exported symbols from that module and ... — committed to angular/angular by JoostK 5 years ago
Hi @gkalpak ,
Thank you for all of our efforts and support on this. If the you have managed to run ngcc over the packages of the ivy-sample (which includes nativescript-angular) all should be good for the app to run.
I am tagging @vakrilov to proceed with the Ivy implementation in NativeScript.
It turns out that ngcc cannot recognize
__spreadArrays()
, because the packages are compiled withnoEmitHelpers: true
(so TypeScript does not emit the implementation of helpers such as__spreadArray()
), but also withoutimportHelpers: true
(so the helpers are not imported either). I donβt know if you have a custom way to provide the helpers, but ngcc cannot recognize them if they are not imported.By changing nativescript-angular/tsconfig.json from
"noEmitHelpers": true
to"importHelpers": true
and addingtslib
as a dependency in e2e/ivy-sample/package.json, I was able to solve the problem.Now, there is another problem, where ngcc cannot recognize the following as an array:
So, I am looking into that now.
Yeah, the metadata files are there. In the compiled
common.js
file, the declarations look like this:declarations: __spreadArrays([dialogs_1.ModalDialogHost], directives_1.NS_DIRECTIVES)
So, it looks like
__spreadArrays()
is what throws ngcc off. Looks like an ngcc issue. Iβll look into it and let you know.Thx, Iβll give it another try. (BTW,
ngcc-validation
uses the latest Angular version from the master branch (with a few hours delay), so it is newer than the latest released version.)Weβve been working with the nativescript team to ensure compatibility with v9 and Ivy.
I believe that they are releasing a new version of NativeScript that has all the necessary fixes. @alxhub can you confirm please?