简体   繁体   English

Angular AOT 构建因私有成员而失败

[英]Angular AOT build failing because of Private member

I am working on a migration project where i have existing UI application codebase which is developed on Angular 8 .我正在做一个迁移项目,我有现有的 UI 应用程序代码库,该代码库是在Angular 8上开发的。

When i am doing normal build (ie. ng build) i am able to build successfully but the deployed artifacts size is more.当我进行正常构建(即 ng 构建)时,我能够成功构建,但部署的工件大小更大。

Eg: main.js (4.5 mb) in size.例如: main.js (4.5 mb)大小。

If i deploy above artifcats to my production my page is taking more time to render in browser.如果我将上述工件部署到我的生产中,我的页面将花费更多时间在浏览器中呈现。

So, For production build i tried building my angular application in AOT mode but the build is failing.因此,对于生产构建,我尝试在AOT模式下构建我的 angular 应用程序,但构建失败。

Below is the log getting from almost every template.下面是从几乎每个模板获取的日志。

src/app/components/header/header.component.html(52,19): Property 'competenciesService' is private and only accessible within class 'HeaderComponent'

What I understood from log's are i can't use private members inside.html templates in AOT mode.我从日志中了解到我不能在内部使用私有成员。AOT模式下的 html 模板。

But as my application is build by some other team and i can't go and change the property in each and every template practically not possible.但是由于我的应用程序是由其他团队构建的,我不能 go 并且几乎不可能更改每个模板中的属性。

Please suggest me is their any approach to resolve this so that my production build artifacts will reduce in size so that application performance will increase.请建议我是他们解决此问题的任何方法,以便我的生产构建工件的大小将减小,从而提高应用程序性能。

Angualr CLI global Version: 8.3.15 Angualr CLI 全球版本:8.3.15

Angular CLI local Version: 8.3.0 Angular CLI 本地版本:8.3.0

Let me know if anything more information required.如果需要更多信息,请告诉我。

Thanks,谢谢,

Since you are migrating your code, your first focus should be to make as compliant as possible with your framework, even if it is a lot of work because the application will get harder and harder to maintain in the future.由于您正在迁移代码,因此您的首要重点应该是尽可能地兼容您的框架,即使这需要做很多工作,因为应用程序在未来将变得越来越难以维护。 A template should only access public variables.模板应该只访问公共变量。 You could add getters in your component ts file.您可以在组件 ts 文件中添加 getter。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM