ericltw / notes

0 stars 1 forks source link

Angular Rendering Engine #52

Open ericltw opened 4 years ago

ericltw commented 4 years ago

Angular Compiler // TODO

目的

將你寫的template, decorator(declative)轉換為runtime運行的代碼(imperative)。

Why not just write imperative code?
Compile Mode

Compiler可以以兩種方式進行compile,JIT和AOT。

Architecture

on a macro scale processes your code.

Compilation Model

多個compilation根據定義好的compilation model一起工作。

Feature of the Compiler
Reference
ericltw commented 4 years ago

Angular Runtime // TODO

介紹

應用的附帶框架代碼,實際在瀏覽器中運行。

Application Bootstrap
Reference
ericltw commented 4 years ago

Ivy // TODO

介紹

Next-generation compiler and runtime (rendering pipeline).

解決

How achived by Ivy?

Tree Shacking

tree shacking指的是在bundle過程刪除未使用的代碼。然而這些tree shacking tool當遇到條件內的引用時,會有侷限性,如:static analyzer無法識別"if"語句中為使用的code,這些code仍會出現在輸出的bundle。

View Engine Pipeline

現今的Angular compiler以Angular template當作輸入,生成代表template結構的JavaScript code,運行時,這些template data將會被Angular interpreter解釋生成DOM。正是因為Angular interpreter無法確定template data,存在條件判斷,因此無法很好的去執行tree shaking。

Ivy Pipeline

Ivy的方式則是直接生成template instruction,不需要interpreter就可以進行處理,生成DOM,因此更好的去執行tree shacking。

Locality

Locality指的是Ivy compile每個component時指關注component本身的information,不關注其依賴。在現今的Angular code,每個component包含了parent information。

影響

Reference