使用--prod-flag时,角度构建会中断

时间:2017-06-27 13:22:21

标签: angular build angular2-aot

使用angular-cli的我的Angular 4构建运行,我可以启动应用程序,但很多组件无法正确加载。我的控制台充满了以下错误消息:

Expected function name "for", was ""
Expected function name "keyFor", was ""
Expected function name "next", was ""
Expected function name "next", was ""
Expected function name "clear", was ""
Expected function name "delete", was ""
Expected function name "entries", was ""
Expected function name "forEach", was ""
Expected function name "get", was ""
Expected function name "has", was ""
Expected function name "keys", was ""
Expected function name "set", was ""
Expected function name "values", was ""
Expected function name "next", was ""
Expected function name "add", was ""
Expected function name "clear", was ""
Expected function name "delete", was ""
Expected function name "entries", was ""
Expected function name "forEach", was ""
Expected function name "has", was ""
Expected function name "values", was ""
Expected function name "next", was ""
Expected function name "delete", was ""
Expected function name "get", was ""
Expected function name "has", was ""
Expected function name "set", was ""
Expected function name "add", was ""
Expected function name "delete", was ""
Expected function name "has", was ""
Expected function name "all", was ""
Expected function name "race", was ""
Expected function name "reject", was ""
Expected function name "resolve", was ""
Expected function name "catch", was ""
Expected function name "then", was ""

任何想知道从哪里开始追踪此事的人?

1 个答案:

答案 0 :(得分:2)

答案是双重的,我在问题中发布的错误是指我从 polyfills.ts中删除后,我加载的一个polyfill(显然不应该): js-polyfills 错误消失。

然而,这并没有解决我的应用程序中的错误。经过一些测试后,我发现问题在于someObject.constructor.name === 'someString'。 angular-cli-compiler在构建过程之后运行 UglifyJS ,因此更改了类,因此更改了构造函数名称。用类中的显式type - 字段替换它可以解决我遇到的错误。另请参阅:https://github.com/angular/angular-cli/issues/5168