Angular 12: RangeError: Maximum call stack size exceeded

Issue

I am getting this error when building:

Generating browser application bundles (phase: building).../home/jde/edApp2Angular12/node_modules/webpack/node_modules/webpack-sources/lib/helpers/streamChunksOfSourceMap.js:21
        const lines = source.match(SPLIT_LINES_REGEX);
                             ^

RangeError: Maximum call stack size exceeded
    at String.match (<anonymous>)
    at streamChunksOfSourceMapFull (/home/jde/edApp2Angular12/node_modules/webpack/node_modules/webpack-sources/lib/helpers/streamChunksOfSourceMap.js:21:23)
    at module.exports (/home/jde/edApp2Angular12/node_modules/webpack/node_modules/webpack-sources/lib/helpers/streamChunksOfSourceMap.js:389:6)
    at SourceMapSource.streamChunks (/home/jde/edApp2Angular12/node_modules/webpack/node_modules/webpack-sources/lib/SourceMapSource.js:211:11)
    at module.exports (/home/jde/edApp2Angular12/node_modules/webpack/node_modules/webpack-sources/lib/helpers/streamChunks.js:13:17)
    at ReplaceSource.streamChunks (/home/jde/edApp2Angular12/node_modules/webpack/node_modules/webpack-sources/lib/ReplaceSource.js:176:44)
    at module.exports (/home/jde/edApp2Angular12/node_modules/webpack/node_modules/webpack-sources/lib/helpers/streamChunks.js:13:17)
    at streamAndGetSourceAndMap (/home/jde/edApp2Angular12/node_modules/webpack/node_modules/webpack-sources/lib/helpers/streamAndGetSourceAndMap.js:27:53)
    at CachedSource.streamChunks (/home/jde/edApp2Angular12/node_modules/webpack/node_modules/webpack-sources/lib/CachedSource.js:208:35)
    at module.exports (/home/jde/edApp2Angular12/node_modules/webpack/node_modules/webpack-sources/lib/helpers/streamChunks.js:13:17)

I’ve been looking around for an answer but it seems to always be "You have an infinite loop somewhere in your code". But the output from this error suggests that it comes from webpack and therefore not from a bug I my project.

How do I figure out what is wrong? Where do I go from here?

Angular version: 12.2

Webpack version: 5.47.1

UPDATE: It compiles with aot if I turn off sourcemaps

UPDATE: I am not using Angular 12.1 as first stated. It is actually version 12.2. I can also conclude that I am suffering from this bug: https://github.com/webpack/webpack-sources/issues/131

Solution

A fix for the bug I mentioned has now been released. In v3.2.1 of webpack they have removed the regex causing the trouble. I ran an npm update yesterday, and the error went away.

Answered By – Jette

Answer Checked By – Willingham (AngularFixing Volunteer)

Leave a Reply

Your email address will not be published.