[Bug]: rspack.experiments.VirtualModulePlugin would cause a removed module log
System Info
@rspack/core 1.5.4 1.5.5
Details
chain
.plugin('rsbuild-plugin-virtual-module')
.use(rspack.experiments.VirtualModulesPlugin, [
{
'./src/virtual-json-list.js': '11;',
},
]);
Reproduce link
https://github.com/rspack-contrib/rsbuild-plugin-virtual-module/tree/syt/virtual-module-issue
Reproduce Steps
-
git clone https://github.com/rspack-contrib/rsbuild-plugin-virtual-module.git
-
git checkout syt/virtual-module-issue
-
cd ./playground
-
npm run dev
Update: This also resulted in an unnecessary rebuild
This happens because Watcher is trying to watch virtual files, but they don't exist, so Watcher will always return file removed. It's easy to ignore them in Watcher, but I doubt if it's right to impl it as webpack would rebuild too.
since it's actually a watchpack issue(which doesn't support custom fs) we can only fix it in native-watcher(which should support inputfs)
Please refrain from using VirtualModulesPlugin for now if you find the log annoying. I'm planning to do a full refactor on the native watcher to support custom FileSystem.