angular / angular/angularfire

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

オープン
#3,283 コメント 1 件 リアクション 1 件 担当者 0 名 GitHub で見る
主要言語
TypeScript
スター
7.8k
フォーク
2.2k
平均マージ
22時間 28分
マージ済み PR(30日)
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 を短くまとめたダイジェスト。