ionic-team / ionic-team/ionic-cli
ionic/cli commands in a (react based) monorepo aren't working consistently
還沒有人認領這個 Issue。
- 主要語言
- TypeScript
- 星號
- 2k
- 分支
- 681
- PR 合併指標
- 30 天內沒有已合併 PR
描述
**Description:**
ionic cli commands in a (react based) monorepo aren't working consistently.
**Steps to Reproduce:**
As per instructions, I've defined the `ionic.config.json` file at the root of my (Nx) monorepo, which has the following structure:
```
apps/
-- myapp/
dist/
-- apps/
-- myapp/
libs/
node_modules/
ionic.config.json
package.json
```
This is `ionic.config.json`:
```
{
"defaultProject": "myapp",
"projects": {
"reactr": {
"name": "myapp",
"integrations": {
"capacitor": {}
},
"type": "react",
"root": "apps/myapp"
}
}
}
```
Issues:
1. ionic cli searches the app root for custom build scripts
`ionic serve` doesn't work, as I'm not using react-scripts. Fine.
I tried adding `"ionic:serve": "npm start"` to my root `package.json` to no avail. I had to create `apps/myapp/package.json` and add the scripts there. Not too bad, but not intuitive and it tooks some trial & error.
2. `ionic cap` commands searches the app root for node_modules!
ionic capacitor is searched in `apps/myapp/node_modules/` instead of the root `node_modules`, so I've had to also add `@capacitor/core` and `@capacitor/cli` to `apps/myapp/package.json`, effectively duplicating these dependencies (in monorepos you want only 1 node_modules usually).
3. `ionic cap open ` must be launched in the app root
While ionic serve/build work from the monorepo root, ionic cap must be launched from the app's root, despite having specified the app's root in ionic.config.json
**My `ionic info`:**
```
Ionic:
Ionic CLI : 6.19.0 (C:\Users\andre\AppData\Roaming\nvm\v14.18.3\node_modules\@ionic\cli)
Ionic Framework : @ionic/react 6.0.11 (C:\Users\andre\Code\reac-tr\node_modules\@ionic\react)
Capacitor:
Capacitor CLI : 3.4.3
@capacitor/android : 3.4.3
@capacitor/core : 3.4.3
@capacitor/ios : 3.4.3
Utility:
cordova-res : 0.15.4
native-run : 1.5.0
System:
NodeJS : v14.18.3 (C:\Program Files\nodejs\node.exe)
npm : 6.14.15
OS : Windows 10
```
**Other Information:**
Nx monorepo with a react app
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
先使用 ionic.config.json、根目錄的 package.json 和 apps/myapp/package.json,從 Nx monorepo 根目錄重現回報的三種行為。比較 ionic serve/build 與 ionic cap 命令,並確認設定的應用程式根目錄和根目錄的 node_modules 是否以一致的方式處理;完成的條件是文件中的命令可以從 monorepo 根目錄執行,且沒有重複的相依套件。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- react, typescript
- 領域
- cli, tooling
- Issue 類型
- 缺陷
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 活躍度
- 停滯
- 描述清晰度
- 基本清楚
- 新手友好度
- 25/100