<h3 dir="auto">version</h3>
<p dir="auto">current latest master (<a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/denoland/deno/commit/bfce376c685694569be2cbf0716dd58f898c111e/hovercard" href="https://github.com/denoland/deno/commit/bfce376c685694569be2cbf0716dd58f898c111e"><tt>bfce376</tt></a>)</p>
<h3 dir="auto">How to reproduce</h3>
<ol dir="auto">
<li>create a file named <code class="notranslate">main.js</code>with the following content:</li>
</ol>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="console.log('hello');"><pre class="notranslate"><span class="pl-smi">console</span><span class="pl-kos">.</span><span class="pl-en">log</span><span class="pl-kos">(</span><span class="pl-s">'hello'</span><span class="pl-kos">)</span><span class="pl-kos">;</span></pre></div>
<ol start="2" dir="auto">
<li>start running deno watcher by <code class="notranslate">cargo run -- run --watch --unstable main.js</code>. At this point we can see an output like:</li>
</ol>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="hello
Watcher Process terminated! Restarting on file change..."><pre class="notranslate"><code class="notranslate">hello
Watcher Process terminated! Restarting on file change...
</code></pre></div>
<ol start="3" dir="auto">
<li>create a new file named <code class="notranslate">new.js</code>. Nothing happens on the terminal.</li>
</ol>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="export const world = 'world';"><pre class="notranslate"><span class="pl-k">export</span> <span class="pl-k">const</span> <span class="pl-s1">world</span> <span class="pl-c1">=</span> <span class="pl-s">'world'</span><span class="pl-kos">;</span></pre></div>
<ol start="4" dir="auto">
<li>edit <code class="notranslate">main.js</code> to the following and save it:</li>
</ol>
<div class="highlight highlight-source-diff notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="+import { world } from &quot;./new.js&quot;;
console.log(&quot;hello&quot;);
+console.log(world);"><pre class="notranslate"><span class="pl-mi1"><span class="pl-mi1">+</span>import { world } from "./new.js";</span>
console.log("hello");
<span class="pl-mi1"><span class="pl-mi1">+</span>console.log(world);</span></pre></div>
<p dir="auto">When saving it, we get:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Watcher File change detected! Restarting!
hello
world
Watcher Process terminated! Restarting on file change..."><pre class="notranslate"><code class="notranslate">Watcher File change detected! Restarting!
hello
world
Watcher Process terminated! Restarting on file change...
</code></pre></div>
<ol start="5" dir="auto">
<li>edit the value of <code class="notranslate">world</code> in <code class="notranslate">new.js</code> and save it:</li>
</ol>
<div class="highlight highlight-source-diff notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="-export const world = &quot;world&quot;;
+export const world = &quot;Deno!&quot;;"><pre class="notranslate"><span class="pl-md"><span class="pl-md">-</span>export const world = "world";</span>
<span class="pl-mi1"><span class="pl-mi1">+</span>export const world = "Deno!";</span></pre></div>
<p dir="auto">When saving it, nothing happens although we expect <code class="notranslate">hello\nDeno!</code> to be printed.</p>
<p dir="auto">I've already found the cause of this problem in the watcher implementation. This is because module resolution is done only once at the starting of the watcher. Basically we should resolve module every time any event is detected.</p>
<p dir="auto">I'll look into this problem deeply and try to elabolate a solution.</p>
<p dir="auto">to reproduce:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="watching A.ts
creating B.ts
editing A.ts to import B
editing B.ts
watcher doesn't restart"><pre class="notranslate"><code class="notranslate">watching A.ts
creating B.ts
editing A.ts to import B
editing B.ts
watcher doesn't restart
</code></pre></div>