Closed aemoe closed 8 years ago
Thank you for your PR! Unfortunately, I cannot merge it as it's yet, because it's inefficient to invalidate the cache by each tree.match()
iteration. I think it'd be better to purge the cache once before running tree.match()
. Can you make the proper changes?
@maltsev thank you for your advise,i will try to find a better way that delete the cache of require.When I find, I will commit again.
@maltsev See also,yesterday I use an other way to resolve this bug, it use Node file stream. Cause of the file load every times, the cache will refresh. Shortly after,i will submit. What do you think that this way whether to resolve this bug? thx~ ~
fixed~ ~ test all pass~
The issue is still here: by each iteration a file with CSS modules is being re-read and re-parsed. I was thinking about using some simple cache. Something like this:
var cssModulesCache = {};
function getCssModules(cssModulesPath) {
var fullPath = require.resolve(cssModulesPath);
if (! cssModulesCache[fullPath]) {
delete require.cache[fullPath];
cssModulesCache[fullPath] = require(fullPath);
}
return cssModulesCache[fullPath];
}
// To purge the cache insert cssModulesCache = {}; before the tree.match()
I fixed this bug and published the new version. @aemoe please check if everything works fine for you.
thank for fixed this bug~
Thanks for the author, thank you for your code. When I use a gulp when using the watch mode, because of caching issues require cache, and update the json time, can not be read to json modified files, so I can not do it automatically updates results, so modified the code I hope you fixed.