11

看起来 Expo Webpack 没有可选链接

当我尝试将UI Kitten安装到 Expo Web 应用程序时,我发现了这一点。

这是我将 UI Kitten 添加到新创建的 Expo 应用程序后的编译错误

node_modules/@ui-kitten/components/ui/input/input.component.js 104:38
Module parse failed: Unexpected token (104:38)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
|         this.webEventResponder = devsupport_1.WebEventResponder.create(this);
|         this.focus = () => {
>             this.textInputRef.current?.focus();
|         };
|         this.blur = () => {

Deps 版本(目前我在这里写的最新版本。)

  • expo@37.0.6
  • @ui-kitten/components@5.0.0-alpha.1

有什么技巧可以解决这个问题吗?

4

2 回答 2

5

Webpack 使用 Acorn 解析器,Acorn 目前不支持可选链

有一个待处理的拉取请求,您可以订阅它以获得有关进度的通知

因此,您的解决方法是:

  • 不要使用 webpack
  • 不要使用可选链
  • 将 Babel 集成到你的堆栈中,并确保首先通过 Babel 传递所有 *.js 文件,使用这个Babel 插件
  • 等待上述 PR 被合并,包含该 PR 的下一个版本发布
  • fork Acorn,自己合并 PR,然后 fork webpack 并使用你的 fork Acorn
于 2020-04-09T15:20:11.227 回答
1

As @connexo says, the workaround is to integrate a babel plugin. Also, this issue has already been discussed on the github.

于 2020-04-10T06:48:09.267 回答