deno
989e6f2b - feat(core): native module reload engine for HMR (Phase 1)

Commit
170 days ago
feat(core): native module reload engine for HMR (Phase 1) Adds a deno_core reload engine that recompiles and re-evaluates a single ES module in place while preserving its dependencies' instances, the foundation for true Hot Module Replacement (replacing the limited CDP setScriptSource approach behind --watch-hmr). Mechanics: evict the module's by_name entry (new ModuleNameTypeMap::remove and ModuleMapData::evict_modules, tombstoning the append-only handles/info slots so existing ModuleIds stay valid), then re-drive a load so it recompiles into a fresh v8::Module. Its imports resolve through by_name to the surviving instances, so shared dependencies keep their singletons and only the reloaded module's top-level code re-runs. Surfaces: - JsRuntime::reload_es_module(specifier) (Rust API, evict + side load). - op_reload_module_evict + Deno.core.reloadEsModule(specifier) (JS escape hatch: evict + dynamic import, reusing the dynamic-import pipeline). - compute_importer_closure: importer-graph walk, infrastructure for the Phase 2 import.meta.hot boundary bubbling (currently unused). Design and phasing documented in docs/designs/native-hmr.md. import.meta.hot (the headline API) and the browser WebSocket protocol are later phases. Tested in libs/core/modules/tests.rs (Rust and JS paths), both asserting the edited module re-runs, resolves to its fresh namespace, and the shared dependency's singleton is preserved.
Author
Parents
Loading