<h1 dir="auto">Bug report</h1>




<p dir="auto"><strong>What is the current behavior?</strong><br>
When a webpack configuration includes <code class="notranslate">resolve: { symlinks: false }</code>, dependencies that are linked into the <code class="notranslate">node_modules</code> folder as symlinks do not get watched properly by webpack-dev-server: changes to those dependencies do not trigger a rebuild or browser refresh.</p>
<p dir="auto">It is my understanding that using the <code class="notranslate">resolve.symlinks</code> property in this way is valid and shouldn't cause this issue.  In the real application where this was discovered, we are using <code class="notranslate">resolve.symlinks</code> to avoid errors resulting from the symlinked module pulling in duplicate copies of other dependencies (React specifically).</p>
<p dir="auto"><strong>If the current behavior is a bug, please provide the steps to reproduce.</strong></p>
<p dir="auto">Please see <a href="https://github.com/rpokorny/webpack-link-bug">https://github.com/rpokorny/webpack-link-bug</a> for a reproduction of the issue.</p>






<p dir="auto"><strong>What is the expected behavior?</strong><br>
When a file in the symlinked dependency is modified, the change should automatically get picked up resulting in a rebuild of the bundle and a refresh of the webpage if it is open in a browser.</p>


<p dir="auto"><strong>Other relevant information:</strong><br>
webpack version:  5.24.3<br>
Node.js version: 12.18.0<br>
Operating System: Linux 5.10.14-arch1-1<br>
Additional tools: webpack-dev-server 3.11.2</p>
<h1 dir="auto">Bug report</h1>




<p dir="auto"><strong>What is the current behavior?</strong><br>
I install deps with <a href="https://github.com/cnpm/npminstall">npminstall</a>(it can install faster), but the file tree in <code class="notranslate">node_modules</code> is special bacause npminstall install pkgs with symbol link to download and write less files.</p>
<p dir="auto">The file tree looks like this</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="app
├── index.js
└── node_modules
    ├── _a@1.0@a(real dir)
    |   ├── index.js
    |   └── node_modules
    |       └── b(symbol link to app/node_modules/_b@1.0@b)
    ├── _b@1.0@b(real dir)
    |   ├── index.js
    |   └── node_modules
    |       └── a(symbol link to app/node_modules/_a@1.0@a)
    ├── a(symbol link to app/node_modules/_a@1.0@a)
    └── b(symbol link to app/node_modules/_b@1.0@b)"><pre class="notranslate"><code class="notranslate">app
├── index.js
└── node_modules
    ├── _a@1.0@a(real dir)
    |   ├── index.js
    |   └── node_modules
    |       └── b(symbol link to app/node_modules/_b@1.0@b)
    ├── _b@1.0@b(real dir)
    |   ├── index.js
    |   └── node_modules
    |       └── a(symbol link to app/node_modules/_a@1.0@a)
    ├── a(symbol link to app/node_modules/_a@1.0@a)
    └── b(symbol link to app/node_modules/_b@1.0@b)
</code></pre></div>
<p dir="auto">Because of a,b is reference by each other, <code class="notranslate">contextTimestampQueue</code> and <code class="notranslate">contextHashQueue</code> in <code class="notranslate">FileSystemInfo</code> will never reach the end.</p>
<p dir="auto"><strong>If the current behavior is a bug, please provide the steps to reproduce.</strong></p>






<p dir="auto">The minimal reproduction repo is <a href="https://github.com/killagu/npminstall_webpack">here</a>.<br>
The reproduce step is</p>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="git clone git@github.com:killagu/npminstall_webpack.git
cd npminstall_webpack
npm i -g cnpm
# must use cnpm install
cnpm i
npm run build"><pre class="notranslate">git clone git@github.com:killagu/npminstall_webpack.git
<span class="pl-c1">cd</span> npminstall_webpack
npm i -g cnpm
<span class="pl-c"><span class="pl-c">#</span> must use cnpm install</span>
cnpm i
npm run build</pre></div>
<p dir="auto">Build snapshow will fail.</p>
<p dir="auto"><strong>What is the expected behavior?</strong></p>
<ul dir="auto">
<li>Use <code class="notranslate">fs.lstat</code> to get file info, and use target path to process.</li>
<li>Skip files if has been processed</li>
</ul>


<p dir="auto"><strong>Other relevant information:</strong></p>
<p dir="auto">webpack version:  5.11.0<br>
Node.js version: 12.16.3<br>
Operating System: macOS Big Sur 11.0.1 (20B29)</p>
<p dir="auto">If it is ok, I'm happy to make a pr to fix it.</p>