metro icon indicating copy to clipboard operation
metro copied to clipboard

[bug] Not possible to fully disable caching using Babel api

Open serhiipalash opened this issue 5 years ago • 2 comments

Is there a way to fully disable React Native Packager caching?

We have a very small application that is only used for showing the assets. All assets files are imported automatically from special directory using babel-plugin-codegen. The problem is that these imports do not regenerate on files change. It seems that Babel just doesn't support partial caching. So, the solution is to rebuild the whole app every time it reloads in Simulator.

Unfortunately methods described in Babel docs don’t work for some reason with Metro Bundler. This is our babel.config.js

module.exports = function (api) {
  api.cache.never()

  return {
    presets: ['module:metro-react-native-babel-preset'],
    plugins: ['macros']
  }
}

and these are our dependencies (project is created with react-native init yesterday)

"react-native": "0.62.2"
"metro-react-native-babel-preset": "^0.58.0",

Thanks for your help in advance!

serhiipalash avatar Apr 25 '20 11:04 serhiipalash

@serhiipalash did you find a solution for this? I am experiencing this with another babel-plugin, called react-native-dotenv.

f4z3k4s avatar May 18 '21 15:05 f4z3k4s

@serhiipalash Metro has its own per-file caching. Have you tried setting the cacheStores in the metro config to an empty list (no caching, even for incremental builds) or set resetCache: true (no caching for first build after metro starts)

MichaReiser avatar May 18 '21 15:05 MichaReiser