New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(compiler-cli): specify whether a used directive is a component in partial component declaration #41104
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's a crazy idea... Instead of marking each component with isComponent
, how about we change the declaration to have two properties directives
and components
, which get consolidated back together in the linker?
… in partial declaration The partial declaration of a component includes the list of directives that are used in its template, including some metadata of the directive which can be used during actual compilation of the component. Used components are currently part of this list, as components are also directives. This commit splits the used components into a dedicate property in the partial declaration, which allows for template compilation to optimize the generated code for components.
ff307dc
to
82f0bd6
Compare
const collectUsedDirectives = | ||
(directives: AstValue<R3DeclareUsedDirectiveMetadata, TExpression>[]) => { | ||
return directives.map(directive => { | ||
const directiveExpr = directive.getObject(); | ||
const type = directiveExpr.getValue('type'); | ||
const selector = directiveExpr.getString('selector'); | ||
|
||
let typeExpr = type.getOpaque(); | ||
const forwardRefType = extractForwardRef(type); | ||
if (forwardRefType !== null) { | ||
typeExpr = forwardRefType; | ||
declarationListEmitMode = DeclarationListEmitMode.Closure; | ||
} | ||
|
||
return { | ||
type: typeExpr, | ||
selector: selector, | ||
inputs: directiveExpr.has('inputs') ? | ||
directiveExpr.getArray('inputs').map(input => input.getString()) : | ||
[], | ||
outputs: directiveExpr.has('outputs') ? | ||
directiveExpr.getArray('outputs').map(input => input.getString()) : | ||
[], | ||
exportAs: directiveExpr.has('exportAs') ? | ||
directiveExpr.getArray('exportAs').map(exportAs => exportAs.getString()) : | ||
null, | ||
}; | ||
}); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ugh! I'd love to pull this out into a separate utility function at the bottom of this file.
I tried to do it myself when I originally wrote this block of code.
But the update to declarationListEmitMode
makes it awkward to be in a separate function.
😞
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, declarationListEmitMode
made this into a local closure.
…ial component declaration In angular#41104 the list of used directives was split into two arrays of used directives and components, but the JIT side was not updated. This commit fixes the JIT integration by including the list of used components. Fixes angular#41318
…ial component declaration In angular#41104 the list of used directives was split into two arrays of used directives and components, but the JIT side was not updated. This commit fixes the JIT integration by including the list of used components. Fixes angular#41318
…ial component declaration In angular#41104 the list of used directives was split into two arrays of used directives and components, but the JIT side was not updated. This commit fixes the JIT integration by including the list of used components. Fixes angular#41318
…ial component declaration (angular#41353) In angular#41104 the list of used directives was split into two arrays of used directives and components, but the JIT side was not updated. This commit fixes the JIT integration by including the list of used components. Fixes angular#41318 PR Close angular#41353
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. |
The partial declaration of a component includes the list of directives
that are used in its template, including some metadata of the directive
which can be used during actual compilation of the component. This
commit introduces an additional metadata flag
isComponent
such thattemplate compilation can use this information in the future.