Support deferred blocks in partial compilation#54908
Closed
crisbeto wants to merge 5 commits intoangular:mainfrom
Closed
Support deferred blocks in partial compilation#54908crisbeto wants to merge 5 commits intoangular:mainfrom
crisbeto wants to merge 5 commits intoangular:mainfrom
Conversation
d5f55aa to
deaa7d1
Compare
deaa7d1 to
6395a29
Compare
AndrewKushnir
approved these changes
Mar 19, 2024
Contributor
AndrewKushnir
left a comment
There was a problem hiding this comment.
@crisbeto the change looks great 👍 Huge thanks for splitting the change into multiple commits, it made it much easier to review.
Contributor
|
@alxhub could you please take a look at this change when you get a chance? Would love to get your feedback on the shape of partially compiled components. Thank you. |
…n the binder Switches to tracking the deferred blocks in a flat array in the binder to ensure that their template order is maintained. This will be relevant in the next commits where we'll match deferred blocks by their index. Note that the current map we have technically guarantees the insertion order in the spec, but the array is a bit more explicit.
Updates the type of the resolver function to be any `Expression` since JIT may receive a function reference rather than a `ArrowFunctionExpr`.
Updates the linker's AST host to add the ability to extract a function's parameters. This will be required for the next commits.
…data Adds the `ɵɵngDeclareClassMetadataAsync` function that will be produced during partial compilation for component classes that have deferred dependencies. At runtime the dependencies will be resolved before setting the metadata.
6395a29 to
b7cf26b
Compare
Builds on top of the previous changes to add support for deferred blocks during partial compilation. To do this, the following changes had to be made: * The metadata passed into `ɵɵngDeclareComponent` has an additional field called `deferBlockDependencies` which has an array of the dependency loading functions for each defer block in the template. During linking, the dependency functions are loaded by matching their template index to the index in the `deferBlockDependencies` array. * There's a new `ɵɵngDeclareClassMetadataAsync` function that is created for components that have deferred dependencies. It gets transpiled to `setClassMetadataAsync` and works in the same way by capturing a dependency loading function and setting the metadata after the dependencies are resolved. It also has some extra fields for capturing the version which are standard in linker-generated code. * Deferred import statements are now stripped in partial compilation mode, similar to full compilation.
b7cf26b to
76365a5
Compare
Contributor
|
This PR was merged into the repository by commit 5bd188a. |
dylhunn
pushed a commit
that referenced
this pull request
Mar 22, 2024
Updates the type of the resolver function to be any `Expression` since JIT may receive a function reference rather than a `ArrowFunctionExpr`. PR Close #54908
dylhunn
pushed a commit
that referenced
this pull request
Mar 22, 2024
…ks (#54908) Builds on top of the previous changes to add support for deferred blocks during partial compilation. To do this, the following changes had to be made: * The metadata passed into `ɵɵngDeclareComponent` has an additional field called `deferBlockDependencies` which has an array of the dependency loading functions for each defer block in the template. During linking, the dependency functions are loaded by matching their template index to the index in the `deferBlockDependencies` array. * There's a new `ɵɵngDeclareClassMetadataAsync` function that is created for components that have deferred dependencies. It gets transpiled to `setClassMetadataAsync` and works in the same way by capturing a dependency loading function and setting the metadata after the dependencies are resolved. It also has some extra fields for capturing the version which are standard in linker-generated code. * Deferred import statements are now stripped in partial compilation mode, similar to full compilation. PR Close #54908
|
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 file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Includes some changes that are necessary to support
@deferblocks in partial compilation mode.refactor(compiler): ensure defer blocks maintain the template order in the binder
Switches to tracking the deferred blocks in a flat array in the binder to ensure that their template order is maintained. This will be relevant in the next commits where we'll match deferred blocks by their index.
Note that the current map we have technically guarantees the insertion order in the spec, but the array is a bit more explicit.
refactor(compiler): widen type of resolver function
Updates the type of the resolver function to be any
Expressionsince JIT may receive a function reference rather than aArrowFunctionExpr.refactor(compiler-cli): add method for extracting function parameters
Updates the linker's AST host to add the ability to extract a function's parameters. This will be required for the next commits.
refactor(core): introduce API for declaring asynchronous partial metadata
Adds the
ɵɵngDeclareClassMetadataAsyncfunction that will be produced during partial compilation for component classes that have deferred dependencies. At runtime the dependencies will be resolved before setting the metadata.feat(compiler-cli): add partial compilation support for deferred blocks
Builds on top of the previous changes to add support for deferred blocks during partial compilation. To do this, the following changes had to be made:
ɵɵngDeclareComponenthas an additional field calleddeferBlockDependencieswhich has an array of the dependency loading functions for each defer block in the template. During linking, the dependency functions are loaded by matching their template index to the index in thedeferBlockDependenciesarray.ɵɵngDeclareClassMetadataAsyncfunction that is created for components that have deferred dependencies. It gets transpiled tosetClassMetadataAsyncand works in the same way by capturing a dependency loading function and setting the metadata after the dependencies are resolved. It also has some extra fields for capturing the version which are standard in linker-generated code.