feat(ivy): ngtsc compiles @Component, @Directive, @NgModule#24427
feat(ivy): ngtsc compiles @Component, @Directive, @NgModule#24427alxhub wants to merge 1 commit intoangular:masterfrom
Conversation
|
You can preview 184cdd3 at https://pr24427-184cdd3.ngbuilds.io/. |
There was a problem hiding this comment.
Just a heads up, makeBindingParser is ridiculously slow due to its construction of DomElementSchemaRegistry. I noticed while profiling the Ivy Todo app in JIT mode where all calls to makeBindingParser summed up to ~100ms. Constructing the schema registry only once reduced that to nil.
There was a problem hiding this comment.
Hey! Wow, this is good feedback.
makeBindingParser is only temporary - eventually the DomElementSchemaRegistry will (in JIT mode) be something that the user can override, and the BindingParser itself will be rewritten to not depend on Compile*Metadata.
|
You can preview 76d8c04 at https://pr24427-76d8c04.ngbuilds.io/. |
42f4206 to
401431f
Compare
|
You can preview 401431f at https://pr24427-401431f.ngbuilds.io/. |
|
You can preview 19d8b6e at https://pr24427-19d8b6e.ngbuilds.io/. |
There was a problem hiding this comment.
In current implementation, a component would be given ng-component as its selector when not specified, is this being a breaking change?
angular/packages/compiler/src/metadata_resolver.ts
Lines 348 to 350 in 3ed2d75
(Even I don't think this feature should be depend upon)
There was a problem hiding this comment.
This is selector scope registration, which determines what selectors we look for when parsing a template of another component. If a component/directive doesn't have a selector, then it cannot be in the selector scope because it can never match an element in a template.
There was a problem hiding this comment.
@alxhub A selector-less component would indeed match <ng-component> in template:
https://stackblitz.com/edit/angular-hxgxhz?file=src%2Fapp%2Fhello.component.ts
There was a problem hiding this comment.
Forgot to mention yesterday, I find it somewhat suspicious that in the guard above, the original node mapping is not used. I'm not familiar with what TS considers as "original" node so I can't really say if this is bad or not.
- one more occurrence in
registerSelector
There was a problem hiding this comment.
Yeah, that's a good point. Original nodes are "untransformed" nodes. During the analysis phase (when registerModule and registerSelector) are called, ts.getOriginalNode(node) will always be node, because the original source files are analyzed.
During the emit phase, when TS is running transformers, other transformers (before Angular's) may change the AST, so by the time we go to codegen data for the node, the reference could be different. ts.getOriginalNode walks back from the transformed node to the untransformed one that was seen during our analysis phase.
Here it's not necessary (and is a no-op) as registerModule and registerSelector are always called during the analysis phase, so the nodes we deal with will always be original.
|
You can preview 3632542 at https://pr24427-3632542.ngbuilds.io/. |
|
You can preview b26605d at https://pr24427-b26605d.ngbuilds.io/. |
There was a problem hiding this comment.
nigt: expect(reference).toBeAnInstanceOf(ExternalExpr, 'Expected expression reference to be an external (import) expression')
There was a problem hiding this comment.
That doesn't narrow the type of reference :)
|
You can preview e8d5225 at https://pr24427-e8d5225.ngbuilds.io/. |
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.
|
You can preview 38f210a at https://pr24427-38f210a.ngbuilds.io/. |
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
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.