Currently the .blitz dev cache is not cleared between blitz start invocations for performance. That's great, but we've found that when the blitz version changes we need to bust that cache.
https://github.com/blitz-js/blitz/issues/1407 is an example error caused by the lack of this.
Basically we want to clean the cache anytime the installed blitz version changes.
Setting this clean config item to true will clean the cache. That spot is a possible place to do this.
Let me elaborate.
If blitz version in package.json is changed, we need to set clean in config to true right?
@rayandrews yes. So we need to cache the blitz version somehow inside .blitz so that each time blitz start runs, we can check the current blitz version with the cached version.
Also, we need to check the actual installed version of blitz, not just the version range in the app package.json. I think we can get the actual installed version with something like this:
const pkgJson = require(path.join(require.resolve('blitz'), 'package.json'))
I see, it makes sense now for the installed version @flybayer
However, how about the blitz version inside .blitz? Do we just use the package.json inside .blitz folder?
No, we don't currently store the blitz version. We could add a new file or maybe add a new field to .blitz/caches/dev/_manifest.json.
@ryardley any opinion on this?
I see, we can cache the version via this function
and re-read it while running in development to make sure the version is same or not @flybayer
Maybe we can store the blitz version in the cache hash?
could you give me the pointer of the cache hash?
I want to work on this.
is it similar like file-cache here or different?
@flybayer @ryardley
@rayandrews I was talking about the file tree hashing happening here: https://github.com/blitz-js/blitz/blob/canary/packages/server/src/build-hash.ts#L26
Looks like you can't add strings to hash object so I would be inclined to use a second hash function and hash the hash with the blitz version. eg. return sha1(tree.hash + blitzVersion);
CMIIW, hash runs only for production right?
so for summary:
tree.hash with blitzVersion with sha1(tree.hash + blitzVersion)developmentproduction command (checking the hash etc)am I right? @ryardley
Hmm maybe I am wrong and am misunderstanding this issue. If we are talking about a dev related thing. Yeah you might want to:
processNewFile function.clean flag.Got it @ryardley.
I understand now thank you.
Count me in and I will make a PR.
Thank you @ryardley @flybayer
Best Regards