【问题标题】:Trying to build Jest is throwing "Caching was left unconfigured."尝试构建 Jest 会抛出“缓存未配置”。
【发布时间】:2018-11-29 01:39:37
【问题描述】:

我在根文件夹中有以下.babelrc.js

{
       "plugins": [
           "@babel/plugin-transform-flow-strip-types",
           "@babel/plugin-transform-modules-commonjs",
           "@babel/plugin-transform-async-to-generator",
           "@babel/plugin-transform-strict-mode",
           "@babel/plugin-transform-runtime"
       ],
       "cache": "true"
}

但是当它尝试运行 node ./packages/jest-cli/bin/jest.js 时,我看到了:

缓存未配置。可以配置 Babel 的 plugins、presets 和 .babelrc.js 文件 对于各种类型的缓存,使用它们的处理函数的第一个参数:

我错过了什么?

【问题讨论】:

    标签: jestjs babeljs


    【解决方案1】:

    使用新的babel.config.js

    https://new.babeljs.io/docs/en/next/babelconfigjs.html

    module.exports = function(api) {
      api.cache(true)
      return {
        plugins: [
          "@babel/plugin-transform-flow-strip-types",
          "@babel/plugin-transform-modules-commonjs",
          "@babel/plugin-transform-async-to-generator",
          "@babel/plugin-transform-strict-mode",
          "@babel/plugin-transform-runtime"
        ]
      }
    }
    

    【讨论】:

    • api.cache(true) 是干什么用的?它有什么作用?文档仍然不完整:(谢谢
    • @NickGnd 基于packages/babel-core/src/config/caching.js的来源,api.cache(true)cache.forever()相同,api.cache(false)cache.never()相同
    猜你喜欢
    • 2018-03-25
    • 2018-10-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-04
    • 2018-11-21
    • 1970-01-01
    相关资源
    最近更新 更多