Skip to content

feat(angular): add Vite HMR with route, dialog, and cache preserve - #161

Open
NathanWalker wants to merge 1 commit into
mainfrom
feat/vite-hmr
Open

feat(angular): add Vite HMR with route, dialog, and cache preserve#161
NathanWalker wants to merge 1 commit into
mainfrom
feat/vite-hmr

Conversation

@NathanWalker

@NathanWalker NathanWalker commented Dec 27, 2025

Copy link
Copy Markdown
Contributor

Summary

  • Sit on the @nativescript/vite client contract (__reboot_ng_modules__, compiled-component reset, component registrar, app ref / boot-complete globals) instead of reimplementing eviction, CSS fetch, or import.meta.hot dispatch.
  • Restore the current URL across reboot (named-outlet URLs boot at / then one navigateByUrl), keep isAngularHmrRestoringRoute() for app default-nav guards, and opt-in dialog restore via preserveOnHmr.
  • Add HmrCacheService (LRU + import.meta.hot.data persist) and propagate modal host props so _dialogFragment / viewController exist on descendants for both cold open and HMR.

The HMR surface is 6 modules:

  • hmr.ts — env detection, class registrar, eager instantiators, compiled-component reset
  • hmr-route.ts — current URL + named-outlet deferral + restoring window + tracker/replay
  • dialog-hmr.ts — stash/restore + un-animated close/reopen
  • modal-host-props.ts — host-prop mirroring (not HMR-only)
  • hmr-cache.ts + hmr-cache-store.ts — app cache (store is Jest-importable; persist stays in the service because import.meta cannot run in CJS Jest)

Public API stays small: HmrCacheService, configureHmrCache, isAngularHmrRestoringRoute / getAngularHmrRestoringRoute, NativeDialogConfig.preserveOnHmr.

Test plan

  • npx nx run angular:test (60 passing)
  • Vite HMR save on a routed screen: URL stays put, no back-stack walk
  • Named-outlet URL (e.g. tab outlet): boots / then one forward nav; isAngularHmrRestoringRoute() is true through the 1s grace
  • Dialog with preserveOnHmr: true reopens with the fresh class, no close/open animation
  • Dialog with default preserveOnHmr: false is not restored
  • Embedded first launch still bootstraps without Application.run()
  • Webpack import.meta['hot'] / webpackHot.decline() still works
  • HmrCacheService values survive a save cycle

@NathanWalker
NathanWalker marked this pull request as draft March 30, 2026 20:19
@coderabbitai

coderabbitai Bot commented May 24, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: f32dd0e2-481f-44d5-8e84-26516a7fbbea

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/vite-hmr

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@pkg-pr-new

pkg-pr-new Bot commented Aug 19, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/NativeScript/angular/@nativescript/angular@161
npm i https://pkg.pr.new/NativeScript/angular/@nativescript/zone-js@161

commit: 8bc735e

@NathanWalker
NathanWalker marked this pull request as ready for review August 21, 2026 22:30
@NathanWalker NathanWalker changed the title feat: support Vite HMR feat(angular): add Vite HMR with route, dialog, and cache preserve Aug 21, 2026
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant