Skip to content
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

[patch-only] perf(forms): avoid direct references to the Validators class (#41189) #41220

Closed

Conversation

AndrewKushnir
Copy link
Contributor

This PR contains a cherry-picked commit from #41189, which had marge conflicts with the patch (11.2.x) branch due to the fact that min/max validator directives are only available in master.

…ar#41189)

Currently the `Validators` class contains a number of static methods that represent different validators as well as some helper methods. Since class methods are not tree-shakable, any reference to the `Validator` class retains all of its methods (even if you've used just one).

This commit refactors the code to extract the logic into standalone functions and use these functions in the code instead of referencing them via `Validators` class. That should make the code more tree-shakable. The `Validators` class still retains its structure and calls these standalone methods internally to keep this change backwards-compatible.

PR Close angular#41189
@ngbot ngbot bot modified the milestone: Backlog Mar 15, 2021
@google-cla google-cla bot added the cla: yes label Mar 15, 2021
@AndrewKushnir AndrewKushnir marked this pull request as ready for review March 15, 2021 18:43
@AndrewKushnir AndrewKushnir added the action: merge The PR is ready for merge by the caretaker label Mar 15, 2021
@jessicajaniuk
Copy link
Contributor

Closed by commit 804b6b6

jessicajaniuk pushed a commit that referenced this pull request Mar 15, 2021
… (#41220)

Currently the `Validators` class contains a number of static methods that represent different validators as well as some helper methods. Since class methods are not tree-shakable, any reference to the `Validator` class retains all of its methods (even if you've used just one).

This commit refactors the code to extract the logic into standalone functions and use these functions in the code instead of referencing them via `Validators` class. That should make the code more tree-shakable. The `Validators` class still retains its structure and calls these standalone methods internally to keep this change backwards-compatible.

PR Close #41189

PR Close #41220
This was referenced Mar 18, 2021
@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Apr 15, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker area: forms area: performance cla: yes cross-cutting: tree-shaking PullApprove: disable target: patch This PR is targeted for the next patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants