angular - "Maximum call stack size exceeded"在 Angular 9 ng build --prod 中用于库

标签 angular typescript ng-packagr

我有一个可以用 Angular 9 编译的库。但是如果我将标志更改为 --prod,这实际上使 "enableIvy": false然后我得到

[error] RangeError: Maximum call stack size exceeded

at Object.pathIsRelative (...\node_modules\typescript\lib\typescript.js:5778:34)

at tryLoadModuleUsingPathsIfEligible (...\node_modules\typescript\lib\typescript.js:28346:37)

at tryLoadModuleUsingOptionalResolutionSettings (...\node_modules\typescript\lib\typescript.js:28334:24)

at tryResolve (...\node_modules\typescript\lib\typescript.js:28479:28)

at ...\node_modules\typescript\lib\typescript.js:28471:69

at Object.forEach (...\node_modules\typescript\lib\typescript.js:309:30)

at nodeModuleNameResolverWorker (...\node_modules\typescript\lib\typescript.js:28471:25)

at nodeModuleNameResolver (...\node_modules\typescript\lib\typescript.js:28464:16)

at Object.resolveModuleName (...\node_modules\typescript\lib\typescript.js:28238:30)

at CompilerHostAdapter.getMetadataFor (...\node_modules@angular\compiler-cli\src\metadata\bundler.js:567:37)


我在 function tryLoadModuleUsingPathsIfEligible(extensions, moduleName, loader, state) 中引入了控制台调试消息函数,它似乎是一个循环,大约有 20 moduleName s。我不得不提到,如果我在没有 --prod 的情况下进行编译,我没有任何循环依赖警告。旗帜。
更新:我修复了循环依赖项,并且没有更多的警告。

最佳答案

我在 angular 12.1.1 上遇到了同样的问题,我没有循环依赖,解决方案是改变 "enableIvy: false""compilationMode": "partial" .
angular docs .

关于angular - "Maximum call stack size exceeded"在 Angular 9 ng build --prod 中用于库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62769793/

相关文章:

Angular:如何将多个表单控件附加到表单组

typescript - 当应用程序在 Angular 2 中启动时如何运行服务

node.js - 如何在模块 A 导入模块 B 的地方开发两个 Angular 模块

forms - 子组件的 Angular Form 验证

javascript - angular2 中的老虎机旋转效果

typescript - 为什么我的 Sequelize/Typescript 函数会出现 "Two different types with this name exist, but they are unrelated."错误?

javascript - Angular 5 服务替换/覆盖

json - 在 ng-packagr 中嵌入 json

angular - ng2-idle modal ok 应该恢复空闲

typescript - Keyof 推断字符串 |键只是字符串时的数字