-
Notifications
You must be signed in to change notification settings - Fork 24.8k
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
fix(ivy): avoid remote scoping if it's not actually required #29404
Conversation
@@ -3934,6 +3967,57 @@ export const Foo = Foo__PRE_R3__; | |||
expect(jsContents).toContain('styles: ["h1[_ngcontent-%COMP%] {font-size: larger}"]'); | |||
}); | |||
}); | |||
|
|||
xit('should not suck', () => { |
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.
ROFL 🤣
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.
Hahaha. That's my usual test description for reproducing bugs within the compiler's test suite.
2cac81f
to
15d606b
Compare
|
||
// The BoundTarget knows which directives and pipes matched the template. | ||
const usedDirectives = bound.getUsedDirectives(); | ||
const usedPipes = bound.getUsedPipes().map(name => pipes.get(name) !); |
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.
This non-null assertion operator is actually a problem, I think. T3TargetBinder
, or more specifically TemplateBinder
:
angular/packages/compiler/src/render3/view/t2_binder.ts
Lines 444 to 447 in 5ad2097
visitPipe(ast: BindingPipe, context: any): any { | |
this.usedPipes.add(ast.name); | |
return super.visitPipe(ast, context); | |
} |
tracks pipes just by name regardless of their definition. So, a missing pipe results in a miss here.
edit: aha, existing code. Still, looks error-prone to me.
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.
You're absolutely right. I'll file an issue to clean that up.
// any import which needs to be generated for the directive would create a cycle. | ||
const cycleDetected = directives.some(dir => this._isCyclicImport(dir.expression, context)) || | ||
Array.from(pipes.values()).some(pipe => this._isCyclicImport(pipe, context)); | ||
// Next, the component template AST is bound using the R3TargetBinder. This produces an |
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.
an --> a ✌️
Currently, ngtsc decides to use remote scoping if the compilation of a component may create a cyclic import. This happens if there are two components in a scope (say, A and B) and A directly uses B. During compilation of B ngtsc will then note that if B were to use A, a cycle would be generated, and so it will opt to use remote scoping for B. ngtsc already uses the R3TargetBinder to correctly track the imports that are actually required, for future cycle tracking. This commit expands that usage to not trigger remote scoping unless B actually does consume A in its template.
15d606b
to
f846f03
Compare
I am the approver for compiler-cli. |
…#29404) Currently, ngtsc decides to use remote scoping if the compilation of a component may create a cyclic import. This happens if there are two components in a scope (say, A and B) and A directly uses B. During compilation of B ngtsc will then note that if B were to use A, a cycle would be generated, and so it will opt to use remote scoping for B. ngtsc already uses the R3TargetBinder to correctly track the imports that are actually required, for future cycle tracking. This commit expands that usage to not trigger remote scoping unless B actually does consume A in its template. PR Close angular#29404
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. |
Currently, ngtsc decides to use remote scoping if the compilation of a
component may create a cyclic import. This happens if there are two
components in a scope (say, A and B) and A directly uses B. During
compilation of B ngtsc will then note that if B were to use A, a cycle would
be generated, and so it will opt to use remote scoping for B.
ngtsc already uses the R3TargetBinder to correctly track the imports that
are actually required, for future cycle tracking. This commit expands that
usage to not trigger remote scoping unless B actually does consume A in its
template.