Skip to content

refactor(forms): keep signal forms config tree-shakable#68810

Open
SkyZeroZx wants to merge 1 commit into
angular:mainfrom
SkyZeroZx:refactor/sf-tree-shake
Open

refactor(forms): keep signal forms config tree-shakable#68810
SkyZeroZx wants to merge 1 commit into
angular:mainfrom
SkyZeroZx:refactor/sf-tree-shake

Conversation

@SkyZeroZx
Copy link
Copy Markdown
Contributor

Add a dedicated @angular/forms/signals/config entrypoint so root-level signal forms configuration can be imported without eagerly pulling in the signal forms runtime.

Close #67909

CC @cexbrayat for the initial work that I used as the base for this PR.

What is the current behavior?

Currently provideSignalFormsConfig pulls in all Symbols from Signals Forms.

import { provideSignalFormsConfig } from "@angular/forms/signals";

bootstrapApplication(App, {
 providers: [
   provideSignalFormsConfig({
     classes: {
       "ng-invalid": ({ state }) => state().invalid(),
     },
   }),
 ],
});

What is the new behavior?

Create a secondary entry point @angular/forms/signals/config to allow tree-shaking and avoid pulling the Signals Forms runtime into the initial bundle.

Now

import { provideSignalFormsConfig } from "@angular/forms/signals/config";

bootstrapApplication(App, {
 providers: [
   provideSignalFormsConfig({
     classes: {
       "ng-invalid": ({ state }) => state().invalid(),
     },
   }),
 ],
});

Other

Additionally, I’m not sure whether this would be considered a breaking change (considering Angular 22 has not been officially released yet), or if we should keep the previous entry point and let it coexist with the new one to avoid compatibility issues.

I think it would be better to address this before the release.

@google-cla
Copy link
Copy Markdown

google-cla Bot commented May 20, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@pullapprove pullapprove Bot requested review from alan-agius4 and atscott May 20, 2026 02:17
@ngbot ngbot Bot added this to the Backlog milestone May 20, 2026
Add a dedicated @angular/forms/signals/config entrypoint so root-level
signal forms configuration can be imported without eagerly pulling in the
signal forms runtime.

Closes angular#67909

Co-authored-by: Cédric Exbrayat <cedric@ninja-squad.com>
@SkyZeroZx SkyZeroZx force-pushed the refactor/sf-tree-shake branch from 9c4f1d5 to 12ab5ba Compare May 20, 2026 02:18
Comment on lines 194 to -698
@@ -554,9 +553,6 @@ export class PatternValidationError extends BaseNgValidationError {
// @public
export function provideExperimentalWebMcpForms(): EnvironmentProviders;

// @public
export function provideSignalFormsConfig(config: SignalFormsConfig): Provider[];

// @public
export function readonly<TValue, TPathKind extends PathKind = PathKind.Root>(path: SchemaPath<TValue, SchemaPathRules.Supported, TPathKind>, config?: {
when?: NoInfer<LogicFn<TValue, boolean, TPathKind>>;
@@ -689,13 +685,6 @@ TModel
[K in keyof TModel]: MaybeSchemaPathTree<TModel[K], PathKind.Child>;
} : unknown);

// @public
export interface SignalFormsConfig {
classes?: {
[className: string]: (formField: FormFieldBinding) => boolean;
};
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a breaking change of a now stable api.

We'll have to deprecated those entries.

/**
* The subset of field state APIs used by signal forms CSS class configuration.
*
* @publicApi 22.0
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're past 22.0 freeze.

This would be 22.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

provideSignalFormsConfig prevents lazy-loading of forms

2 participants