Repository navigation
refactor(core): Makes @defer(hydrate ...) runtime tree-shakable - #68333
Conversation
|
I haven't had a chance to look at this yet, but we should probably make sure this works properly when an incremental hydration block is inside a non-incremental hydration defer block. You should definitely add that test case. |
2df61f7 to
ea832a3
Compare
| @Component({ | ||
| template: ` | ||
| @defer (on idle) { | ||
| @defer (hydrate on idle) { |
There was a problem hiding this comment.
This is within the same template. So it may not adequately test this use case. I would be interested to see a nested @defer(hydrate on idle) where the nested defer is inside a separate component. This immediate case wouldn't work anyway as there's nothing to defer.
ea832a3 to
1a3093a
Compare
| if (rf & 1) { | ||
| $r3$.ɵɵdomTemplate(0, MyApp_Defer_0_Template, 1, 0)(1, MyApp_DeferPlaceholder_1_Template, 2, 0); | ||
| $r3$.ɵɵdefer(2, 0, null, null, 1, null, null, null, null, 1); | ||
| $r3$.ɵɵdefer(2, 0, null, null, 1, null, null, null, null, 1, $r3$.ɵɵenableIncrementalHydrationRuntime); |
There was a problem hiding this comment.
I think it'd be great to generate a call to an extra side-effectful function as a separate top-level call like this:
$r3$.ɵɵenableIncrementalHydrationRuntime();
$r3$.ɵɵdefer(2, 0, null, null, 1, null, null, null, null, 1);
In this case the function should be present only once in a "create" block (before the first ɵɵdefer instruction in that "create" block), even if there are multiple defer blocks that require hydration code.
There was a problem hiding this comment.
Good option, i updated
This commit updates `@defer` logic related to incremental hydration to be tree-shakable. If hydrate triggers are used in a `@defer` block, the compiler emits a single top-level call to `ɵɵenableIncrementalHydrationRuntime`, placed once per create block before the first `ɵɵdefer` that requires it. As a result, the incremental hydration runtime is only included in the bundle when hydrate is explicitly used.
1a3093a to
065031a
Compare
thePunderWoman
left a comment
There was a problem hiding this comment.
LGTM! Thanks for this!
reviewed-for: fw-general, size-tracking, public-api
|
This PR was merged into the repository. The changes were merged into the following branches:
|
|
This pull request 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 commit updates
@deferlogic related to incremental hydration to be tree-shakable.If hydrate triggers are used in a
@deferblock, the compiler emits a single top-level call toɵɵenableIncrementalHydrationRuntime, placed once per create block before the firstɵɵdeferthat requires it.As a result, the incremental hydration runtime is only included in the bundle when hydrate is explicitly used.
Considering that the current default behavior of
provideClientHydrationenables incremental hydration.Inspired by #52042