Commit ec65663
refactor(core): replace Optional/SkipSelf deps with inject() flags (angular#63386)
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 angular#633861 parent 07e6788 commit ec65663
File tree
5 files changed
+8
-22
lines changed- packages/core
- src/change_detection/differs
- test/bundling
- defer
- forms_reactive
- forms_template_driven
5 files changed
+8
-22
lines changedLines changed: 3 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | | - | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| |||
233 | 233 | | |
234 | 234 | | |
235 | 235 | | |
236 | | - | |
| 236 | + | |
| 237 | + | |
237 | 238 | | |
238 | 239 | | |
239 | 240 | | |
240 | 241 | | |
241 | 242 | | |
242 | | - | |
243 | | - | |
244 | 243 | | |
245 | 244 | | |
246 | 245 | | |
| |||
Lines changed: 3 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
| 9 | + | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| |||
166 | 166 | | |
167 | 167 | | |
168 | 168 | | |
169 | | - | |
| 169 | + | |
| 170 | + | |
170 | 171 | | |
171 | 172 | | |
172 | 173 | | |
173 | 174 | | |
174 | 175 | | |
175 | | - | |
176 | | - | |
177 | 176 | | |
178 | 177 | | |
179 | 178 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
| 61 | + | |
61 | 62 | | |
62 | 63 | | |
63 | 64 | | |
| |||
753 | 754 | | |
754 | 755 | | |
755 | 756 | | |
756 | | - | |
757 | | - | |
| 757 | + | |
758 | 758 | | |
759 | 759 | | |
760 | 760 | | |
Lines changed: 0 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
198 | 198 | | |
199 | 199 | | |
200 | 200 | | |
201 | | - | |
202 | | - | |
203 | 201 | | |
204 | 202 | | |
205 | 203 | | |
| |||
245 | 243 | | |
246 | 244 | | |
247 | 245 | | |
248 | | - | |
249 | 246 | | |
250 | 247 | | |
251 | 248 | | |
| |||
385 | 382 | | |
386 | 383 | | |
387 | 384 | | |
388 | | - | |
389 | 385 | | |
390 | 386 | | |
391 | 387 | | |
| |||
789 | 785 | | |
790 | 786 | | |
791 | 787 | | |
792 | | - | |
793 | | - | |
794 | 788 | | |
795 | 789 | | |
796 | 790 | | |
| |||
Lines changed: 0 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
194 | 194 | | |
195 | 195 | | |
196 | 196 | | |
197 | | - | |
198 | | - | |
199 | 197 | | |
200 | 198 | | |
201 | 199 | | |
| |||
240 | 238 | | |
241 | 239 | | |
242 | 240 | | |
243 | | - | |
244 | 241 | | |
245 | 242 | | |
246 | 243 | | |
| |||
389 | 386 | | |
390 | 387 | | |
391 | 388 | | |
392 | | - | |
393 | 389 | | |
394 | 390 | | |
395 | 391 | | |
| |||
790 | 786 | | |
791 | 787 | | |
792 | 788 | | |
793 | | - | |
794 | | - | |
795 | 789 | | |
796 | 790 | | |
797 | 791 | | |
| |||
0 commit comments