The header keeps 1.2 MB of video code in the initial bundle
The write-up says what remains is "mostly libraries" and names ng-ivs, the IVS player, and aws-sdk. I walked the head build's static import graph to see why a logged-out visitor on /about downloads a live-stream player. Most of it comes through one edge:
- app.module.ts
- header/header.component.ts
- header-layout/header-layout.component.ts
- welcome-video-modal/welcome-video-modal.component.ts
- video-player-v2.component.ts → ng-ivs 551 KB, amazon-ivs-player 360 KB
- comments.component.ts → upload.service.ts → aws-sdk 349 KB
HeaderLayoutComponent imports the modal's class for one @ContentChild(CustomWelcomeModalTemplate) query. Using the class as the token makes its whole compiled dependency tree part of the header. Remove that edge and 88 files, about 1,216,000 bytes, go lazy. That's a third of what this PR saved, from a one-file change. Query by a token instead:
// welcome-video-modal.token.ts
export const WELCOME_VIDEO_MODAL = new InjectionToken<WelcomeVideoModal>('WELCOME_VIDEO_MODAL');
// welcome-video-modal.component.ts
providers: [{ provide: WELCOME_VIDEO_MODAL, useExisting: CustomWelcomeModalTemplate }]
// header-layout.component.ts
@ContentChild(WELCOME_VIDEO_MODAL) welcomeVideoModal?: WelcomeVideoModal;
Pre-existing, but before this PR the header's imports didn't matter. Now they decide what a first visit downloads. I'd do this before the per-route SharedModule removals, since it helps every route at once.