webpack-virtual-modules icon indicating copy to clipboard operation
webpack-virtual-modules copied to clipboard

[Bug] Webpack 3 and 5 rebuild all virtual modules on any change

Open non25 opened this issue 3 years ago • 1 comments

  • [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.

non25 avatar Nov 26 '20 17:11 non25

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?

andy0130tw avatar Apr 07 '21 10:04 andy0130tw

Closing the issue as stale, please retest on latest webpack-virtual-modules and reopen with reproduction steps if the issue still exists.

larixer avatar Nov 01 '22 06:11 larixer