Repository navigation
fix(defer): emit ɵɵenableIncrementalHydrationRuntime before hydrating defer blocks - #594
Conversation
… defer blocks Since Angular 22.0.0-next.11 the incremental hydration runtime stays inert until a template calls ɵɵenableIncrementalHydrationRuntime(). OXC never emitted it, so @defer blocks with hydrate triggers were never hydrated on the client. Port Angular's insertIncrementalHydrationRuntime phase: one call per view, before its first defer block with hydrate triggers. Skipped for Angular versions without the instruction.
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
…ts placement in tests - Place the op, OpKind and identifier next to the other defer items. - Give the op the defer block's source span, as Angular does. - Write HAS_HYDRATE_TRIGGERS in ingest through the same constant the phase reads. - Fix the doc: older runtimes turn the feature on from withIncrementalHydration(). - Tests: unit test for the 22.0.0-next.11 cutoff (rc, beta, later minors); check the exact statement after each call and which function it is in; cover hydrate never / when / timer and i18n. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
|
@codex review |
|
Codex Review: Didn't find any major issues. You're on a roll. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Summary
@deferblocks withhydratetriggers are never hydrated on the client when compiled with OXC.Since Angular 22.0.0-next.11, the incremental hydration runtime stays inert until a compiled template calls
ɵɵenableIncrementalHydrationRuntime()(packages/core/src/hydration/incremental_runtime.ts). Until thencreateDehydratedBlockRegistry()returnsnullandrunIncrementalHydrationBootstrap()is a no-op, sowithIncrementalHydration()alone does nothing. ngc emits the call through theinsertIncrementalHydrationRuntimephase. OXC doesn't have that phase, and the e2e compare fixtures recorded the missing call as a known difference.@defer (on idle) {a} @defer (hydrate on hover) {b}ngc and OXC with this change:
OXC on
mainhas noɵɵenableIncrementalHydrationRuntime()line.phases/insert_incremental_hydration_runtime.rsDeferop whose flags haveHasHydrateTriggers. Registered right afterconfigureDeferInstructions, as in ngc's phase list.ir/ops.rs,ir/enums.rs,ir/expression.rsEnableIncrementalHydrationRuntimecreate op.reify,r3/identifiers.rsɵɵenableIncrementalHydrationRuntime().AngularVersion::supports_incremental_hydration_runtime@angular/compilerbuilds. Older targets don't export it, so the phase is skipped for them.Tests
ɵɵdefer;hydrate never,hydrate when,hydrate on timerand a block insidei18neach get the call;hydratetriggers;supports_incremental_hydration_runtime: next.11, rc, 22.1.0-next.0 and 23.x emit; 21.2.25, next.0, next.10 andbeta(parses toOther) don't.defer/defer-hydrate-*entries and their reason fromknown-differences.ts. They match ngc 22.2.2 now: 1091 fixtures, 0 mismatches.cargo fmt --all -- --check,cargo test --all-features(3332 passed), andcargo run -p oxc_angular_conformance(1264/1264, no snapshot diff) all pass.Review follow-up
Checked against real ngc 22.2.3 on 42 templates (every trigger kind, several blocks per view, nesting in
@if/@for/@switch/ng-template/*ngIf/other@defersub-blocks, i18n,templateUrl), plus partial mode, the linker, JIT and HMR: same output. The 22.0.0-next.11 cutoff matches the npm tarballs: next.10 has noɵɵenableIncrementalHydrationRuntime, and no 20.x or 21.x release got it.Polish in the second commit:
OpKindand the identifier sit with the other defer items.HAS_HYDRATE_TRIGGERSthrough the same constant the phase reads.withIncrementalHydration().Not in this PR (already on
main):prefetchtriggers, ngc emits the prefetch op before the defaultɵɵdeferOnIdle(), and OXC emits it after.angularVersionset, OXC treats the version as latest, as for every other version gate. So a v20/v21 app now gets the call and throws at runtime.