Angular: ngc or tsc?

旧巷老猫 提交于 2020-01-15 03:11:19

问题


I have been using tsc, but see that angular.io emphasizes ngc. I am wondering if there are advantages to either or if I should choose one over the other. Thanks in advance.


回答1:


tsc and ngc have different purposes and it's not about selecting one over the other.

tsc is a TypeScript compiler, and you need it to generate JavaScript if your app is written in TypeScript.

ngc is an Angular-specific compiler. It doesn't turn the TypeScript code into JavaScript. It does a "finishing touch" to make your app bundles ready for rendering by the browser. In particular, it turns your components templates into inline JavaScript. If you do a prod build with Ahead of Time (AoT) compilation, the ngc does its part before the bundles are built. In dev mode we use Just-in-Time compilation: the templates are not precompiled, the ngc compiler is included into the bundles, and it compiles the templates after the browser loaded your bundles.



来源:https://stackoverflow.com/questions/50111036/angular-ngc-or-tsc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!