Last 12 weeks · 0 commits
4 of 6 standards met
Due to v8 stack traces only going so many deep by default, modules deep enough in the dependency tree such that clear has been called >~8 times do not get cleared. This is because resolve/parentModule relies on the v8 stack trace. It seems to me we don't need to resolve moduleId when calling it recursively from within clear, since children are absolute paths. I've copied this module into our project and fixed as so:
When clearing a module, certain child modules seem to be skipped. This seems to be because the array is mutated with an -call inside the next recursive call to , skipping certain indices in the outer -loop over children. Making a new array fixes the issue. Looking at the test , before using , is executed. I am not sure if this is part of the expected usage of the function, but the test fails if it is removed. If you swap the order of the imports in , the test succeeds. I chose to split the commits into three so that you may first review the failing test, and then consider how the fix should look.
Repository: sindresorhus/clear-module. Description: Clear a module from the cache Stars: 183, Forks: 18. Primary language: JavaScript. Languages: JavaScript (98%), TypeScript (2%). License: MIT. Latest release: v4.1.2 (4y ago). Open PRs: 0, open issues: 4. Last activity: 4y ago. Community health: 71%. Top contributors: sindresorhus, omrilotan, BendingBender, mrchief, Richienb, sondregj.
Added support for filtering when running clear. This is completely backwards compatible. I had an issue where i had 2 modules that use the same sub module, but clearing one, cleared the sub module for both of them, causing the other module to error. This would allow me to exclude specific modules out of the sub children list, and gives me absolute control over which ones to remove and which to keep
Hi, i'm having some problems trying to make this module running on my code (i'm quite sure i didn't fully get the whole cache concept) Maybe it is a stackoverflow question, in that case feel free to tell me :) Here i prepared a small repo as example install the modules with and then run it with This code prints every 500ms a value. This value comes from a delegate. Now if i change while the code is running the value returned by get-points.js it does not do anything... i would expect a change, right? Thanks for your considerations!