File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -127,6 +127,34 @@ from expanding the glob:
127127deno run --watch --watch-exclude=' *.js' main.ts
128128```
129129
130+ ### Hot module replacement
131+
132+ ` deno run ` also supports the ` --watch-hmr ` flag, which hot-replaces changed
133+ modules in the running process instead of restarting it. This keeps your
134+ application's state across edits. If hot replacement fails, the process falls
135+ back to a full restart.
136+
137+ ``` shell
138+ deno run --watch-hmr main.ts
139+ ```
140+
141+ #### Editors with atomic save
142+
143+ Some editors use "atomic save" (also called safe write), where the editor writes
144+ your changes to a temporary file and then renames it over the original on each
145+ save. On Linux this replaces the file with a new one on disk, which can detach
146+ the file watcher used by ` --watch-hmr ` after the first change. The symptom is
147+ that hot replacement works once and then stops detecting further edits to that
148+ module.
149+
150+ If you hit this, disable atomic save in your editor:
151+
152+ - ** Helix** : set ` [editor] atomic-save = false ` (it is enabled by default).
153+ - ** Neovim/Vim** : set ` :set backupcopy=yes ` .
154+
155+ Plain ` --watch ` is not affected, because each change triggers a full restart
156+ that re-establishes the watchers.
157+
130158## Where to go next
131159
132160For deeper coverage of the topics this page only hints at:
You can’t perform that action at this time.
0 commit comments