title: "Maximum call stack size exceeded" in Angular 9 ng build --prod for a library
body: <p>I have a library that I'm able to compile with Angular 9. But if I change the flag to --prod, which practically makes <code>&quot;enableIvy&quot;: false</code> then I get</p>
  <blockquote>
  <p>[error] RangeError: Maximum call stack size exceeded</p>
  <p>at Object.pathIsRelative (...\node_modules\typescript\lib\typescript.js:5778:34)</p>
  <p>at tryLoadModuleUsingPathsIfEligible (...\node_modules\typescript\lib\typescript.js:28346:37)</p>
  <p>at tryLoadModuleUsingOptionalResolutionSettings (...\node_modules\typescript\lib\typescript.js:28334:24)</p>
  <p>at tryResolve (...\node_modules\typescript\lib\typescript.js:28479:28)</p>
  <p>at ...\node_modules\typescript\lib\typescript.js:28471:69</p>
  <p>at Object.forEach (...\node_modules\typescript\lib\typescript.js:309:30)</p>
  <p>at nodeModuleNameResolverWorker (...\node_modules\typescript\lib\typescript.js:28471:25)</p>
  <p>at nodeModuleNameResolver (...\node_modules\typescript\lib\typescript.js:28464:16)</p>
  <p>at Object.resolveModuleName (...\node_modules\typescript\lib\typescript.js:28238:30)</p>
  <p>at CompilerHostAdapter.getMetadataFor (...\node_modules@angular\compiler-cli\src\metadata\bundler.js:567:37)</p>
  </blockquote>
  <p>I introduced a console debug message in <code>function tryLoadModuleUsingPathsIfEligible(extensions, moduleName, loader, state)</code> function and it seems to be a loop with approximately 20 <code>moduleName</code>s. I have to mention that I do NOT have any circular dependency warning if I compile without <code>--prod</code> flag.</p>
  <p><em>Update:</em> I fixed the circular dependencies and I have no more warnings of sort.</p>