question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

build --prod RangeError: Maximum call stack size exceeded

See original GitHub issue

Type of Issue

[*] Bug Report
[ ] Feature Request

Description

I have a @aaa/lib-a that can be published to gitLab’s NPM library and imported for use in other projects. When I create a second library @bbb/lib-b and introduce modules from @aaa/lib-a, compilation problems arise:

[error] RangeError: Maximum call stack size exceeded
    at resolveModuleNamesReusingOldState (D:\dev\@bbb\lib-b\node_modules\typescript\lib\typescript.js:105667:24)
    at processImportedModules (D:\dev\@bbb\lib-b\node_modules\typescript\lib\typescript.js:107154:35)
    at findSourceFileWorker (D:\dev\@bbb\lib-b\node_modules\typescript\lib\typescript.js:106926:17)
    at findSourceFile (D:\dev\@bbb\lib-b\node_modules\typescript\lib\typescript.js:106788:26)
    at processImportedModules (D:\dev\@bbb\lib-b\node_modules\typescript\lib\typescript.js:107190:25)
    at findSourceFileWorker (D:\dev\@bbb\lib-b\node_modules\typescript\lib\typescript.js:106926:17)
    at findSourceFile (D:\dev\@bbb\lib-b\node_modules\typescript\lib\typescript.js:106788:26)
    at processImportedModules (D:\dev\@bbb\lib-b\node_modules\typescript\lib\typescript.js:107190:25)
    at findSourceFileWorker (D:\dev\@bbb\lib-b\node_modules\typescript\lib\typescript.js:106926:17)
    at findSourceFile (D:\dev\@bbb\lib-b\node_modules\typescript\lib\typescript.js:106788:26)

The @aaa/lib-a and @bbb/lib-b tsconfig configurations are basically the same

If the tsconfig.lib.prod.json configuration item enableIvy is changed to true, it will compile normally, but cannot be published to NPM:

{
  "extends": "./tsconfig.lib.json",
  "compilerOptions": {
    "declarationMap": false
  },
  "angularCompilerOptions": {
    "enableIvy": true
  }
}

Version Information

$ node_modules/.bin/ng-packagr --version
ng-packagr:            11.2.4
@angular/compiler:     11.2.14
rollup:                2.38.4
typescript:            4.1.6
rxjs: ~6.5.4
node: v14.17.5
npm: 6.14.14

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
staneeecommented, Sep 27, 2021

When I upgraded to angular 12 and modified the tsconfig file, I was fine.

This is my repository: (link)

master branch is angular 11, angular 12 is in ng-12 branch.

I think it is important to set compilationMode in tsconfig.lib.prod.json to partial like this:

{
  "extends": "./tsconfig.lib.json",
  "compilerOptions": {
    "declarationMap": false
  },
  "angularCompilerOptions": {
    "compilationMode": "partial"
  }
}

updated versions:

ng-packagr:            12.2.2
@angular/compiler:     12.2.7
rollup:                2.57.0
typescript:            4.3.5

@alan-agius4

1reaction
staneeecommented, Sep 22, 2021

Actuality, I was wrong and is not a duplicate. Try to update to latest version of Angular and ng-packagr. If the problem persists please provide a minimal reproduction.

There is a time difference between us. I will reply after trying during working hours, tks。

Read more comments on GitHub >

github_iconTop Results From Across the Web

"Maximum call stack size exceeded" in Angular 9 ng build
I introduced a console debug message in function tryLoadModuleUsingPathsIfEligible(extensions, moduleName, loader, state) function and it seems ...
Read more >
Maximum call stack size exceeded after updating @angular ...
After updating `@angular/compiler-cli 9.0.3` during ng serve I receive following error: `ERROR in Maximum call stack size exceeded` ...
Read more >
Angular CLI - Module build failed: RangeError: Maximum call ...
Running "ng build --prod" (uses aot and build-optimizer) causes the following error: ... Module build failed: RangeError: Maximum call stack size exceeded.
Read more >
JavaScript RangeError: Maximum Call Stack Size Exceeded
The JavaScript RangeError: Maximum call stack size exceeded is an error that occurs when there are too many function calls, or if a...
Read more >
Maximum call stack size exceeded – while choosing the ...
Hello, Ravi, Thank you for reporting this issue and for sharing a stackblitz example. It seems the error occurs if all of the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found