Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maximum call stack size exceeded for build with Angular CLI

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"
  }
}
like image 992
Sumit Agarwal Avatar asked Aug 04 '17 16:08

Sumit Agarwal


2 Answers

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.

like image 177
Andrew Donovan Avatar answered Oct 23 '22 13:10

Andrew Donovan


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

like image 3
Sumit Agarwal Avatar answered Oct 23 '22 14:10

Sumit Agarwal