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.
Current state
CpsDialogConfigis a class used both as a type annotation and as an Angular DI token: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
CpsDialogConfigto an interface (zero runtime cost).CPS_DIALOG_CONFIGas the DI token.Impact
CpsDialogConfigas a token need to migrate toCPS_DIALOG_CONFIG. Should be released in a major version bump.