LoginSignup
4
2

More than 3 years have passed since last update.

babel.config.js で 以下のエラーが出てビルドできない "Error: Caching was left unconfigured. Babel's plugins, presets, and .babelrc.js files can be configured"

Posted at

以下のようなエラーが出て、babelでトランスパイルできない。webpackでbabelを使っている場合、webpackでビルドができない。

Error: Caching was left unconfigured. Babel's plugins, presets, and .babelrc.js files can be configured


for various types of caching, using the first param of their handler functions:

module.exports = function(api) {
  // The API exposes the following:

  // Cache the returned value forever and don't call this function again.
  api.cache(true);
...

対応方法

babel.config.jsに以下を加える

module.exports = function(api) {
  api.cache(true);

  ...

背景

babel関連のパッケージのバージョンをあげたら上記エラーが出るようになった。
エラーメッセージに書いてある通り、api.cacheを呼び出せばビルドできるようになった。

なぜか

babelもしくはbabel関連のバージョンが新しいとこの問題が起きると思われる。
.babelrcbabel.config.jsonではなく、babel.config.jsを使って動的に設定をしている場合にキャッシュの設定が必須になった為にこのエラーが起きると思われる。

参考

公式document
- https://babeljs.io/docs/en/config-files#apicache

あとがき

詳細は調べていない。この問題が起きるバージョンがいくつからなのかも調べていない。
この記事は、このエラー文言でとりあえず検索した人が、とりあえず対応方法が分かるように作ったもの。

4
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
2