Maximum call stack size exceeded for build with Angular CLI
Asked Answered
P

2

5

I have a large project which was till now running on webpack and all was working well with [email protected]. Today I planned to shift the same to ng-cli to exploit features like universal. Everything is working well and good except when i try to build the project in prod/prod+aot i am getting: Maximum call stack size exceeded.

Checked various place for the issue and most of people are telling to check for circular dependency. But as per the latest [email protected] the circular dependency should have been shown build time, which is not the case. I was planning to increase node virtual machine stack size but couldn't figure out to achieve that. I don't want to use ng eject and get into the webpack mess again.

Are there some other approaches or solutions out there with [email protected]

Thanks

package.json

{
  "name": "test-project",
  "version": "0.0.0",
  "license": "MIT",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/common": "~4.3.3",
    "@angular/compiler": "~4.3.3",
    "@angular/core": "~4.3.3",
    "@angular/forms": "~4.3.3",
    "@angular/http": "~4.3.3",
    "@angular/animations": "~4.3.3",
    "@angular/flex-layout": "^2.0.0-beta.8",
    "@angular/material": "^2.0.0-beta.8",
    "@angular/cdk": "^2.0.0-beta.8",
    "@angular/platform-browser": "~4.3.3",
    "@angular/platform-browser-dynamic": "~4.3.3",
    "@angular/platform-server": "~4.3.3",
    "@angular/router": "~4.3.3",
    "angular2-highcharts": "~0.5.5",
    "@types/highcharts": "~4.2.57",
    "angular-2-local-storage" : "^1.0.1",
    "ngx-infinite-scroll": "^0.5.1",
    "jspdf" : "^1.3.3",
    "@types/jspdf" : "^1.1.31",
    "jspdf-autotable" : "^2.3.2",
    "html2canvas": "^0.5.0-beta4",
    "@types/html2canvas": "^0.5.34",
    "core-js": "^2.4.1",
    "jasmine-core": "^2.6.4",
    "reflect-metadata": "^0.1.10",
    "rxjs": "^5.4.1",
    "moment": "^2.18.1",
    "zone.js": "^0.8.14",
    "angular2-jwt" : "^0.2.3",
    "@types/modernizr": "3.3.0"
  },
  "devDependencies": {
    "@angular/language-service": "^4.0.0",
    "@angular/compiler-cli": "~4.3.3",
    "@angular/platform-server": "~4.3.3",
    "@angular/cli": "1.2.7",
    "hammerjs": "^2.0.8",
    "hammer-timejs" : "^1.1.0",
    "@types/hammerjs": "^2.0.34",
    "@types/jasmine": "^2.5.53",
    "@types/jasminewd2": "~2.0.2",
    "@types/node": "~6.0.60",
    "codelyzer": "~3.1.1",
    "jasmine-core": "^2.6.4",
    "jasmine-spec-reporter": "~4.1.0",
    "karma": "^1.7.0",
    "karma-chrome-launcher": "^2.2.0",
    "karma-coverage": "^1.1.1",
    "karma-cli": "~1.0.1",
    "karma-coverage-istanbul-reporter": "^1.2.1",
    "karma-jasmine": "^1.1.0",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "~5.1.2",
    "ts-node": "~3.1.0",
    "tslib": "^1.7.1",
    "tslint": "~5.4.3",
    "typescript": "^2.4.1"
  }
}
Pe answered 4/8, 2017 at 16:40 Comment(3)
chances are you have a Component like a layout page, who is embedding another component which contains that layout page. That was my case for Ionic and their tabs controllerFanchette
Not found anything yet, I have no such dependencies. Checked it numerous times.Pe
My comment was not about dependencies its about Circular References, Meaning you need to check your component code, What is the error in your browser?Fanchette
P
4

Found the solution, had some circular dependencies in my lazy loaded routes and modules.

Pe answered 5/9, 2017 at 7:39 Comment(0)
F
4

Me and my team currently encoutered this issue. I have tried everyting, from removing entirely the usage of barrels within our app (I thought it was a circular dependency issue, as many SO questions led me to believe)

My local environment was working well, but a fresh deployment was having maximum call stack issues.

Upon comparing my node modules, I noticed that zone.js was now at 0.8.17 (0.8.16 before)

I thus forced 0.8.16 in my package.json, and everything worked.. BLAH 8 hours on this !

Hope this helps you.

EDIT

Here is the github issue : https://github.com/angular/zone.js/issues/886

As of now, there is a pull request made to fix this issue.

Florrie answered 29/8, 2017 at 15:24 Comment(0)
P
4

Found the solution, had some circular dependencies in my lazy loaded routes and modules.

Pe answered 5/9, 2017 at 7:39 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.