Repository navigation
feat(angular): add Vite HMR with route, dialog, and cache preserve - #161
Open
NathanWalker wants to merge 6 commits into
Open
NathanWalker wants to merge 6 commits into
NathanWalker wants to merge 6 commits into
Conversation
NathanWalker
marked this pull request as draft
March 30, 2026 20:19
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
NathanWalker
force-pushed
the
feat/vite-hmr
branch
from
August 19, 2026 19:08
72af632 to
33c7337
Compare
commit: |
NathanWalker
force-pushed
the
feat/vite-hmr
branch
from
August 21, 2026 22:30
33c7337 to
3fb385a
Compare
NathanWalker
marked this pull request as ready for review
August 21, 2026 22:30
NathanWalker
force-pushed
the
feat/vite-hmr
branch
from
August 21, 2026 22:36
3fb385a to
1241a03
Compare
Vite client contract and keep the current URL, opt-in dialogs, compiled-component identities, and HmrCacheService across __reboot_ng_modules__ without walking a leftover back-stack.
NathanWalker
force-pushed
the
feat/vite-hmr
branch
from
August 21, 2026 22:44
1241a03 to
8bc735e
Compare
# Conflicts: # packages/angular/src/lib/cdk/dialog/native-modal-ref.ts
…ease 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.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Vite HMR support for
@nativescript/angular, built on the@nativescript/viteAngular client contract (__reboot_ng_modules__,__NS_UPDATE_ANGULAR_APP_OPTIONS__,__reset_ng_compiled_components__,__NS_HMR_REGISTER_COMPONENT__)./and are then replayed with a singlenavigateByUrl.isAngularHmrRestoringRoute()lets app start-up navigation stand down while a restore is in progress.preserveOnHmr: truereopen after a reboot without animation, using the freshly edited component class.ɵɵreplaceMetadata) work inside open modals, and changed component styles are re-applied.HmrCacheServiceprovides an app-wide LRU cache that survives reboots. In release builds it is a plain in-memory cache.Dev-only by construction
Everything lives in
packages/angular/src/lib/hmr/:hmr.tsroute.tsdialog.tspreserveOnHmrtracking and reopenmodal-host.tscache.tsHmrCacheServiceEvery call into
lib/hmrfrom elsewhere is guarded bytypeof ngDevMode === 'undefined' || ngDevMode. Release builds definengDevMode=false, so none of this code ships. I checked the iOS and Android release bundles of a Vite app: they contain no HMR globals or hooks.Features plug into the reboot through
beforeDispose/afterBootstraphooks rather than being hard-wired intoapplication.ts. The modalContentViewwrapper is only used during a live HMR session, so release and plain dev builds present modals exactly asmaindoes.Public API:
HmrCacheService,configureHmrCache,isAngularHmrRestoringRoute/getAngularHmrRestoringRoute,NativeDialogConfig.preserveOnHmr.Test plan
npx nx run angular:test(22 specs)ns-duo-guitarHMR lab branch):.tssave on a pushed lazy route keeps the URL and shows the edited componentHmrCacheServicevalues survive a rebootpreserveOnHmrdialog reopens with the fresh class and keeps its data; a default dialog is not restored.htmland.cssedits update an open dialog in placemain, now installed wheneverngDevModeis on)