Skip to content

perf(forms): enable tree shaking of unused errors and properties #63298

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

Merged
merged 1 commit into from
Aug 21, 2025

Conversation

leonsenft
Copy link
Contributor

The ValidationError and AggregateProperty classes used static factory methods to create instances. This pattern created a hard dependency from the base classes to all of their subclasses and variations.

As a result, any application importing even a single validator (e.g., required) or property would inadvertently pull in the code for all other validators and properties, preventing effective tree-shaking and increasing bundle size.

This refactoring removes the static factory methods and replaces them with standalone, exported functions or properties. This decouples the individual validators and properties, allowing bundlers to properly perform dead code elimination.

@leonsenft leonsenft requested a review from mmalerba August 20, 2025 19:55
@angular-robot angular-robot bot added area: performance Issues related to performance area: forms target: feature This PR is targeted for a feature branch (outside of main and semver branches) labels Aug 20, 2025
@ngbot ngbot bot added this to the Backlog milestone Aug 20, 2025
@leonsenft leonsenft marked this pull request as draft August 20, 2025 20:25
@leonsenft leonsenft marked this pull request as ready for review August 21, 2025 17:27
The `ValidationError` and `AggregateProperty` classes used static
factory methods to create instances. This pattern created a hard
dependency from the base classes to all of their subclasses and
variations.

As a result, any application importing even a single validator (e.g.,
required) or property would inadvertently pull in the code for all other
validators and properties, preventing effective tree-shaking and
increasing bundle size.

This refactoring removes the static factory methods and replaces them
with standalone, exported functions or properties. This decouples the
individual validators and properties, allowing bundlers to properly
perform dead code elimination.
@leonsenft leonsenft merged commit 197b393 into angular:prototype/signal-forms Aug 21, 2025
15 of 16 checks passed
@leonsenft leonsenft deleted the tree-shaking branch August 21, 2025 23:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: forms area: performance Issues related to performance target: feature This PR is targeted for a feature branch (outside of main and semver branches)
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants