-
Notifications
You must be signed in to change notification settings - Fork 32
wipeCache is slow on large projects #20
Description
Thousand of files could greatly slowdown wiping cache before and after mocking. It is just a few milliseconds, and they form seconds...
The problem is simple - wipe-node-cache goes thought all cache entities and asks "should I wipe it", next rewiremock checks it, at least 3 times - does mock exists, that plugins think, what if filename is incomplete.
Few simple checks per thousands of files.
The goal is simple - you can mock something anywhere, and rewiremock will wipe anything "between" that file and entry point.
The fix:
-
mocks with absolute paths should be wiped directly - O(1) lookup
-
mocks with relative paths could operate on inverse index (I mean reverse string order) - O(1) lookup
-
proxy/around should support auto naming resolution.
-
thus - shouldMock shall not be able to mock something, only to prevent something from mocking. Actually, as it currently does in
protectNodeModulesplugin.