Skip to content

Replace CpsDialogConfig class with interface + InjectionToken to reduce bundle size #571

Description

@lukasmatta

Current state

CpsDialogConfig is a class used both as a type annotation and as an Angular DI token:

{ provide: CpsDialogConfig, useValue: config }

Because it's a DI token, it cannot be converted to an interface (interfaces are erased at compile time), so it emits unnecessary runtime JavaScript.

Proposed change

  • Introduce a dedicated injection token:
export const CPS_DIALOG_CONFIG = new InjectionToken<CpsDialogConfig>('CPS_DIALOG_CONFIG');
  • Convert CpsDialogConfig to an interface (zero runtime cost).
  • Update internal usages to use CPS_DIALOG_CONFIG as the DI token.
  • Deprecate the class-based token with a migration note for consumers (important).

Impact

  • Reduces bundle size (class constructor is no longer emitted).
  • Aligns with Angular best practices for config objects.
  • Breaking change: consumers injecting CpsDialogConfig as a token need to migrate to CPS_DIALOG_CONFIG. Should be released in a major version bump.

Metadata

Metadata

Assignees

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions