feat(ivy): ngtsc compiles @Component, @Directive, @NgModule (#24427)
This change supports compilation of components, directives, and modules within ngtsc. Support is not complete, but is enough to compile and test //packages/core/test/bundling/todo in full AOT mode. Code size benefits are not yet achieved as //packages/core itself does not get compiled, and some decorators (e.g. @Input) are not stripped, leading to unwanted code being retained by the tree-shaker. This will be improved in future commits. PR Close #24427
This commit is contained in:

committed by
Miško Hevery

parent
0f7e4fae20
commit
27bc7dcb43
@ -7,7 +7,7 @@
|
||||
*/
|
||||
|
||||
import {assertEqual} from './assert';
|
||||
import {DirectiveDef} from './interfaces/definition';
|
||||
import {DirectiveDefInternal} from './interfaces/definition';
|
||||
import {TNodeFlags} from './interfaces/node';
|
||||
import {DIRECTIVES, FLAGS, HookData, LViewData, LViewFlags, TView} from './interfaces/view';
|
||||
|
||||
@ -52,7 +52,7 @@ export function queueLifecycleHooks(flags: number, tView: TView): void {
|
||||
// directiveCreate) so we can preserve the current hook order. Content, view, and destroy
|
||||
// hooks for projected components and directives must be called *before* their hosts.
|
||||
for (let i = start; i < end; i++) {
|
||||
const def: DirectiveDef<any> = tView.directives ![i];
|
||||
const def: DirectiveDefInternal<any> = tView.directives ![i];
|
||||
queueContentHooks(def, tView, i);
|
||||
queueViewHooks(def, tView, i);
|
||||
queueDestroyHooks(def, tView, i);
|
||||
@ -61,7 +61,7 @@ export function queueLifecycleHooks(flags: number, tView: TView): void {
|
||||
}
|
||||
|
||||
/** Queues afterContentInit and afterContentChecked hooks on TView */
|
||||
function queueContentHooks(def: DirectiveDef<any>, tView: TView, i: number): void {
|
||||
function queueContentHooks(def: DirectiveDefInternal<any>, tView: TView, i: number): void {
|
||||
if (def.afterContentInit) {
|
||||
(tView.contentHooks || (tView.contentHooks = [])).push(i, def.afterContentInit);
|
||||
}
|
||||
@ -73,7 +73,7 @@ function queueContentHooks(def: DirectiveDef<any>, tView: TView, i: number): voi
|
||||
}
|
||||
|
||||
/** Queues afterViewInit and afterViewChecked hooks on TView */
|
||||
function queueViewHooks(def: DirectiveDef<any>, tView: TView, i: number): void {
|
||||
function queueViewHooks(def: DirectiveDefInternal<any>, tView: TView, i: number): void {
|
||||
if (def.afterViewInit) {
|
||||
(tView.viewHooks || (tView.viewHooks = [])).push(i, def.afterViewInit);
|
||||
}
|
||||
@ -85,7 +85,7 @@ function queueViewHooks(def: DirectiveDef<any>, tView: TView, i: number): void {
|
||||
}
|
||||
|
||||
/** Queues onDestroy hooks on TView */
|
||||
function queueDestroyHooks(def: DirectiveDef<any>, tView: TView, i: number): void {
|
||||
function queueDestroyHooks(def: DirectiveDefInternal<any>, tView: TView, i: number): void {
|
||||
if (def.onDestroy != null) {
|
||||
(tView.destroyHooks || (tView.destroyHooks = [])).push(i, def.onDestroy);
|
||||
}
|
||||
|
Reference in New Issue
Block a user