question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItΒ collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[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"

See original GitHub issue

🐞 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?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:4
  • Comments:20 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
VladimirAmiorkovcommented, Nov 28, 2019

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.

1reaction
gkalpakcommented, Nov 21, 2019

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Angular 9 - NGCC fails with an unhandled exception
Building the application after having upgraded dependencies to Angular 9 (and having performed the necessary code changes) throws an error ...
Read more >
RangeError: Maximum call stack size exceeded Angular 7 and ...
I have my app.component who start at the beginning of the project, in that component I call in the constructor all the scripts...
Read more >
How to fix npm maximum call stack size exceeded error
The detail of the error may vary inside your npm-debug.log file, but this error is commonly caused by npm unable to complete a...
Read more >
We really love Angular...10x as much this time
The NativeScript team is dedicated to Angular and truly love building apps with it. We are excited to bring Angular 10 support and...
Read more >
got RangeError: Maximum call stack size exceeded-angular.js
score:0. Accepted answer. Author updated the code to fix this, so the error gone and android app now works correct. Dimanoid 6709. Source:...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found