Build prod failed: Maximum call stack size exceeded

Any time, I execute ionic build --prod, I get the following error with my app:

[17:56:57] ionic-app-scripts 1.1.3
[17:56:57] build prod started …
[17:56:57] clean started …
[17:56:57] clean finished in 4 ms
[17:56:57] copy started …
[17:56:57] ngc started …
[17:57:24] ngc finished in 27.14 s
[17:57:24] preprocess started …
[17:57:24] optimization started …
[17:57:26] copy finished in 29.05 s
[17:57:47] optimization finished in 23.13 s
[17:57:47] preprocess finished in 23.13 s
[17:57:47] webpack started …
[18:00:05] webpack finished in 137.72 s
[18:00:05] sass started …
[18:00:05] transpile bundle started …
[18:00:20] build prod failed: Maximum call stack size exceeded
[18:00:20] ionic-app-script task: “build”
[18:00:20] RangeError: Maximum call stack size exceeded
RangeError: Maximum call stack size exceeded
at checkIdentifier (…/node_modules/typescript/lib/typescript.js:25291:33)
at checkExpressionWorker (…/node_modules/typescript/lib/typescript.js:29613:28)
at checkExpression (…/node_modules/typescript/lib/typescript.js:29593:42)
at checkThisExpression (…/node_modules/typescript/lib/typescript.js:25568:39)
at checkExpressionWorker (…/node_modules/typescript/lib/typescript.js:29615:28)
at checkExpression (…/node_modules/typescript/lib/typescript.js:29593:42)
at checkNonNullExpression (…/node_modules/typescript/lib/typescript.js:27027:24)
at checkPropertyAccessExpressionOrQualifiedName (…/node_modules/typescript/lib/typescript.js:27047:24)
at checkPropertyAccessExpression (…/node_modules/typescript/lib/typescript.js:27041:20)
at checkExpressionWorker (…/node_modules/typescript/lib/typescript.js:29636:28)

The dev build is working without problems, but the prod build fails always.

I am using TypeScript version 2.0.9.

Hi, did you find the problem here? I have just started getting this too.

No, I didn’t solve it. But at some time it was simply gone. Probably by just updating to the current Ionic packages (the stable Ionic cli, not the new beta).

Maybe it was enough to delete the node_modules folder, which I had to to for one of the upgrades. But I do not know…

Ok thanks. It only seems to be one (build) machine for us, and not updated to v3 yet, which will be doing very soon).

I’d make sure that your build machine is using the latest app scripts version. (1.3.6 as of now) Problems like this have popped up in earlier versions.

1 Like

After upgrading to Ionic 3 I am getting this problem too. My current workaround is to run the iOS build until it passes. Most often every second attempt works.

I am using pdf.js which is quite large. Webpack runs out of memory while optimizing this file.

I hope it won’t get worse and a fix will be available soon.