首页 > 解决方案 > 使用 preact-cli 的 Cloud Firestore 构建错误

问题描述

我正在尝试从 preact-cli 生成的项目中使用 Firebase 的 Cloud Firestore,但遇到了第一个障碍。我选择了 Firebase 的 v9 SDK,它处于测试阶段,以领先一步(但也许这是一个错误)。构建时,Firebase SDK 文件出现错误,但我不确定它是由 SDK 本身、babel、webpack、preact-cli 还是组合引起的。我也不知道如何诊断它,因为我是这些工具的新手。

下面的步骤,任何想法这个错误的原因可能是什么?

npx preact-cli create typescript webapp
npm install --save firebase@9.0.0-beta.1

然后在中src/components/app.tsx,通过添加使用 Firestore SDK

import { getFirestore } from "firebase/firestore";
getFirestore();

但是构建失败。

$ npm run build

> webapp@0.0.0 build
> preact build

 Build  [==                  ] 12% (1.3s) building(13200:6) switch-case fall-through not supported - added break. See https://github.com/MatAtBread/nodent#differences-from-the-es7-specification
[BABEL] Note: The code generator has deoptimised the styling of ../node_modules/@firebase/firestore/dist/exp/index.browser.esm2017.js as it exceeds the max of 500KB.
✖ ERROR ../node_modules/@firebase/firestore/dist/exp/index.browser.esm2017.js 5055:431
Module parse failed: Unsyntactic break (5055:431)
File was processed with these loaders:
 * ../node_modules/babel-loader/lib/index.js
You may need an additional loader to handle the result of these loaders.
(Source code omitted for this binary file)
 @ ../node_modules/firebase/firestore/dist/index.esm.js 1:0-36 1:0-36
 @ ./components/app.tsx
 @ ./index.ts

标签: firebasegoogle-cloud-firestorepreactpreact-cli

解决方案


推荐阅读