Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does api.cache(true) do in Expo's babel.config.js?

This line appears in the default Expo babel.config.js, but I can't find any reference anywhere to what it does. Is there anyone who knows what this does?

module.exports = function(api) {
  api.cache(true);
  return {
    presets: ['babel-preset-expo'],
  };
};
like image 882
Slbox Avatar asked Dec 12 '18 00:12

Slbox


People also ask

What is the use of Babel config JS?

Babel has two parallel config file formats which can be used together, or independently. . babelrc would be useful if you want to run certain transformations / plugins on a subset of files /directories. Maybe you have 3rd party libraries that you don't want to be transformed/changed by babel.

What does Babelrc file do?

babelrc file is your local configuration for your code in your project. Generally you would put it in the root of your application repo. It will affect all files that Babel processes that are in the same directory or in sibling directories of the . babelrc .

Where is Babel config JS react?

Where can I find the babel configuration of a non ejected application made with create-react-app ? It's in the Webpack config of the react-scripts/config directory.


1 Answers

By default, Babel will evaluate configuration each time it processes a new file. It is possible to optimize the build process performance by caching config function execution result. api.cache(true) does exactly that. When the cache is enabled this way, config function will be called only once.

Here is a link for a more detailed explanation of Babel configuration caching: https://babeljs.io/docs/en/config-files#apicache

like image 174
Alex Musayev Avatar answered Oct 17 '22 08:10

Alex Musayev