-
Notifications
You must be signed in to change notification settings - Fork 24.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ivy: DI decorators tree-shaking when they are used to configure useFactory
deps
#40143
Labels
area: core
Issues related to the framework runtime
cross-cutting: tree-shaking
P4
A relatively minor issue that is not relevant to core functions
refactoring
Issue that involves refactoring or code-cleanup
Milestone
Comments
AndrewKushnir
added
refactoring
Issue that involves refactoring or code-cleanup
area: core
Issues related to the framework runtime
cross-cutting: tree-shaking
labels
Dec 16, 2020
AndrewKushnir
added
the
P4
A relatively minor issue that is not relevant to core functions
label
Dec 16, 2020
Related PR that triggered investigation - #40122. |
3 tasks
AndrewKushnir
added a commit
to AndrewKushnir/angular
that referenced
this issue
Dec 16, 2020
…y` deps config This commit updates the logic that calculates `useFactory` function arguments to avoid relying on `instanceof` checks (thus always retaining symbols) and relies on specific flags that DI decorators contain. Closes angular#40143.
3 tasks
AndrewKushnir
added a commit
to AndrewKushnir/angular
that referenced
this issue
Jan 8, 2021
…y` deps config This commit updates the logic that calculates `useFactory` function arguments to avoid relying on `instanceof` checks (thus always retaining symbols) and relies on specific flags that DI decorators contain. Closes angular#40143.
AndrewKushnir
added a commit
to AndrewKushnir/angular
that referenced
this issue
Jan 9, 2021
…y` deps config This commit updates the logic that calculates `useFactory` function arguments to avoid relying on `instanceof` checks (thus always retaining symbols) and relies on flags that DI decorators contain (as a monkey-patched property). Closes angular#40143.
AndrewKushnir
added a commit
to AndrewKushnir/angular
that referenced
this issue
Jan 11, 2021
…y` deps config This commit updates the logic that calculates `useFactory` function arguments to avoid relying on `instanceof` checks (thus always retaining symbols) and relies on flags that DI decorators contain (as a monkey-patched property). Another perf benefit is having less megamorphic reads while calculating args for the `useFactory` call: we used to check whether a token has `ngMetadataName` property 4 times (in worst case), now we have just 1 megamorphic read in all cases. Closes angular#40143.
AndrewKushnir
added a commit
to AndrewKushnir/angular
that referenced
this issue
Jan 13, 2021
…y` deps config This commit updates the logic that calculates `useFactory` function arguments to avoid relying on `instanceof` checks (thus always retaining symbols) and relies on flags that DI decorators contain (as a monkey-patched property). Another perf benefit is having less megamorphic reads while calculating args for the `useFactory` call: we used to check whether a token has `ngMetadataName` property 4 times (in worst case), now we have just 1 megamorphic read in all cases. Closes angular#40143.
AndrewKushnir
added a commit
to AndrewKushnir/angular
that referenced
this issue
Jan 13, 2021
…y` deps config This commit updates the logic that calculates `useFactory` function arguments to avoid relying on `instanceof` checks (thus always retaining symbols) and relies on flags that DI decorators contain (as a monkey-patched property). Another perf benefit is having less megamorphic reads while calculating args for the `useFactory` call: we used to check whether a token has `ngMetadataName` property 4 times (in worst case), now we have just 1 megamorphic read in all cases. Closes angular#40143.
atscott
pushed a commit
that referenced
this issue
Jan 13, 2021
…y` deps config (#40145) This commit updates the logic that calculates `useFactory` function arguments to avoid relying on `instanceof` checks (thus always retaining symbols) and relies on flags that DI decorators contain (as a monkey-patched property). Another perf benefit is having less megamorphic reads while calculating args for the `useFactory` call: we used to check whether a token has `ngMetadataName` property 4 times (in worst case), now we have just 1 megamorphic read in all cases. Closes #40143. PR Close #40145
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
area: core
Issues related to the framework runtime
cross-cutting: tree-shaking
P4
A relatively minor issue that is not relevant to core functions
refactoring
Issue that involves refactoring or code-cleanup
Angular DI allows providing DI tokens using
useFactory
function, which can accepts arguments configured viadeps
array.Here is a quick example:
The underlying logic that constructs these args refers to DI decorators (such as
SkipSelf
,Self
, etc) explicitly, thus making them non-tree-shakable:angular/packages/core/src/di/injector_compatibility.ts
Lines 145 to 159 in 2e7727c
Instead, we should consider using an approach of patching a field (like
__NG_DI_FLAG___
) onto a class and update the mentioned logic to check for this flag instead.Important:
meta.ngMetadataName
), the new approach will reduce the number of calls from 4 to 1.meta.ngMetadataName
check here is critical and break any existing use-cases.__NG_DI_FLAG__
flag should be present on both class definition and class instance:As a result, DI decorators should only be present in the bundle when they are used explicitly in the app code.
The text was updated successfully, but these errors were encountered: