小编sch*_*der的帖子

Apollo - 构建生产构建时的 React(Typescript)不变错误

我正在使用 gatsby、typescript 和 apollo(用于 graphql 查询)创建一个新的 React 应用程序。

在 dev 中进行测试时,应用程序编译并运行时不会抛出任何错误。

当我使用“gatsby build”转换构建时,它失败并出现错误。

我不明白为什么或在哪里触发。这似乎与 webpack 在构建时检查的方式有关,但我不知道如何查明问题,而且似乎没有任何材料可以为我提供明确的答案。

这似乎是由 httplink 模块引起的。出现在任何 .tsx 文件中时触发错误的代码是:

import { HttpLink } from 'apollo-link-http'

const link = new HttpLink({
  uri: 'http://localhost:3001/graphql'
})
Run Code Online (Sandbox Code Playgroud)

显示的错误如下:

error Building static HTML failed

See our docs page on debugging HTML builds for help https://gatsby.dev/debug-html

  10 |     function InvariantError(message) {
  11 |         if (message === void 0) { message = genericMessage; }
> 12 |         var _this = _super.call(this, typeof message ===     "number" …
Run Code Online (Sandbox Code Playgroud)

typescript apollo reactjs webpack gatsby

7
推荐指数
1
解决办法
2397
查看次数

标签 统计

apollo ×1

gatsby ×1

reactjs ×1

typescript ×1

webpack ×1