Ava其他babel插件未运行

时间:2018-09-11 16:09:26

标签: babeljs babel ava dynamic-import

我正在尝试在运行Ava时使用其他babel插件来转译动态导入,以便它们可以在节点上运行(基于此响应)

ava dynamic syntax import enable support

由于我们正在Webpack中实现捆绑包拆分,因此无法将其添加到主.babelrc文件中。

要解决这个问题,我试图通过ava的babel配置包含插件。当我运行ava时,babel不使用其他插件。

package.json

{
  "dependencies": {
    "babel-cli": "6.16.0",
    "babel-core": "^6.26.3",
    "babel-eslint": "7.2.1",
    "babel-loader": "^7.1.2",
    "babel-plugin-dynamic-import-node": "^2.1.0",
    "babel-plugin-flow-react-proptypes": "^5.1.2",
    "babel-plugin-module-resolver": "^2.7.1",
    "babel-plugin-recharts": "1.1.0",
    "babel-plugin-syntax-dynamic-import": "^6.18.0",
    "babel-plugin-transform-async-to-generator": "^6.22.0",
    "babel-plugin-transform-builtin-extend": "^1.1.2",
    "babel-plugin-transform-class-properties": "^6.24.1",
    "babel-plugin-transform-flow-strip-types": "^6.22.0",
    "babel-plugin-transform-object-rest-spread": "^6.22.0",
    "babel-polyfill": "^6.23.0",
    "babel-preset-es2015": "6.16.0",
    "babel-preset-es2015-node": "^6.1.1",
    "babel-preset-react": "6.16.0"
  },
  "devDependencies": {
    "ava": "^0.24.0",
    "babel-preset-env": "^1.7.0",
    "babel-register": "6.16.3"
  },
  "ava": {
    "require": [
      "babel-register",
      "babel-polyfill",
      "ignore-styles"
    ],
    "babel": {
      "plugins": [
        "babel-plugin-dynamic-import-node"
      ]
    }
  }
}

.babelrc

{
  "plugins": [
    ["babel-plugin-transform-builtin-extend", {
      "globals": ["Error"]
    }],
    "recharts",
    "transform-object-rest-spread",
    "flow-react-proptypes",
    "transform-flow-strip-types",
    "transform-async-to-generator",
    "transform-class-properties",
    "syntax-dynamic-import",
    "react-hot-loader/babel",
    [
      "module-resolver",
      {
        "root": ["./src"],
        "alias": {
          "tests": "./tests"
        }
      }
    ]
  ],
  "presets": ["env", "react"]
}

1 个答案:

答案 0 :(得分:1)

0.24很老了。 Babel 6的最新版本是0.25,但是如果可能,您应该升级到Babel 7并使用最新的AVA 1.0 beta。