为什么没有完全部署,会赢得Angular Firebase云功能模拟器更新功能?

时间:2018-05-06 18:24:22

标签: angular firebase google-cloud-functions firebase-cli

我正在尝试设置我的开发环境。我在Windows 10计算机上使用Angular 5 TypeScript,VisualStudio IDE。我使用的是Firebase托管,Firestore和Firebase功能。我在'函数中编写函数' TypeScript(index.ts)文件中的文件夹。按照本地测试Firebase功能的说明进行操作(https://firebase.google.com/docs/functions/local-emulator)。我能够通过" firebase serve"在本地服务器上获得本地运行的功能。并通过函数Shell,如链接中所述。但是,当我对index.ts进行更改时,再次进行ping操作时不会更新该函数。它仅在我执行完整的" firebase部署功能时更新。命令。这违背了拥有本地函数模拟器的目的。我们的想法是避免在每次更改内容时都必须部署函数。也许,firebase.json的东西?我将其与“&n;”版本'。

的输出一起复制到下面
Angular CLI: 1.6.8
Node: 6.11.5
OS: win32 x64
Angular: 5.2.4
... cdk, common, compiler, compiler-cli, core, forms, http
... language-service, material, platform-browser
... platform-browser-dynamic, router

@angular/animations: 5.2.5
@angular/cli: 1.6.8
@angular-devkit/build-optimizer: 0.0.42
@angular-devkit/core: 0.0.29
@angular-devkit/schematics: 0.0.52
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.9.8
@schematics/angular: 0.1.17
typescript: 2.5.3
webpack: 3.10.0


// firebase.json
{
  "functions": {
    "predeploy": [
      "npm --prefix \"$RESOURCE_DIR\" run lint",
      "npm --prefix \"$RESOURCE_DIR\" run build"
    ],
    "source": "functions"
  },
  "hosting": {
    "public": "dist",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ],
    "rewrites": [
      {
        "source": "**",
        "destination": "/index.html"
      }
    ]
  },
  "database": {
    "rules": "database.rules.json"
  }
}

1 个答案:

答案 0 :(得分:1)

TypeScript具有将代码转换为JavaScript(ES6)所需的转换阶段,云函数可以理解这一阶段。为了让模拟器获取更改,您必须进行转换阶段。

使用Firebase CLI为新的TypeScript项目创建的package.json,您可以运行npm run build进行转换而无需部署。或者,您可以使用tsc --watch让进程自动将更改转换为您的TypeScript。

听起来你的package.json可能很旧,并且不包含用于处理TypeScript的最新npm脚本。如果您没有npm run build,我建议您使用最新版本的Firebase CLI重新创建它。

另外,我写了一篇关于此问题的详细博客 - you can read it here

相关问题