5

I am looking into converting my current babel.config.js file to a babel.config.mjs file. This should be straight forward but for some reason I am getting the following error when I try to use the function parameter api in my configuration:

Cannot change caching after evaluation has completed.

Here is my config, pretty barebones:

export default function(api) {
  api.cache(true) // if I remove this then it will work
  return {
    plugins,
    presets
  };
}
Yves M.
  • 29,855
  • 23
  • 108
  • 144
sotiristherobot
  • 259
  • 3
  • 10

1 Answers1

0

api.cache(true), enables caching for the Babel configuration. The error is often tied to modifying the babel configuration caching after evaluation.

In a .babelrc.mjs or babel.config.mjs file, api.cache shouldn’t be used as the module-based configuration is cached by Node.js. so no need for manual enabling caching.

the fix should be to remove the api.cache(true) line:

export default function() { return { plugins, presets }; }

Hopefully, this should fix the issue. I hope it does.

DrJay
  • 111
  • 4