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 a dist 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 the nativescript-angular package that uses the previously build @nativescript/angular package as a dependency. Replace the path to the nativescript-angular-scoped.tgz that is after the npm 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 the nativescript-angular package. Can we make ngcc work with symlinked packages (the code that ngcc needs to compile is nested in an innter node_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

Most upvoted comments

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 with noEmitHelpers: true (so TypeScript does not emit the implementation of helpers such as __spreadArray()), but also without importHelpers: 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 adding tslib 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:

exports.FORMS_DIRECTIVES = [
  // Some items...
  ...
];
var NativeScriptFormsModule = /** @class */ (function () {
  function NativeScriptFormsModule() {
  }
  NativeScriptFormsModule = tslib_1.__decorate([
    core_1.NgModule({
      declarations: exports.FORMS_DIRECTIVES,
      ...
    })
  ], NativeScriptFormsModule);
...

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?