21 DI tokens selected their implementation like this: factory: () => (environment.useMockData ? inject(XLocal) : inject(XApi)) That reads as a toggle and is not one. Naming both classes in the factory keeps both reachable, so every mock shipped regardless of the flag - and `useMockData` is false in both environment files, so none of them were ever the selected implementation in the first place. Verified: a fixture string from partner-hierarchy-local.gateway.ts was present in a production bundle. Token factories now inject the API gateway unconditionally. Mock overrides move to src/app/mock-gateway.providers.ts, swapped for a production copy that imports nothing, via the same fileReplacements mechanism mock-data.interceptor.production.ts already uses. Dev behaviour is unchanged - flip useMockData in environment.ts exactly as before. useExisting rather than useClass: the local gateways are already providedIn: 'root' singletons, and an app-level provider for the token wins over its tree-shakable default. scan-bundle.sh gains two patterns so this cannot come back: any *LocalGateway class name, and known fixture literals. Verified in both directions - clean against the real dist, exit 1 against a planted OfferLocalGateway. Result: zero LocalGateway classes and zero fixtures in the production bundle, down from 21 classes and 75 kB of source. Initial bundle is unchanged at 1.55 MB because these all sat in lazy chunks; the win is that production can no longer serve seeded fixtures as real data, not bytes off the critical path. Not addressed here: MediaRepository is still bound to MockMediaRepository unconditionally in app.config.ts. That one cannot be deleted - no real implementation exists yet - so it is a missing API gateway, not dead weight. Tracked separately. 256 tests pass. Build green, boundaries and cycles green. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
10 lines
474 B
TypeScript
10 lines
474 B
TypeScript
import { InjectionToken, inject } from '@angular/core';
|
|
import { AdminDashboardMetricsGateway } from './admin-dashboard-metrics.gateway.interface';
|
|
import { AdminDashboardMetricsApiGateway } from './admin-dashboard-metrics-api.gateway';
|
|
|
|
/** Swap point. */
|
|
export const ADMIN_DASHBOARD_METRICS_GATEWAY = new InjectionToken<AdminDashboardMetricsGateway>('ADMIN_DASHBOARD_METRICS_GATEWAY', {
|
|
providedIn: 'root',
|
|
factory: () => inject(AdminDashboardMetricsApiGateway),
|
|
});
|