Skip to content

refactor(compiler): support local compilation for @defer blocks #53591

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

Closed

Conversation

AndrewKushnir
Copy link
Contributor

This commit updates Angular compiler to support local compilation mode for @defer blocks.

In local compilation mode, compiler can only rely on the information present in a currently processed file. As a result, compiler can not detect which components/directives/pipes belong to a particular @defer block (because that requires selector matching and selector info from other files where those classes are defined) and thus which classes can be defer-loaded. Because of this, no dependency functions are being generated for @defer blocks in the local compilation mode.

Also, this commit brings extra configuration and logic to make @defer blocks compatible with more constrained local compilation mode internally.

Overall, this change does not affect the behavior and APIs of @defer blocks externally (outside of Google's codebase) when using regular (full) compilation mode.

Does this PR introduce a breaking change?

  • Yes
  • No

@AndrewKushnir AndrewKushnir added action: review The PR is still awaiting reviews from at least one requested reviewer area: core Issues related to the framework runtime target: patch This PR is targeted for the next patch release area: compiler Issues related to `ngc`, Angular's template compiler core: defer Issues related to @defer blocks. labels Dec 15, 2023
@AndrewKushnir AndrewKushnir requested a review from alxhub December 15, 2023 20:24
@ngbot ngbot bot added this to the Backlog milestone Dec 15, 2023
@pullapprove pullapprove bot requested a review from josephperrott December 15, 2023 20:24
@AndrewKushnir AndrewKushnir force-pushed the defer_local_compilation_1 branch from 98906ee to 170527b Compare January 3, 2024 18:56
@AndrewKushnir AndrewKushnir force-pushed the defer_local_compilation_1 branch from 170527b to d53f5b9 Compare January 5, 2024 02:30
@AndrewKushnir AndrewKushnir force-pushed the defer_local_compilation_1 branch from d53f5b9 to faea33e Compare January 10, 2024 02:06
@AndrewKushnir AndrewKushnir added action: presubmit The PR is in need of a google3 presubmit and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Jan 10, 2024
@AndrewKushnir
Copy link
Contributor Author

AndrewKushnir commented Jan 10, 2024

Presubmit + TGP.

This commit updates a few places to extract the logic into a separate functions which will be reused in a few places in followup commits.
This commit updates typechecker to store full Pipe metadata in internal data strctures, so that this information is available to more places in the code, which will be updated in a followup commit.
…ide a defer block

This commit updates the logic to expose an internal API on the `R3BoundTarget` to check if an element belongs to any defer block.
…ps in `@defer` for local compilation mode

This commit adds an internal config option to enforce explicit deps in `@defer` for local compilation mode.
…deps config

This commit updates the `DeferredSymbolTracker` class to take info account the `onlyExplicitDeferDependencyImports` flag. The `DeferredSymbolTracker` class also exposes a new API to register import declarations as explicitly deferred, which will be used in followup commits.
This commit updates the logic to add support for internal `deferredImports` field in compiler.
…and `deferredImports`

This commit updates the typechecker logic to prevent same deps in `imports` and `deferredImports`.
… compilation

This commit updates the logic of the `TemplateDefinitionBuilder` to support local compilation and generate a single dependency function for all explicitly deferred deps within a component.
This commit adds tests to cover local compilation support for `@defer` blocks.
rlmestre pushed a commit to rlmestre/angular that referenced this pull request Jan 26, 2024
…ps in `@defer` for local compilation mode (angular#53591)

This commit adds an internal config option to enforce explicit deps in `@defer` for local compilation mode.

PR Close angular#53591
rlmestre pushed a commit to rlmestre/angular that referenced this pull request Jan 26, 2024
…deps config (angular#53591)

This commit updates the `DeferredSymbolTracker` class to take info account the `onlyExplicitDeferDependencyImports` flag. The `DeferredSymbolTracker` class also exposes a new API to register import declarations as explicitly deferred, which will be used in followup commits.

PR Close angular#53591
rlmestre pushed a commit to rlmestre/angular that referenced this pull request Jan 26, 2024
…ngular#53591)

This commit updates the logic to add support for internal `deferredImports` field in compiler.

PR Close angular#53591
rlmestre pushed a commit to rlmestre/angular that referenced this pull request Jan 26, 2024
…and `deferredImports` (angular#53591)

This commit updates the typechecker logic to prevent same deps in `imports` and `deferredImports`.

PR Close angular#53591
rlmestre pushed a commit to rlmestre/angular that referenced this pull request Jan 26, 2024
… compilation (angular#53591)

This commit updates the logic of the `TemplateDefinitionBuilder` to support local compilation and generate a single dependency function for all explicitly deferred deps within a component.

PR Close angular#53591
rlmestre pushed a commit to rlmestre/angular that referenced this pull request Jan 26, 2024
…ion (angular#53591)

This commit adds tests to cover local compilation support for `@defer` blocks.

PR Close angular#53591
rlmestre pushed a commit to rlmestre/angular that referenced this pull request Jan 26, 2024
…ar#54043)

In angular#53591, Andrew added local compliation support for defer blocks. However, this requires the ability to emit pre-generated static defer deps functions. We now also support that feature in Template Pipeline.

PR Close angular#54043
amilamen pushed a commit to amilamen/angular that referenced this pull request Jan 26, 2024
…angular#53591)

This commit updates a few places to extract the logic into a separate functions which will be reused in a few places in followup commits.

PR Close angular#53591
amilamen pushed a commit to amilamen/angular that referenced this pull request Jan 26, 2024
…angular#53591)

This commit updates typechecker to store full Pipe metadata in internal data strctures, so that this information is available to more places in the code, which will be updated in a followup commit.

PR Close angular#53591
amilamen pushed a commit to amilamen/angular that referenced this pull request Jan 26, 2024
…ide a defer block (angular#53591)

This commit updates the logic to expose an internal API on the `R3BoundTarget` to check if an element belongs to any defer block.

PR Close angular#53591
amilamen pushed a commit to amilamen/angular that referenced this pull request Jan 26, 2024
…ps in `@defer` for local compilation mode (angular#53591)

This commit adds an internal config option to enforce explicit deps in `@defer` for local compilation mode.

PR Close angular#53591
amilamen pushed a commit to amilamen/angular that referenced this pull request Jan 26, 2024
…deps config (angular#53591)

This commit updates the `DeferredSymbolTracker` class to take info account the `onlyExplicitDeferDependencyImports` flag. The `DeferredSymbolTracker` class also exposes a new API to register import declarations as explicitly deferred, which will be used in followup commits.

PR Close angular#53591
amilamen pushed a commit to amilamen/angular that referenced this pull request Jan 26, 2024
…ngular#53591)

This commit updates the logic to add support for internal `deferredImports` field in compiler.

PR Close angular#53591
amilamen pushed a commit to amilamen/angular that referenced this pull request Jan 26, 2024
…and `deferredImports` (angular#53591)

This commit updates the typechecker logic to prevent same deps in `imports` and `deferredImports`.

PR Close angular#53591
amilamen pushed a commit to amilamen/angular that referenced this pull request Jan 26, 2024
… compilation (angular#53591)

This commit updates the logic of the `TemplateDefinitionBuilder` to support local compilation and generate a single dependency function for all explicitly deferred deps within a component.

PR Close angular#53591
amilamen pushed a commit to amilamen/angular that referenced this pull request Jan 26, 2024
…ion (angular#53591)

This commit adds tests to cover local compilation support for `@defer` blocks.

PR Close angular#53591
amilamen pushed a commit to amilamen/angular that referenced this pull request Jan 26, 2024
…ar#54043)

In angular#53591, Andrew added local compliation support for defer blocks. However, this requires the ability to emit pre-generated static defer deps functions. We now also support that feature in Template Pipeline.

PR Close angular#54043
nikvarma pushed a commit to nikvarma/angular that referenced this pull request Jan 31, 2024
…ar#54043)

In angular#53591, Andrew added local compliation support for defer blocks. However, this requires the ability to emit pre-generated static defer deps functions. We now also support that feature in Template Pipeline.

PR Close angular#54043
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Feb 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker area: compiler Issues related to `ngc`, Angular's template compiler area: core Issues related to the framework runtime core: defer Issues related to @defer blocks. merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note target: rc This PR is targeted for the next release-candidate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants