angular / angular/angularfire

Function deployment not uploading referenced package.json file when built with @angular/fire:deploy

未關閉
#3,283 1 則留言 1 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
TypeScript
星號
7.8k
分支
2.2k
平均合併
22 小時 28 分鐘
30 天內合併 PR
6

描述

### Version info

**Angular:** 14.2.0

**Firebase:** 11.15.0

**AngularFire:** 7.4.1

**Other (e.g. Ionic/Cordova, Node, browser, operating system):**

### How to reproduce these conditions
Use `@angular/fire:deploy` for an Angular Universal app

**Failing test unit, Stackblitz demonstrating the problem**

**Steps to set up and reproduce**
Use an Nx workspace and add Angular Universal, then include `@angular/fire:deploy` builder (in Nx terms "executor") in `project.json`:
```json
"deploy": {
"executor": "@angular/fire:deploy",
"options": {
"ssr": true,
"firebaseProject": "my-project",
"functionsNodeVersion": 16,
"firebaseHostingSite": "my-site"
},
"configurations": {
"production": {
"browserTarget": "my-app:build:production",
"serverTarget": "my-app:server:production"
}
}
},
```
This generates a production build in the `dist` folder with the following structure:
```
dist /
my-app /
dist /
my-app /
browser
server
node_modules /
index.js
package.json
package-lock.json
```

In the `package.json` file that resides in the `dist` folder is a reference like so:
```
{
// [...]
"my-app": "file:../.."
}
```
The firebase configuration is set up like so:
```json
{
"functions": [
{
"source": "dist/my-app",
"codebase": "default",
"ignore": ["node_modules"]
}
]
}
```

Upon running `firebase deploy --only functions` it errors out (see section below for logs). It seems files outside the `source` are not uploaded to firebase functions and so `@angular/fire:deploy` can't be used to deploy functions.

I can confirm this with the following steps. I remove the line `"my-app": "file:../.."` from the generated `package.json` and remove the `node_modules` and `package-lock.json` in the `dist` folder. Then I run `npm install` in the `dist` folder. When done, I run `firebase deploy --only functions` and it works.

**Sample data and security rules**

### Debug output

** Errors in the JavaScript console **
When running `firebase deploy --only functions` the following output is generated:
```
Build failed: npm ERR! code EUSAGE
npm ERR!
npm ERR! The `npm ci` command can only install with an existing package-lock.json or
npm ERR! npm-shrinkwrap.json with lockfileVersion >= 1. Run an install with npm@5 or
npm ERR! later to generate a package-lock.json file, then try again.
npm ERR!
npm ERR! Clean install a project
npm ERR!
npm ERR! Usage:
npm ERR! npm ci
npm ERR!
npm ERR! Options:
npm ERR! [--no-audit] [--foreground-scripts] [--ignore-scripts]
npm ERR! [--script-shell ]
npm ERR!
npm ERR! aliases: clean-install, ic, install-clean, isntall-clean
npm ERR!
npm ERR! Run "npm help ci" for more info

npm ERR! A complete log of this run can be found in:
npm ERR!

Functions deploy had errors with the following functions:
ssr(us-central1)
i functions: cleaning up build files...

Error: There was an error deploying functions
```

** Output from `firebase.database().enableLogging(true);` **

** Screenshots **

### Expected behavior
`@angular/fire:deploy` should generate output that can be uploaded to functions as is.

### Actual behavior
Functions cannot be deployed because the reference in the generated `package.json` is outside the `source` folder.

貢獻指南

開啟貢獻指南

研究方向

從 project.json 中的 @angular/fire:deploy builder 設定開始,檢查產生的 dist/my-app/package.json,尤其是其中的 file:../.. 參照。使用 firebase deploy --only functions 重現,並確認產生的輸出可以在不參照設定的 functions 來源目錄之外檔案的情況下部署。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
angular, firebase, node.js, typescript
領域
backend, cloud, devops
Issue 類型
缺陷
難度
3/5
預估耗時
1-2 天
活躍度
停滯
描述清晰度
基本清楚
新手友好度
45/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。