web-infra-dev / rsbuild

The Rspack-based build tool. It's fast, out-of-the-box and extensible.
https://rsbuild.dev/
MIT License
1.44k stars 115 forks source link

[Bug]: HMR doesn't trigger recompile in Docker on WSL2 #3193

Closed jan-bures closed 5 days ago

jan-bures commented 1 month ago

Version

System:
  OS: Linux 5.15 Debian GNU/Linux 12 (bookworm) 12 (bookworm)
  CPU: (20) x64 13th Gen Intel(R) Core(TM) i5-13600KF
  Memory: 12.61 GB / 15.54 GB
  Container: Yes
  Shell: 5.2.15 - /bin/bash
npmPackages:
  @rsbuild/core: 1.0.1-beta.11 => 1.0.1-beta.11 
  @rsbuild/plugin-svelte: 1.0.1-beta.11 => 1.0.1-beta.11

Details

When running Docker Desktop (with the WSL2 engine) on Windows 11, the dev server doesn't recompile files when HMR is triggered by saving changes, even though the websocket is connected and the page reloads.

The testing project where this occurs was created using npx create rsbuild@latest with the Svelte template.

In rsbuild.config.mjs, I am using usePolling: true in dev.watchFiles.options, similarly to my previous Vite setup, since without it, WSL doesn't register changes made from a Windows application.

Reproduce link

https://github.com/jan-bures/rsbuild-test-project

Reproduce Steps

  1. Execute docker compose up -d in the folder of the example project.
  2. Open http://localhost:3000 in a browser.
  3. Modify src/App.svelte and save the changes.
  4. The page in the browser gets refreshed but the changed files don't get recompiled.
chenjiahan commented 3 weeks ago

If the dev server doesn't recompile files after saving changes, it should be related to Rspack's watcher (watchpack)

Have you seen any logs like this: https://github.com/webpack/watchpack/issues/187?