angular: [Angular 9.0.4] Building throws `ERROR in Error when flattening the source-map "[...].d.ts.map" for "[...].d.ts": Maximum call stack size exceeded`

šŸž bug report

Affected Package

Probably @angular/cli, but I was asked to open the issue here.

Is this a regression?

Yes. The issue does not occur with Angular 9.0.2. Version 9.0.3 causes a different RangeError: Maximum call stack size exceeded error, tracked here: https://github.com/angular/angular-cli/issues/17106.

Description

Building and serving both fail consistently with a bunch of the following messages:

ERROR in Error when flattening the source-map "[/path/to/file1].d.ts.map" for "[/path/to/file1].d.ts": RangeError: Maximum call stack size exceeded
ERROR in Error when flattening the source-map "[/path/to/file2].d.ts.map" for "[/path/to/file2].d.ts": RangeError: Maximum call stack size exceeded
...
ERROR in Error when flattening the source-map "[/path/to/fileN].d.ts.map" for "[/path/to/fileN].d.ts": RangeError: Maximum call stack size exceeded

The issue seems similar to the above mentioned one and deleting node_modules does not fix it.

My setup is an Angular workspace with two projects: an app and a lib. The source-maps being ā€œflattenedā€ when the error occurs belong to the lib. The error occurs when attempting to build (--prod or otherwise) or serve the app.

šŸŒ Your Environment

Angular Version:

Angular CLI: 9.0.4
Node: 13.9.0
OS: linux x64

Angular: 9.0.4
... animations, cli, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router
Ivy Workspace: Yes

Package                            Version
------------------------------------------------------------
@angular-devkit/architect          0.900.4
@angular-devkit/build-angular      0.900.4
@angular-devkit/build-ng-packagr   0.900.4
@angular-devkit/build-optimizer    0.900.4
@angular-devkit/build-webpack      0.900.4
@angular-devkit/core               9.0.4
@angular-devkit/schematics         9.0.4
@angular/cdk                       9.1.0
@ngtools/webpack                   9.0.4
@schematics/angular                9.0.4
@schematics/update                 0.900.4
ng-packagr                         9.0.2
rxjs                               6.5.4
typescript                         3.7.5
webpack                            4.41.2

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 13
  • Comments: 35 (7 by maintainers)

Commits related to this issue

Most upvoted comments

I was getting this after an upgrade from 9.0.2 -> 9.0.4. Deleting node_modules didnā€™t fix it, but deleting both node_modules and dist folders then npm ci and rebuild/re-serve did the trick.

Iā€™ve got a slightly odd layout, a framework workspace and a separate application workspace that uses tsconfig.json paths to reference the framework packages out of their built dist folders.

with angular 9, there is a incremental build process which is in the /dist folder.

I had the same problem. I removed my dist and package-lock.json and then ran npm install and all seems to be well now.

I donā€™t understand, I donā€™t have the error anymore on my local computer (windows), but on my gitlab ci job (docker and linux), I am getting this:

ERROR in Error when flattening the source-map ā€œ/builds/applications/frontsxxxx/node_modules/ngx-window-token/ngx-window-token.d.ts.mapā€ for ā€œ/builds/applications/fronts/xxxx/node_modules/ngx-window-token/ngx-window-token.d.tsā€: RangeError: Maximum call stack size exceeded

EDIT: Ok I have found out. I had to delete all the cache created by gitlab runner to have this working !

I could reproduce what I reported consistently even after removing node_modules. However, after removing my dist folder (generated when building the lib), I can no longer reproduce the issue, even across rebuilds.

This is odd because I believe that Angular shouldnā€™t even be looking at that folder, but that might be a different issue.

Iā€™ll close this for now since I can no longer reproduce the issue, but feel free to reopen it if others can reproduce it more consistently. Iā€™ll also open a new issue describing what I mean by ā€œAngular shouldnā€™t be looking at that folderā€ (which Iā€™ve now realised is causing an annoying error).

Having the same issue updating today. Removing the dist folder fixed the problem. Now I ā€œjustā€ have to tell everyone who will get the update commit šŸ˜

My build just failed in Azure DevOps, just as @mattiaskagstrom stated. Going to have to rollback this changeset. It built fine locally.

Weā€™re using docker, both locally and in the cloud.

@adamdport šŸ˜Š personally none of that worked for me, what fixed it was updating terser library to latest, but it doesnā€™t have to work for you, so my guide is: grab the code and slam it against the wall a couple of times, what sticks, fix it :p