[Bug] Webpack 3 and 5 rebuild all virtual modules on any change
- [x] I'd be willing to submit the fix
Describe the bug
Webpack 3 and 5 reloads and rebuilds all virtual modules on any change.
To Reproduce
Test is already in master branch. Disabled for webpack 3 and 5.
Additional context
I'm not sure what to do for now, but I thought a robust test for that problem could be useful as a start. See https://github.com/sysgears/webpack-virtual-modules/pull/78.
Some investigation: If you add some code in Watchpack, like
_onRemove(item, file, type) {
file = file || item;
+ console.log('!!! ON-REMOVE', item, file, type)
if (this.paused) return;
this.emit("remove", file, type);
if (this.aggregateTimer) clearTimeout(this.aggregateTimer);
this.aggregatedChanges.delete(item);
this.aggregatedRemovals.add(item);
this.aggregateTimer = setTimeout(this._onTimeout, this.aggregateTimeout);
}
it will print something like:
!!! ON-REMOVE /path/to/file.js /path/to/file.js scan (missing in initial scan)
one for each virtual file. Which causes Webpack think that the file system has changed. Does this relate to the watchFileSystem?
Closing the issue as stale, please retest on latest webpack-virtual-modules and reopen with reproduction steps if the issue still exists.