【发布时间】:2019-07-27 08:13:29
【问题描述】:
我有一个项目,它使用 Parcel 来构建和 Babel 来编译。
当我尝试开玩笑时,我得到了
Test suite failed to run
ReferenceError: Unknown plugin "syntax-dynamic-import" specified in "/app/.babelrc" at 0, attempted to resolve relative to "/app"
通过Parcel正常运行发现插件成功,并在我的package.json的依赖项中列出&安装。
我的 babelrc:
{
"presets": [
"@babel/preset-env",
"@babel/preset-react"
],
"plugins": [
"@babel/syntax-dynamic-import",
],
"env": {
"test": {
"plugins": ["dynamic-import-node"]
}
}
}
在 package.json 中:
"dependencies": {
"@material-ui/core": "^3.6.0",
"@material-ui/icons": "^3.0.1",
"express": "^4.16.4",
"react": "^16.6.3",
"react-dom": "^16.6.3",
"jest": "^23.6.0",
"babel-jest": "^23.6.0",
"babel-plugin-dynamic-import-node": "^2.2.0"
},
"devDependencies": {
"@babel/core": "^7.1.6",
"@babel/plugin-syntax-dynamic-import": "^7.0.0",
"@babel/preset-env": "^7.0.0",
"@babel/preset-react": "^7.0.0",
"eslint-plugin-jsx-a11y": "^6.1.2",
"eslint-plugin-react": "^7.11.1",
"http-proxy-middleware": "^0.19.0",
"less": "^2.0.0",
"parcel-bundler": "^1.10.3",
"parcel-plugin-eslint": "^1.0.4"
},
完整的项目代码可以在on Glitch找到。重新混合项目以获得您自己的版本,您可以编辑并尝试在其上运行脚本。
【问题讨论】:
标签: jestjs babel-jest parceljs