javascript - babel-plugin-rewire 无法正常使用 React Native 项目
问题描述
我目前正在创建一个小型 React Native 应用程序。为了测试,我声明使用 babel-plugin-rewire 来访问未导出的函数。现在我的所有测试都运行良好,但如果我尝试运行我的应用程序,我会收到以下错误:
node_modules\@react-navigation\native\src\NavigationContainer.tsx: C:\node_modules\@react-navigation\native\src\NavigationContainer.tsx: Property typeName of
TSTypeReference expected node to be of a type ["TSEntityName"] but instead got "CallExpression"
transform[stderr]: The exported identifier "_DefaultExportValue" is not declared in Babel's scope tracker
transform[stderr]: as a JavaScript value binding, and "@babel/plugin-transform-typescript"
transform[stderr]: never encountered it as a TypeScript type declaration.
transform[stderr]: It will be treated as a JavaScript value.
transform[stderr]:
transform[stderr]: This problem is likely caused by another plugin injecting
transform[stderr]: "_DefaultExportValue" without registering it in the scope tracker. If you are the author
transform[stderr]: The exported identifier "_DefaultExportValue" is not declared in Babel's scope tracker
transform[stderr]: as a JavaScript value binding, and "@babel/plugin-transform-typescript"
transform[stderr]: never encountered it as a TypeScript type declaration.
transform[stderr]: It will be treated as a JavaScript value.
transform[stderr]:
transform[stderr]: This problem is likely caused by another plugin injecting
transform[stderr]: "_DefaultExportValue" without registering it in the scope tracker. If you are the author
transform[stderr]: of that plugin, please use "scope.registerDeclaration(declarationPath)".
我的项目是用 JS 编写的。
.babelrc:
{
"plugins": [
["@babel/plugin-transform-flow-strip-types"],
[
"module-resolver",
{
"root": ["./src/main"],
"alias": {
"src": "./src/main",
"resources": "./src/main/resources"
}
}
],
["transform-inline-environment-variables"],
["babel-plugin-rewire"]
]
}
我已经搜索过,但从未找到有帮助或与 babel-plugin-rewire 相关的东西。
已经感谢您的帮助。
干杯
解决方案
推荐阅读
- html - HTML 电子邮件 - href 属性未在某些设备中隐藏
- java - 错误 404 - 使用 @RestController 获取请求 - SpringBoot
- c# - 在 IIS 上为 C# IIS 重置器应用程序模拟服务器错误
- excel - Excel 无法加载基本的自定义函数加载项
- grails - Grails 3:Spring Security Rest 返回登录页面
- mysql - 如何从逗号分隔值的字段中选择不同值的列表?
- docker - 如果文件的源路径不同但目标和内容相同,如何有效地使用 docker 缓存?
- oracle - 如果在 PL/SQL 中存在 - 如果不存在,如何使用?
- jenkins - spec.volumes[1].name:重复值:“workspace-volume”
- docker - 使用 nginx docker 部署 react 应用程序时如何使路由工作