feat: ESM resolver hardening, http loader, dev-mode globals#1965
Draft
NathanWalker wants to merge 3 commits into
Draft
feat: ESM resolver hardening, http loader, dev-mode globals#1965NathanWalker wants to merge 3 commits into
NathanWalker wants to merge 3 commits into
Conversation
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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 |
fb386eb to
708fecd
Compare
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`).
…ract The runtime explicitly does not implement HMR policy. import.meta.hot, the hot-data/accept/dispose/prune registries, and dev-session state move to the JS HMR clients (eg, @nativescript/vite); native keeps only the sync HTTP module fetch, prewarm cache + list-mode kickstart, eviction plumbing, and the dev-boot-complete signal. Dev helpers are consolidated under __NS_DEV__. Also fixes dynamic import() error propagation: with top-level-await enabled, Module::Evaluate() returns a promise instead of an empty MaybeLocal on throw, so the previous empty-check never fired and import() resolved a half-evaluated namespace, silently swallowing module evaluation errors. The callback now checks Module::GetStatus() for kErrored (HTTP, blob, and generic paths) and rejects with the module's real exception, matching iOS. Removes the httpModulePrefetch app-config flag and speculative prefetching; list-mode kickstart remains.
08e7b8e to
696d4fc
Compare
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.
Framework-agnostic hot module replacement on Android with native ES modules: the device fetches modules over HTTP from the Vite dev server and applies hot updates without restarting the process.
The runtime's entire dev surface is one namespace object,
globalThis.__NS_DEV__, carrying primitives, each traceable to a V8-embedder or OS constraint:configureRuntime(config)ResolveModuleCallbackinvalidateModules(urls)v8::Modulerecords + prewarm cache + arms a CFNetwork cache-bust noncekickstartPrefetch(urls)getLoadedModuleUrls()setDevBootComplete(bool)Every HMR policy decision, boot orchestration,
import.meta.hot, full reload, CSS apply, the WebSocket protocol is JS in@nativescript/vite. No native dev-session state machine, no reload orchestration, no hot-callback registries exist in the runtime, and on-device tests pin both the present members and the absent globals.