Skip to content

wipeCache is slow on large projects #20

@theKashey

Description

@theKashey

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 protectNodeModules plugin.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions