feat: HMR dev-sessions, ESM resolver hardening, dev-mode runtime globals by NathanWalker · Pull Request #1965 · NativeScript/android · GitHub
Skip to content

feat: HMR dev-sessions, ESM resolver hardening, dev-mode runtime globals#1965

Draft
NathanWalker wants to merge 2 commits into
mainfrom
feat/hmr-dev-sessions
Draft

feat: HMR dev-sessions, ESM resolver hardening, dev-mode runtime globals#1965
NathanWalker wants to merge 2 commits into
mainfrom
feat/hmr-dev-sessions

Conversation

@NathanWalker

Copy link
Copy Markdown
Contributor

Adds robust Hot Module Replacement plus the supporting ESM resolver hardening and dev-session globals that make hot reload viable on Android.

  • import.meta.hot: data, accept, dispose, prune, decline, invalidate, on/off/send event surface.
  • Dev-session globals (__nsStartDevSession, __nsReloadDevApp, __nsInvalidateModules, __nsRunHmrDispose, __nsRunHmrPrune, __nsHasDeclinedModule, __nsKickstartHmrPrefetch, __nsGetLoadedModuleUrls, __nsApplyStyleUpdate, __nsConfigureDevRuntime/__nsConfigureRuntime, __nsTerminateAllWorkers).
  • Speculative HTTP module prefetch (opt-in) with canonical-key normalization so __ns_hmr__/v<N> and __ns_boot__/b<N> tag prefixes share hot.data identity across reload cycles.
  • ESM resolver hardening in ModuleInternalCallbacks.cpp to:
    • Preserve synthetic-namespace identity (ns-vendor://, optional:, node:, blob:) — these are NOT filesystem paths.
    • Handle HTTP/HTTPS module URLs end-to-end (resolution, fetch, canonical-key collapse, dynamic import).
    • Compile .json imports into synthetic ES modules.
  • Android runtime-dex support for .extend() classes created during HMR that the static binding generator can't see at build time: runtime DEX generation with $/_ inner-class normalization (DexFactory), dev/HMR class-resolution fallback (ClassResolver), and dev-flag / logScriptLoading plumbing (AppConfig, DevFlags).

Matches features in NativeScript/ios#383

@coderabbitai

coderabbitai Bot commented Jun 8, 2026

Copy link
Copy Markdown

Adds the Hot Module Replacement runtime layer plus the supporting ESM
resolver hardening and dev-session globals that make hot reload viable on
Android.

* `import.meta.hot`: `data`, `accept`, `dispose`, `prune`, `decline`,
  `invalidate`, `on`/`off`/`send` event surface.
* Dev-session globals (`__nsStartDevSession`, `__nsReloadDevApp`,
  `__nsInvalidateModules`, `__nsRunHmrDispose`, `__nsRunHmrPrune`,
  `__nsHasDeclinedModule`, `__nsKickstartHmrPrefetch`,
  `__nsGetLoadedModuleUrls`, `__nsApplyStyleUpdate`,
  `__nsConfigureDevRuntime`/`__nsConfigureRuntime`,
  `__nsTerminateAllWorkers`).
* Speculative HTTP module prefetch (opt-in) with canonical-key
  normalization so `__ns_hmr__/v<N>` and `__ns_boot__/b<N>` tag prefixes
  share `hot.data` identity across reload cycles.
* ESM resolver hardening in `ModuleInternalCallbacks.cpp` to:
  - Preserve synthetic-namespace identity (`ns-vendor://`, `optional:`,
    `node:`, `blob:`) — these are NOT filesystem paths.
  - Handle HTTP/HTTPS module URLs end-to-end (resolution, fetch,
    canonical-key collapse, dynamic import).
  - Compile `.json` imports into synthetic ES modules.
* Android runtime-dex support for `.extend()` classes created during HMR
  that the static binding generator can't see at build time: runtime DEX
  generation with `$`/`_` inner-class normalization (`DexFactory`),
  dev/HMR class-resolution fallback (`ClassResolver`), and dev-flag /
  `logScriptLoading` plumbing (`AppConfig`, `DevFlags`).
@NathanWalker NathanWalker force-pushed the feat/hmr-dev-sessions branch from fb386eb to 708fecd Compare June 16, 2026 17:07
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