| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
…ooks for client strategies
The device hot registry kept `hot.accept` callbacks but nothing ever fired
them, and it had no dependency form. A framework strategy can now read a
module's accept callbacks before eviction (`getAcceptCallbacks`), find the
importers that accept a changed path by name (`accept('./dep', cb)` →
`getDepAcceptors` / `acceptsDep`), and hook the shared queue at the points
Vite's own client uses: `beforeBatchEvict` (snapshot accept, drain dispose),
`shouldQueueReimport` / `applyUnqueuedChanges` (modules this realm never
loaded — worker scripts, type-only files — must not evaluate here), and
`handleGraphResync` (one ordered reload instead of piecemeal re-imports
after a dev-server restart).
The JS full reload now drains `hot.dispose` first, evicts only app-owned
modules — evicting `/ns/core` minted a second `View` hierarchy the live tree
failed `instanceof` against — and reports `ns:full-reload-complete` /
`ns:full-reload-failed` so a strategy can finish what it deferred.
The shared hot-update prologue read a changed module's `importedModules`
before awaiting the transform that discovers them, so a newly added import
reached the client graph one save late; it reads them after the transform.
`cleanCode` stripped every `@nativescript/core/globals` import from served modules. That is right for the main realm, where the entry installs the globals once, and fatal for a worker realm: the worker script is that isolate's only entry and the import is its only source of `setTimeout`, `setInterval` and the other runtime globals. Worker-realm serves keep the import, and a worker entry that does not carry one gets it added — the production worker build bundles the module in, so the two paths agree.
Flavors were wired by name inside the package, so a framework could only
get device HMR by landing a PR here. `registerFrameworkFlavor({ flavor,
server, client })` from `@nativescript/vite/framework` registers a server
strategy and the specifier of a client strategy module shipped in the
framework's own package; `@nativescript/vite/hmr/client/framework.js` is
the device-side surface that module is written against.
The dev server looks registered strategies up next to the built-ins, seeds
the device bundle with the client module's `/ns/m/node_modules/<pkg>/…`
path (`__NS_CLIENT_STRATEGY_URL__`), and classifies the client package as
dev tooling — served per-module, never vendor-bundled or plugin-wrapped —
so its relative imports and its imports of the shared client resolve to the
running client's canonical URLs. `nativescript-vite init` and flavor
detection read a `nativescript.vite` declaration from the framework
package's package.json.
docs/framework-flavors.md is the walkthrough; @nativescript/vite-octane
(NativeScript/octane) is the worked example.
Vite's stock client never connects under device HMR, so its `page reload <file>` / `hmr update <file>` lines describe a client that does not exist — and `page reload` misleads while the device applies the same save in place through a framework strategy.
|
View your CI Pipeline Execution ↗ for commit 1de8324
💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗ ☁️ Nx Cloud last updated this comment at 2026-08-22 18:07:56 UTC |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Support for third-party frameworks to define and register their own NativeScript Vite HMR "flavors," enabling any framework to provide custom HMR strategies through their own packages.
Framework Flavor Extensibility
Configuration and Runtime Integration