gpt4 book ai didi

babeljs - Ava 附加 babel 插件未运行

转载 作者:行者123 更新时间:2023-12-02 10:38:17 24 4
gpt4 key购买 nike

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

ava dynamic syntax import enable support

我无法将其添加到我的主 .babelrc 文件中,因为我们正在 webpack 中实现 bundle 拆分。

为了解决这个问题,我尝试通过 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"]
}

最佳答案

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

关于babeljs - Ava 附加 babel 插件未运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52280096/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com