Description
Which @angular/* package(s) are the source of the bug?
cdk
Is this a regression?
No
Description
The documented way to globally disable the popover behaviour is to provide OVERLAY_DEFAULT_CONFIG at bootstrap (see overlay.md). In 22.3.0, OVERLAY_DEFAULT_CONFIG is declared in fesm2022/_overlay-module-chunk.mjs together with Overlay, createOverlayRef, position/scroll strategies and the portal/scrolling imports. Importing only the token from @angular/cdk/overlay in an application config therefore keeps that implementation in the initial bundle even when every overlay consumer is lazy-loaded.
UI kits such as Spartan (provideSpartanHlm()) do exactly this, so every app using them pays for the overlay code at startup.
Measured on an Angular 22.3 application builder project (esbuild, production): removing the single root provider { provide: OVERLAY_DEFAULT_CONFIG, useValue: { usePopover: false } } reduced the initial bundle from 616.45 kB to 567.21 kB raw (−49.24 kB; about −11 kB transfer). After removal only ~3.6 kB of CDK code remained in main.
Because Overlay/Dialog are root services that read the token through their own injector, the token cannot simply be moved to a lazy route provider.
Proposed solution
Declare OVERLAY_DEFAULT_CONFIG (and similar configuration tokens) in a small side-effect-free module that does not import the overlay implementation, re-exported from @angular/cdk/overlay as today — in line with the "lightweight injection tokens" guidance on angular.dev.
Minimal reproduction
ng new repro --style css(Angular 22.3), add@angular/cdk@22.3.0.- In
app.config.tsadd{ provide: OVERLAY_DEFAULT_CONFIG, useValue: { usePopover: false } }(import from@angular/cdk/overlay); do not use any overlay in the app. ng build --stats-jsonand compare the initial total / inspectbrowser-stats.jsonwith and without the provider.
Activity
crisbeto commentedon Nov 27, 2026
Moving it into a separate entrypoint would be a breaking change and re-exporting defeats the purpose of moving it in the first place.