Repository navigation
Use light-weight injection pattern for optimized tree-shaking/bundle size #19576
Description
With Ivy, factories are directly attached to components, so we production bundles could end up with larger bundles if Angular components/directives are used as predicates for optional queries or DI.
See: angular/angular#36144 and https://github.com/angular/angular-cli/issues/16866.
Here is an example:
export class ListItem {
constructor(@Optional() navigationList: NavList|null,
@Optional() actionList: ActionList|null)
}This will result in both NavList and ActionList being retained in production bundles as soon as the ListItem component/directive is used. It will become worse if NavList and ActionList have their own Angular factory/definition (that will also be retained now).
We need to go through our components and optimize these if they are affected by this issue that is now surfacing (more significantly) with Ivy.
Currently pending PRs:
- refactor(list): use light-weight tokens for injecting parent lists #19568
- List retains
MatListandMatNavList:
- List retains
- refactor: use light-weight token for optgroup to optimize bundle size #19577
- Autocomplete retains
MatOptgroup - Select retains
MatOptgroup MatOptionretainsMatOptgroup
- Autocomplete retains
- refactor: provide and use light-weight token for button-toggle group #19591
MatButtonTogglealways retainsMatButtonToggleGroup.
- refactor: use light-weight token for form-field in range-picker input #19643
- Date ranger picker input always retaining
MatFormField
- Date ranger picker input always retaining
- refactor: use lightweight token for lazy menu content #19644
- menu always retains
MatMenuContentdirective for lazy content
- menu always retains
- refactor: use lightweight token for injecting radio group #19645
- radio button always retains
MatRadioGroup.
- radio button always retains
- refactor: use lightweight token for CDK accordion #19676
CdkAccordionItemalways retainsCdkAccordion. Also affectsMatExpansionPanel.
- refactor: use lightweight token in CDK drag-drop #19678
CdkDragretainsCdkDragHandle,CdkDragPlaceholderandCdkDragPreviewCdkDropListretainsCdkDropListGroup.
- refactor: use lightweight token for chip avatar, remove and trailing icon #19693
MatChipretainsMatChipRemove,MatChipAvatarandMatChipTrailingIcon- Same applies to the MDC implementation where a significant size improvement was noticeable.
- refactor(form-field): use lightweight token for optimized treeshaking #19714
MatFormFieldretainsMatError,MatHint,MatSuffixandMatPrefix.- Same applies to MDC version, except for
MatHintthat is intentionally retained there.
- Use lightweight token for tab group and select trigger #19728
MatSelectalways retainsMatSelectTriggerMatTabalways retainsMatTabLabelandMatTabContent.
What we need upstream:
NgFormused inMatChipList.FormGroupDirectiveused inMatChipListNgControlused inMatChipList.
What we should consider in the future?
Directionality- Using a light-weight token for the
DateAdapterfor better tree-shaking
Revisit after done:
- MDC equivalents
Activity
refactor: optgroup should provide light-weight token
refactor: provide and use light-weight token for optgroup
refactor: provide and use light-weight token for optgroup
refactor: provide and use light-weight token for optgroup
refactor: provide and use light-weight token for optgroup
refactor: provide and use light-weight token for button-toggle group
refactor: provide and use light-weight token for button-toggle group
refactor: provide and use light-weight token for button-toggle group
refactor: provide and use light-weight token for optgroup
79 remaining items
refactor: use lightweight token for custom select trigger
refactor: use lightweight token for injecting radio group
refactor: use lightweight token for lazy menu content
refactor: use light-weight token for form-field in range-picker input
refactor: provide and use light-weight token for button-toggle group
refactor: provide and use light-weight token for optgroup
refactor: use lightweight token in CDK drag-drop
refactor: use lightweight token for CDK accordion
refactor: use lightweight token for chip avatar, remove and trailing …
refactor: use lightweight token for tab-group label and content
refactor: use lightweight token for custom select trigger
angular-automatic-lock-bot commentedon Jul 30, 2020
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.