-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Cache babel-transpiled code #352
Conversation
dd21358
to
bd36318
Compare
Compared to master branch (see results in #351), now test runs take ~0.7s, given the same test files. |
d4d4377
to
844fad9
Compare
I don't think we should put cached files in the home dir. Users will not be able to find and clear them. For If you are storing in the home dir, then you need to take extra care salting the hash with the versions of Babel and every plugin used. That would still be a good idea in a local cache, but less critical since it's easier to clear the cache. |
I like the |
// @floatdrop |
Good suggestion! Update is coming. |
also, I wrote |
844fad9
to
8add554
Compare
@sindresorhus @jamestalmage PR updated to store cache in |
appendPaths: module.paths | ||
}); | ||
var cachePath = hasha(testPath); | ||
var hashPath = hasha(testPath) + '_hash'; |
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.
cachePath + '_hash'
instead of invoking hasha twice
74fc5a9
to
6e4c5b2
Compare
LGTM. @jamestalmage ? Tried it on |
The cache is currently saved in I think the solution to this is to do: pkgDir.sync(path.dirname(filename)) However, there is a chance they are using a global install, and do not have a
We should probably salt the hash with |
Why don't we just fallback to Regarding cache, when do you think users would want to clear it? |
Because caches cause problems. The one CSE joke I know is about cache invalidation. I can't think of a single piece of software I use that is so absolutely confident in its caching strategy that it does not provide a means for me to clear it. My browser, my IDE, As a practical example, the first thing I can think of is Perhaps, when we can't resolve their node modules folder, we do put it with the global AVA install and just provide a |
Not sure about this. It would mean when the user upgrades to a new AVA version, that might change how the cache works, the existing cache is still kept around. Should at least then be
👍
👍 Actually, we should make the salt based on the versions of the various Babel related packages. Upgrades to any of them should invalidate the cache.
We now have multiple ways the cache can go wrong and when in
I don't see the point of a flag if we only put the cache in |
That makes it (only a little) harder to script removing the directory. I was going to suggest we include the AVA version in the salt. I'm fine with this approach though. I just really want it in their root
I think we are going to find that difficult and costly. Babel doesn't do that in it's own cache implementation. To actually do that right, you would need to resolve the
Agreed. That was offered as a workaround for my concerns with global installs. If we disable |
👍 AVA version in the salt would be even better.
Ok, lets not do it then. |
6e4c5b2
to
4dc5c7d
Compare
4dc5c7d
to
0daec3e
Compare
|
||
var opts = JSON.parse(process.argv[2]); | ||
var testPath = opts.file; | ||
|
||
var cache = cacha(path.join(pkgDir(path.dirname(testPath)), 'node_modules', '.cache', 'ava')); |
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.
So, the cache is being stored in node_modules/.cache/ava
, but later down this file versions from ava & babel-* packages are being included in the cache key.
That way, when users rm -rf node_modules/.cache/ava
, they can be sure they removed all the cache. And they won't need to get the AVA version to remove ava-0.8.0
(for example).
So, are we good on this? Would really like to get it in before the release, so that users don't experience bad performance. |
Cache babel-transpiled code
👍 |
Originated from #351, inspired from #189.
This PR was created to avoid retranspiling test files on every run and even
require('babel-core')
. MD5 hash of test file gets calculated and if stored hash equals current hash, AVA loads transpiled code from cache.