mirror of
https://github.com/angular/angular
synced 2026-05-24 09:28:37 +00:00
This commit updates provider definitions that relied on the `deps` array
with `new Optional()` and `new SkipSelf()` to instead use the modern
`inject(..., { optional: true, skipSelf: true })` API.
Previously:
deps: [[KeyValueDiffers, new SkipSelf(), new Optional()]]
Now:
const parent = inject(KeyValueDiffers, { optional: true, skipSelf: true });
**Bundle size reduction**: `Optional` and `SkipSelf` are runtime values
created by `makeParamDecorator()`. Even in production builds, esbuild
and other bundlers must keep their factory code because they are
referenced with `new Optional()` / `new SkipSelf()`. With `inject()`,
those classes are no longer referenced, allowing them and the
`makeParamDecorator` scaffolding to be tree-shaken when unused.
As a result, production bundles can drop both `Optional`, `SkipSelf`, and
their supporting factory code when not used elsewhere, reducing code size
while keeping the same behavior.
PR Close #63386
|
||
|---|---|---|
| .. | ||
| differs | ||
| scheduling | ||
| change_detection.ts | ||
| change_detector_ref.ts | ||
| constants.ts | ||
| pipe_transform.ts | ||
| provide_check_no_changes_config.ts | ||
| use_exhaustive_check_no_changes.ts | ||