Skip to content

Commit 442ff1e

Browse files
committed
refactor(angular): consolidate HMR into lib/hmr and strip it from release builds
All HMR support now lives in packages/angular/src/lib/hmr (hmr, route, dialog, modal-host, cache). Every entry point outside that folder is guarded by `typeof ngDevMode === 'undefined' || ngDevMode`, so release builds (which define ngDevMode=false) drop it entirely; verified against iOS and Android release bundles of a Vite app. - Features register beforeDispose/afterBootstrap hooks with the reboot instead of application.ts importing the router and NativeDialog subscribing to bootstrap events; removes the eager-instantiator registry and the ReplaySubject change. - Route restore captures router.url at dispose and feeds the start path through provideLocationStrategy instead of overriding START_PATH, so an app-provided START_PATH is no longer clobbered. Route configs are no longer cloned at bootstrap; router caches are cleared at dispose instead. - Dialog restore tracks preserveOnHmr dialogs, drops the destroyed viewContainerRef/injector, and waits for app stability so an edited dialog inside a lazy route reopens with its fresh class. - The modal ContentView wrapper and host-prop mirroring apply only in live HMR sessions; release and plain dev builds present modals exactly as before. - Drops the console.warn NG0912 filter, Angular-core namespace holder, diagnostics counters, redundant boot-complete globals and the import.meta.hot wiring in HmrCacheService (import.meta.hot is always undefined inside the package). - Reverts formatting-only zone-js changes, the NativeDialogModule provider removal, the element registration changes and the NSLocationStrategy and NSRouteReuseStrategy ngOnDestroy changes.
1 parent f64e423 commit 442ff1e

41 files changed

Lines changed: 1179 additions & 3088 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎packages/angular/src/lib/application.ts‎

Lines changed: 74 additions & 286 deletions
Large diffs are not rendered by default.

‎packages/angular/src/lib/cdk/dialog/dialog-hmr.spec.ts‎

Lines changed: 0 additions & 183 deletions
This file was deleted.

‎packages/angular/src/lib/cdk/dialog/dialog-hmr.ts‎

Lines changed: 0 additions & 147 deletions
This file was deleted.
Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,10 @@
11
import { NgModule } from '@angular/core';
22
import { NativeDialogCloseDirective } from './dialog-content-directives';
3+
import { NativeDialog } from './dialog-services';
34

4-
/**
5-
* Convenience module that re-exports the `NativeDialogCloseDirective` for
6-
* template-driven `[nativeDialogClose]` usage.
7-
*
8-
* **Important**: `NativeDialog` itself is **not** listed in this module's
9-
* `providers` array. The service is `@Injectable({ providedIn: 'root' })`,
10-
* which already registers a single root-level instance and is fully
11-
* tree-shakeable. Listing it here as well caused Angular to treat the
12-
* module-level provider and the `providedIn: 'root'` factory as
13-
* *separate* registrations once the module was pulled into a standalone
14-
* app via `importProvidersFrom(NativeDialogModule, ...)`. The duplicate
15-
* registration triggered:
16-
*
17-
* - Two `NativeDialog` instances in the same root environment injector,
18-
* each subscribing to `postAngularBootstrap$`, which produced
19-
* duplicate restore attempts during HMR.
20-
* - `NG0200: Circular dependency detected for NativeDialog` while a
21-
* captured modal was being re-opened during HMR restore, because the
22-
* second resolution started while the first was still in progress.
23-
*
24-
* Removing the redundant entry collapses both providers back into a
25-
* single root-level instance, which is what `providedIn: 'root'`
26-
* documents. App authors who explicitly wire `NativeDialog` themselves
27-
* (e.g. in a feature module's `providers`) keep working unchanged
28-
* because they're targeting the same class symbol.
29-
*/
305
@NgModule({
316
imports: [NativeDialogCloseDirective],
327
exports: [NativeDialogCloseDirective],
8+
providers: [NativeDialog],
339
})
3410
export class NativeDialogModule {}

0 commit comments

Comments
 (0)