ionic-team / ionic-team/ionic-cli

Don't use `--` when the `npmClient` is `pnpm`

Đang mở
#5,020 1 bình luận 1 reaction 0 người được giao Xem trên GitHub
triage
Ngôn ngữ chính
TypeScript
Star
2k
Fork
682
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

**Description:**

When running `ionic capacitor run android --livereload --external`, I get an endless loop of `[INFO] Waiting for connectivity with pnpm...`

```log
> pnpm run ionic:serve -- --host=0.0.0.0 --port=8100
[pnpm] > theia-mobile@0.1.1 ionic:serve /home/nato/Code/github.com/Omerlo-Technologies/theia-mobile
[pnpm] > vite dev "--" "--host=0.0.0.0" "--port=8100"
[pnpm] VITE v4.3.9 ready in 474 ms
[pnpm] ➜ Local: http://localhost:5173/
[pnpm] ➜ Network: use --host to expose
[pnpm] ➜ press h to show help
[INFO] Waiting for connectivity with pnpm...
[INFO] Waiting for connectivity with pnpm...
[INFO] Waiting for connectivity with pnpm...
```

The issue is that `pnpm run ionic:serve -- --host=0.0.0.0 --port=8100` doesn't work as expected because of that `--` in the middle. `--` is useful when you want `npm` to pass additional command-line arguments to scripts, but `pnpm` isn't limited by this restriction and it passes the whole thing. When `vite` receives that, it ignores everything after it.

This can be tested:

```sh
❯ vite dev --host=0.0.0.0 --port=8100

VITE v4.3.9 ready in 527 ms

➜ Local: http://localhost:8100/
➜ Network: http://192.168.1.213:8100/
➜ Network: http://192.168.1.214:8100/
➜ press h to show help

❯ vite dev -- --host=0.0.0.0 --port=8100

VITE v4.3.9 ready in 519 ms

➜ Local: http://localhost:5173/
➜ Network: use --host to expose
➜ press h to show help
```

**Steps to Reproduce:**

1. Have a Vite app (ex: SvelteKit)
2. Setup Capacitor and Ionic
```json
{
"name": "Hello World",
"integrations": {
"capacitor": {}
},
"type": "custom",
"npmClient": "pnpm"
}
```
3. Set these scripts in `package.json`
```json
"dev:android": "ionic capacitor run android --livereload --external",
"ionic:serve": "vite dev",
```
4. Run `pnpm dev:android`

**Output:**

**My `ionic info`:**

```yaml
Ionic:

Ionic CLI : 7.1.1 (/home/nato/.local/share/pnpm/global/5/.pnpm/@ionic+cli@7.1.1/node_modules/@ionic/cli)

Capacitor:

Capacitor CLI : 5.0.5
@capacitor/android : 5.0.5
@capacitor/core : 5.0.5
@capacitor/ios : 5.0.5

Utility:

cordova-res : not installed globally
native-run : not installed globally

System:

NodeJS : v20.2.0 (/usr/bin/node)
npm : 9.7.1
OS : Linux 6.2
```

**Other Information:**

Admittedly, this *could* be seen as a `vite` issue, but I it's possible that they would consider rejecting everything after `--` as a security benefit.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.