metro
metro copied to clipboard
Caching Examples
Are there good examples for FileStore and NetworkStore cache configurations in metro?
Are there any updates on this after two years?
I've managed to use FileStore
on my project.
If you check this file, you will notice that the metro-cache
module exports the FileStore
class.
No documentation is given of the options needed to create a new instance of the FileStore
, but inspecting on the constructor of the FileStore
class, I concluded that the root
option is the directory where the cache will be saved.
My goal was to save Metro's cache on the project's root directory, so that I could cache it between builds on CircleCI. Therefore, my metro.config.js
on a React Native / Expo (managed) project looked like this:
const { resolve } = require('path');
const { FileStore } = require('metro-cache');
module.exports = (async () => ({
cacheStores: [
new FileStore({ root: resolve(__dirname, '.metro-cache') }),
],
}))();
Anyway, I can't see the NetworkStore
class on the metro-cache
package, maybe the HttpGetStore
or HttpStore
can fullfil that role?
Hope it helps