-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle invalidating cache if dependency is a globAsset #1417
Conversation
src/FSCache.js
Outdated
mtime = fileStats.mtime.getTime(); | ||
} | ||
} | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit-pick: use Promise.all
for better perf:
if (isGlob(filename)) {
let files = await glob(filename, {
strict: true,
nodir: true
});
mtime = (
await Promise.all(
files.map(file =>
fs.stat(file).then(({mtime}) => mtime.getTime())
)
)
).reduce((a, b) => Math.max(a, b), 0)
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll change it
Maybe it would simplify things if we just marked all GlobAssets as non-cacheable? That way the cache wouldn't need to have specific logic about them. Alternatively we could use the Right now we always need to run |
@devongovett Won't this invalidate the parent asset as well? as the main edit in this PR is dependencies. |
When you module.exports = {
test: require('./foo/test.js'),
bar: require('./foo/bar.js')
}; That's the "file" that you are needing to invalidate when files are added/removed. So if we just don't cache that at all, it should just work for free. Not sure we would gain anything by caching it since we need to check it every time anyway. |
Codecov Report
@@ Coverage Diff @@
## master #1417 +/- ##
=========================================
+ Coverage 87.96% 89.1% +1.13%
=========================================
Files 80 81 +1
Lines 4653 4679 +26
=========================================
+ Hits 4093 4169 +76
+ Misses 560 510 -50
Continue to review full report at Codecov.
|
8b11801
to
6dff3f2
Compare
Duplicate of #1414
This is needed to properly invalidate and cache styl files as they allow glob requires.
But I kind of messed up a rebase, so here is a clean version
Closes #1546