ionic-team / ionic-team/ionic-cli

ionic/cli commands in a (react based) monorepo aren't working consistently

Abierto
#4,826 0 comentarios 0 reacciones 0 asignados Ver en GitHub
triage
Lenguaje dominante
TypeScript
Estrellas
2k
Forks
682
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

**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

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.